Giter VIP home page Giter VIP logo

Comments (16)

pekhota avatar pekhota commented on July 23, 2024 2

I'll send a patch in a few days.

from jaeger-client-php.

sergeyklay avatar sergeyklay commented on July 23, 2024 2

Just released 1.2.5 version.

from jaeger-client-php.

sergeyklay avatar sergeyklay commented on July 23, 2024

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.

maiermic avatar maiermic commented on July 23, 2024

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 or
  • NESTED_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.

pekhota avatar pekhota commented on July 23, 2024

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.

maiermic avatar maiermic commented on July 23, 2024

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.

sergeyklay avatar sergeyklay commented on July 23, 2024

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.

maiermic avatar maiermic commented on July 23, 2024

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.

maiermic avatar maiermic commented on July 23, 2024

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.

sergeyklay avatar sergeyklay commented on July 23, 2024

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.

pekhota avatar pekhota commented on July 23, 2024

@maiermic try this fix #112. If everything good we will release new version.

from jaeger-client-php.

maiermic avatar maiermic commented on July 23, 2024

@pekhota How can I install this version in my project?

from jaeger-client-php.

sergeyklay avatar sergeyklay commented on July 23, 2024

@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.

maiermic avatar maiermic commented on July 23, 2024

Does this mean, I can install this version using composer require jonahgeorge/jaeger-client-php:dev-master?

from jaeger-client-php.

pekhota avatar pekhota commented on July 23, 2024

yes

from jaeger-client-php.

maiermic avatar maiermic commented on July 23, 2024

Thanks 👍   I can confirm that it works 🚀

from jaeger-client-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.