Comments (16)
I'll send a patch in a few days.
from jaeger-client-php.
Just released 1.2.5 version.
from jaeger-client-php.
Hmm, this is very interesting ... AFAIK, there is no such limitation. At least we use hundreds of spans in our projects.
from jaeger-client-php.
It seems to be caused by the size of the trace. This example causes the issue:
<?php
// https://github.com/jonahgeorge/jaeger-client-php/issues/109
const NESTED_SPAN_COUNT = 100;
const NESTED_SPAN_TAG_VALUE_BYTE_COUNT = 400;
require_once __DIR__.'/../lib/vendor/autoload.php';
use OpenTracing\GlobalTracer;
try {
$config = new \Jaeger\Config(
[
'sampler' => [
'type' => \Jaeger\SAMPLER_TYPE_CONST,
'param' => true,
],
'logging' => true,
"tags" => [
"foo" => "bar",
],
"local_agent" => [
"reporting_host" => "jaeger",
],
'dispatch_mode' => \Jaeger\Config::JAEGER_OVER_BINARY_UDP,
],
'my-app',
); $config->initializeTracer();
} catch (Throwable $e) {
error_log("ERROR could not initialize tracer: $e");
}
$tracer = GlobalTracer::get();
$scope = $tracer->startActiveSpan('main', []);
for ($i = 0; $i < NESTED_SPAN_COUNT; $i++) {
$nestedSpanScope = $tracer->startActiveSpan("nested");
$nestedSpanScope->getSpan()
->setTag('key', bin2hex(random_bytes(NESTED_SPAN_TAG_VALUE_BYTE_COUNT)));
usleep(1000);
$nestedSpanScope->close();
}
$scope->close();
$tracer->flush();
$spanContext = $scope->getSpan()->getContext();
if (\is_a($spanContext, \Jaeger\SpanContext::class)) {
$traceId = dechex($spanContext->getTraceId());
error_log("TRACE_ID={$traceId}");
}
I don't get this issue if I either set
NESTED_SPAN_COUNT = 10
orNESTED_SPAN_TAG_VALUE_BYTE_COUNT = 200
I guess, the UDP package size may be the issue. Any idea for a workaround?
from jaeger-client-php.
Hi! Yes, you are right about UDP package size. To be sure about that try to use some logger here.
Example:
class StdErrLogger implements \Psr\Log\LoggerInterface
{
use LoggerTrait;
public function log($level, $message, array $context = array())
{
if ($level === "debug") {
return ;
}
fwrite(STDERR, sprintf("Level: %s, Msg: %s", $level, $message));
}
}
Then use it as 3rd parameter to Config constructor:
$config = new Config(
[
'sampler' => [
'type' => Jaeger\SAMPLER_TYPE_CONST,
'param' => true,
],
'logging' => true,
],
'your-app-name',
new StdErrLogger() // <---------
);
Then you will see a message like this: Level: warning, Msg: socket_write failed: [code - 40] Message too long
.
The solution can be to call $tracer->flush();
somewhere inside you loop to reduce the size of udp package. Example:
$scope1 = $tracer->startActiveSpan('TestSpan', []);
for ($j = 0; $j < 4; $j++) {
$scope2 = $tracer->startActiveSpan(sprintf("Child %d; level 1", $j));
for ($i = 0; $i < 50; $i++) {
$scope3 = $tracer->startActiveSpan(sprintf("Child %d level 2", $i));
$scope3->close();
if ($i % 10 === 0) {
$tracer->flush(); // <-------
}
}
$scope2->close();
}
$scope1->close();
$tracer->flush();
We will think about the way on how to optimise this.
from jaeger-client-php.
Then you will see a message like this:
Level: warning, Msg: socket_write failed: [code - 40] Message too long
.
@pekhota Thanks, I do not get such a message (without the flushing in between). Is this a bug?
If I add the flush as you described, it works. Do you think it is possible to automatically flush, before the maximum UDP package size is exceeded?
from jaeger-client-php.
It seems the key point is to call $tracer->flush();
right after $scope->close();
iif the maximum UDP package size is exceeded (or close to be). So I don't think this is hard to implement. @maiermic Would you like to send a patch?
from jaeger-client-php.
Would you like to send a patch?
What should the patch contain? Do you mean a PR with the auto-flush logic?
from jaeger-client-php.
Do you think it is possible to automatically flush, before the maximum UDP package size is exceeded?
Shouldn't UdpSender::send already do this using UdpSender:: chunkSplit?
from jaeger-client-php.
Would you like to send a patch?
What should the patch contain? Do you mean a PR with the auto-flush logic?
Yeah, I meant exactly this.
from jaeger-client-php.
@maiermic try this fix #112. If everything good we will release new version.
from jaeger-client-php.
@pekhota How can I install this version in my project?
from jaeger-client-php.
@maiermic A fix for this issue has been merged into the master branch. Could you please check master branch, so we can release a new version?
from jaeger-client-php.
Does this mean, I can install this version using composer require jonahgeorge/jaeger-client-php:dev-master
?
from jaeger-client-php.
yes
from jaeger-client-php.
Thanks 👍 I can confirm that it works 🚀
from jaeger-client-php.
Related Issues (20)
- Curly braces deprecated in php 7.4 in Thrift package HOT 1
- Booleans in tags are casted to string HOT 1
- Allowed memory size of bytes exhausted HOT 1
- How to ensure closing? HOT 10
- How to create multiple tracers? HOT 7
- tag values are limited to 1024 chars
- Add psr/cache 2.0 support HOT 1
- PHP 8.1 throws warning with package HOT 3
- semm not work for jaeger version 1.34.1 HOT 1
- Support `tags` on `Config` HOT 2
- Please upgrade the Thrift package HOT 1
- Can you create a new release tag? HOT 1
- execute gethostbyname() in the Tracer constructor is not optimal HOT 2
- TextCodec produces malformed trace identity, trace/span ids should be exactly 16 characters HOT 1
- TraceIDs dispatched are not consistent with IDs produced by tracer HOT 2
- Allowed memory size on tag 1.5.0 HOT 3
- PHP Deprecated: explode(): Passing null to parameter HOT 1
- Provide traceId/context to dependent microservice HOT 1
- PHP 8 support HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jaeger-client-php.