Skip to content

Commit

Permalink
fix exception
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill committed Dec 14, 2020
1 parent f58a6f4 commit 371b709
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 28 deletions.
51 changes: 39 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
{
"name": "jukylin/jaeger-php",
"description": "php client for jaeger",
"keywords": ["jaeger","trace","opentracing"],
"license": "Apache-2.0",
"name": "poyuki/jaeger-php",
"description": "php client for jaeger",
"keywords": [
"jaeger",
"trace",
"opentracing"
],
"license": "Apache-2.0",
"minimum-stability": "stable",
"require": {
"require": {
"php": ">=5.6.0",
"packaged/thrift" : "0.10.0",
"opentracing/opentracing" : "1.0.0-beta5"
"ext-ctype": "*",
"ext-sockets": "*",
"ext-json": "*",
"packaged/thrift": "0.10.0",
"opentracing/opentracing": "dev-master"
},
"require-dev": {
"phpunit/phpunit": "^5",
"php-coveralls/php-coveralls": "^1.0",
"phpstan/phpstan": "^0.12.56",
"roave/security-advisories": "dev-master",
"slevomat/coding-standard": "^6.1"
},
"authors": [
{
"name": "jukylin",
"email": "[email protected]"
}
],
"autoload": {
"autoload": {
"psr-4": {
"Jaeger\\": "src\\Jaeger"
},
Expand All @@ -24,10 +38,23 @@
]
},
"scripts": {
"test": "./vendor/bin/phpunit"
"test": "./vendor/bin/phpunit",
"app/validate": [
"@composer validate --no-check-all",
"@composer check-platform-reqs --no-ansi --no-interaction"
],
"app/ci": [
"@composer clearcache",
"@composer i --no-ansi --no-interaction --no-progress --optimize-autoloader --classmap-authoritative"
],
"app/code-analysis": "php vendor/bin/phpstan analyse --no-ansi --no-interaction --no-progress -l 5 src",
"app/code-analysis-dev": "php vendor/bin/phpstan analyse -l 7 src",
"app/code-style": "php vendor/bin/phpcs --standard=phpcs.xml --extensions=php",
"app/code-style-fix": "php vendor/bin/phpcbf -p --standard=phpcs.xml --extensions=php",
"app/tests": "php vendor/bin/codecept run unit"
},
"require-dev": {
"phpunit/phpunit": "^5",
"php-coveralls/php-coveralls": "^1.0"
"scripts-descriptions": {
"app/code-style": "Checks that the application code conforms to coding standard",
"app/code-style-fix": "Checks that the application code conforms to coding standard and automatically fix"
}
}
30 changes: 14 additions & 16 deletions src/Jaeger/Transport/TransportUdp.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
use Thrift\Transport\TMemoryBuffer;
use Thrift\Protocol\TCompactProtocol;
use Jaeger\Constants;
use const Jaeger\Constants\EMIT_BATCH_OVER_HEAD;
use const Jaeger\Constants\UDP_PACKET_MAX_LENGTH;

class TransportUdp implements Transport
{
Expand All @@ -34,32 +36,28 @@ class TransportUdp implements Transport
public static $hostPort = '';

// sizeof(Span) * numSpans + processByteSize + emitBatchOverhead <= maxPacketSize
public static $maxSpanBytes = 0;
public static int $maxSpanBytes = 0;

public static $batchs = [];

public $agentServerHostPort = '0.0.0.0:5775';

public $thriftProtocol = null;
public $thriftProtocol;

public $procesSize = 0;
public int $processSize = 0;

public $bufferSize = 0;
public int $bufferSize = 0;

const MAC_UDP_MAX_SIZE = 9216;

public function __construct($hostport = '', $maxPacketSize = '')
public function __construct(string $hostPort = '0.0.0.0:5775', int $maxPacketSize = 0)
{
if ($hostport == "") {
$hostport = $this->agentServerHostPort;
}
self::$hostPort = $hostport;
self::$hostPort = $hostPort;

if ($maxPacketSize == 0) {
$maxPacketSize = stristr(PHP_OS, 'DAR') ? self::MAC_UDP_MAX_SIZE : Constants\UDP_PACKET_MAX_LENGTH;
if ($maxPacketSize === 0) {
$maxPacketSize = str_contains(PHP_OS, 'DAR') ? self::MAC_UDP_MAX_SIZE : UDP_PACKET_MAX_LENGTH;
}

self::$maxSpanBytes = $maxPacketSize - Constants\EMIT_BATCH_OVER_HEAD;
self::$maxSpanBytes = $maxPacketSize - EMIT_BATCH_OVER_HEAD;

$this->tran = new TMemoryBuffer();
$this->thriftProtocol = new TCompactProtocol($this->tran);
Expand All @@ -70,8 +68,8 @@ public function buildAndCalcSizeOfProcessThrift(Jaeger $jaeger)
{
$jaeger->processThrift = (new JaegerThriftSpan())->buildJaegerProcessThrift($jaeger);
$jaeger->process = (new Process($jaeger->processThrift));
$this->procesSize = $this->getAndCalcSizeOfSerializedThrift($jaeger->process, $jaeger->processThrift);
$this->bufferSize += $this->procesSize;
$this->processSize = $this->getAndCalcSizeOfSerializedThrift($jaeger->process, $jaeger->processThrift);
$this->bufferSize += $this->processSize;
}


Expand Down Expand Up @@ -129,7 +127,7 @@ public function append(Jaeger $jaeger)

public function resetBuffer()
{
$this->bufferSize = $this->procesSize;
$this->bufferSize = $this->processSize;
self::$batchs = [];
}

Expand Down

0 comments on commit 371b709

Please sign in to comment.