Coder Social home page Coder Social logo

jukylin / jaeger-php Goto Github PK

View Code? Open in Web Editor NEW
221.0 11.0 116.0 348 KB

Jaeger Bindings for PHP OpenTracing API

Home Page: https://github.com/jaegertracing/jaeger

License: Apache License 2.0

PHP 100.00%
opentracing jaeger php-client distributed-tracing zipkin istio

jaeger-php's Introduction

Build Status Minimum PHP Version License Coverage Status

jaeger-php

Install

Install via composer.

composer config minimum-stability dev
composer require jukylin/jaeger-php

Init Jaeger-php

$config = Config::getInstance();
$tracer = $config->initTracer('example', '0.0.0.0:6831');

128bit

$config->gen128bit();

Extract from Superglobals

$spanContext = $tracer->extract(Formats\TEXT_MAP, $_SERVER);

Start Span

$serverSpan = $tracer->startSpan('example HTTP', ['child_of' => $spanContext]);

Distributed context propagation

$serverSpan->addBaggageItem("version", "2.0.0");

Inject into Superglobals

$clientTrace->inject($clientSpan1->spanContext, Formats\TEXT_MAP, $_SERVER);

Tags and Log

// tags are searchable in Jaeger UI
$span->setTag('http.status', '200');

// log record
$span->log(['error' => 'HTTP request timeout']);

Close Tracer

$config->setDisabled(true);

Zipkin B3 Propagation

no support for Distributed context propagation

$config::$propagator = \Jaeger\Constants\PROPAGATOR_ZIPKIN;

Finish span and flush Tracer

$span->finish();
$config->flush();

More example

Features

  • Transports

    • via Thrift over UDP
  • Sampling

    • ConstSampler
    • ProbabilisticSampler

Reference

OpenTracing

Jaeger

jaeger-php's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jaeger-php's Issues

报错超时

Maximum execution time of 6 seconds exceeded
错误位置
FILE: E:\WWW\ichuntapi\vendor\packaged\thrift\src\Thrift\Protocol\TCompactProtocol.php  LINE: 722

Some API/documentation issues

initTracer

$tracer = $config->initTrace('example', '0.0.0.0:6831');
  • should be initTracer
  • The parameters look positional, is only UDP sender currently supported?

Close Trace(r)?

$config->setDisabled(true);

I am not sure what this does. Method does not have English comment.

Flush trace

$config->flush();

This method looks like it forces flushing of all spans from memory buffers - should it not be a method on the Tracer object then? Config is just a factory for the Tracer.

next release?

Hi,

when do you plan releasing the next version of you library? We would like to operate at least on beta versions instead of dev-master.

Thanks,
best regards, @cawolf

两个微服务trace-id怎么不同?

第一个服务:
image
traceID: "15dd6f536e02bfd215dd6f536e01da6c",
spanID: "15dd6f538a7c7f00",
traceID: "15dd6f536e02bfd215dd6f536e01da6c",
spanID: "15dd6f536e01da6c",

第二个服务:
image
traceID: "15dd6f54a0b18e0515dd6f54a0afe764",

分布式链路跟踪,多个服务的trace-id应该是相同的吧?是我理解错了,还是哪里操作不对?
每个项目入口:
image

CI build, distribution, and badges

There is no Travis config, I assume the unit tests are not run automatically on pull requests. Can the Travis build be set up?

I don't know how PHP modules are usually distributed, is there some repository (like npm, pypi, Maven) where the module is packaged and distributed? Or do people always import it directly from GitHub? If there is a repository, please document it in the README.

Please include badges in the README for the Travis build, latest release version of the module, and the repository (if available).

Update packagist.org

Please update your package on packagist (or setup auto-updating). There is only 2.0.9-beta there. Thanks.

x-b3-traceid overflow

istio generate hexadecimal numbers beyond the decimal range, for example: af857efd81c82641,effect trace-without-root-span bug

How to use elasticsearch store,instead of TMemoryBuffer ?

I run jaegertracing/all-in-one in docker,It does work and this tracing show in jaeger ui because of using memory to store.

But now I use elasticsearch instead of memory,so I run all the service correctly in docker include es6.3.1,jaeger-collector,jaeger-query,jaeger-agent.In my project I can get traceId correctly.But it does not show in jaeger ui.

Now i install thrift in my window 10.Which class i can use to replace TMemoryBuffer() in TransportUdp on line 64?And how to use it? And somebody said thrift does not work on windows system,must run in linux, is it true?

Thank you !!!

uber-trace-id 能不能换个常量?

const Tracer_State_Header_Name = 'uber-trace-id';
const Trace_Baggage_Header_Prefix = 'uberctx-';
这两个带uber了 不好吧,能不能换个其他的

start_time of StartSpanOptions is ignored

According to the opentracing/opentracing-php specification, the value start_time should be respected if passed in as part of StartSpanOptions (or as an array).

The current implementation does not allow this, as the current time is used always. This is an issue if you try to implement delayed span creation in order to create spans by criteria (like timing). Example: I want to create spans only if they would be longer than 2 seconds, but I get this information at the end of the span.

Make library compatible with php 8

These errors occurs:
TypeError: Unsupported operand types: string - int
/vendor/jukylin/jaeger-php/src/Jaeger/Transport/TransportUdp.php:62

Deprecated: Required parameter $reporter follows optional parameter $serverName in /vendor/jukylin/jaeger-php/src/Jaeger/Jaeger.php on line 51

Problem with generateId on macOS PHP 7.0, 7.1

I have a weird problem which seems to only affect PHP versions (of MAMP) on macOS where the trace ID is always 10000000000000001. I have tested with 7.0.33 and 7.1.32, both have the issue. 7.2.22 is not affected. Also other operating system versions (at least Alpine Linux and Debian) are seemingly not affected.

Jaeger has the method

private function generateId(){
    return microtime(true) * 10000 . rand(10000, 99999);
}

In the mentioned environments this produces e.g. 1.58375696973E+1330420 a very large number that cannot be processed. It seems that on that systems microtime(true) * 10000 is in exponent notation 1.58375693969E+13 and then the rand part is concatenated to the exponent yielding that large number.

On not affected systems the output is the correct e.g. 1583757054325111449.

I have tried to work around the problem but I don't know enough about how trace IDs have to be composed. I get a lot of zeros in the middle which then show up in JaegerUI too.

Do you see the possibility of modifying the method to work around that PHP bug (or whatever it is) on the mentioned systems?

Expected Span or SpanContext, got NULL

Hi,

I'm getting this error after using the next two lines

$spanContext = $tracer->extract(Formats\TEXT_MAP, $_SERVER);
$serverSpan = $tracer->startSpan('span-name', ['child_of' => $spanContext]);

Fatal error: Uncaught OpenTracing\Exceptions\InvalidSpanOption: Invalid child_of option. Expected Span or SpanContext, got NULL

My setup is
"jukylin/jaeger-php" : "^2.1.1-beta",
"opentracing/opentracing":"1.0.0-beta5"

Create span from JSON context rather then HTTP context

I'm confuse where we extract "$tracer->extract(Formats\TEXT_MAP, $_SERVER);" from $_SERVER.

I do understand the process and flow, but how can we create a root span by context rather using JSON?

FYI: I'm trying to use this in Laravel.

Make s span child of in another service

Hi, im start a sapn in a service called User then i request to another service called product.
how can i start span child of span which started in User service?
Thanks

Join forces

There is an issue open in the official Jaeger repository for a PHP client: jaegertracing/jaeger#211

Based on the comments, others are working on a client as well. Maybe joining forces would be a good idea to create an official Jaeger client for PHP.

Invalid child_of option. Expected Span or SpanContext, got NULL

Invalid child_of option. Expected Span or SpanContext, got NULL

opentracing/opentracing/src/OpenTracing/StartSpanOptions.php(164): OpenTracing\Exceptions\InvalidSpanOption::forInvalidChildOf(NULL)
opentracing/opentracing/src/OpenTracing/StartSpanOptions.php(49): OpenTracing\StartSpanOptions::buildChildOf(NULL)

fails on null

#89

在PHP5.6的环境中报错

哥们儿,我知道你是**人,我就不跟你扯英文了。

这个东西在PHP5.6环境中报错了:

PHP Fatal error: Cannot use OpenTracing\SpanContext as SpanContext because the name is already in use in /home/manhong/jeager/vendor/jukylin/jaeger-php/src/Jaeger/Span.php on line 5
PHP Stack trace:
PHP 1. {main}() /home/manhong/jeager/index.php:0
PHP 2. Jaeger\Jaeger->startSpan() /home/manhong/jeager/index.php:14
PHP 3. spl_autoload_call() /home/manhong/jeager/index.php:112
PHP 4. Composer\Autoload\ClassLoader->loadClass() /home/manhong/jeager/index.php:112
PHP 5. Composer\Autoload\includeFile() /home/manhong/jeager/vendor/composer/ClassLoader.php:322

Fatal error: Cannot use OpenTracing\SpanContext as SpanContext because the name is already in use in /home/manhong/jeager/vendor/jukylin/jaeger-php/src/Jaeger/Span.php on line 5

Call Stack:
0.0001 231896 1. {main}() /home/manhong/jeager/index.php:0
0.0030 786432 2. Jaeger\Jaeger->startSpan() /home/manhong/jeager/index.php:14
0.0032 822760 3. spl_autoload_call() /home/manhong/jeager/index.php:112
0.0032 822800 4. Composer\Autoload\ClassLoader->loadClass() /home/manhong/jeager/index.php:112
0.0032 822944 5. Composer\Autoload\includeFile() /home/manhong/jeager/vendor/composer/ClassLoader.php:322

只要注释掉 “vendor/jukylin/jaeger-php/src/Jaeger/Span.php” 文件中的 “use OpenTracing\SpanContext;“ 这一行就可以了。

我是用composer安装的,安装步骤如下:
composer require opentracing/opentracing 1.0.0-beta2
composer require jukylin/jaeger-php v2.0.5-beta

Zipkin B3 Propagation

Hi are you planning to add support for Zipkin B3 Propagation headers? Will be very useful for integration with service mash. Official Jaeger Client (at least for Go) also has support for this :)

Fatal error: Can't use library

Hey guys,
I've just installed you lib via composer as per documentation.

I've got:

  • opentracing/opentracing (1.0-beta1)
  • jukylin/jaeger-php (v2.0.0-beta)

Now, when I use it I see the following PHP Fatal error:

Xdebug: Fatal error: Declaration of Jaeger\Jaeger::inject(OpenTracing\SpanContext $spanContext, $format, &$carrier) must be compatible with OpenTracing\Tracer::inject(OpenTracing\SpanContext $spanContext, $format, OpenTracing\Propagators\Writer $carrier) in /srv/vendor/jukylin/jaeger-php/src/Jaeger/Jaeger.php on line 13.

It looks like package versions are not compatible. Can you please let me know if this is a known issue?

Thanks

is this can not support golang to php?

it is pretty good supporting php to php, but i found that golang (or other language or platform like postman) to php is sure when error occured. And i can not find datas by a correct request. so why? or that is there any other config operation i ignored to do?
Thanks :)

不支持http header透传?

/**
 * 注入
 * @param SpanContext $spanContext
 * @param string $format
 * @param $carrier
 */
public function inject(SpanContext $spanContext, $format, &$carrier){
    if($format == Formats\TEXT_MAP){
        $this->propagator->inject($spanContext, $format, $carrier);
    }else{
        throw new \Exception("not support format $format");
    }
}


/**
 * 提取
 * @param string $format
 * @param $carrier
 */
public function extract($format, $carrier){
    if($format == Formats\TEXT_MAP){
        return $this->propagator->extract($format, $carrier);
    }else{
        throw new \Exception("not support format $format");
    }
}

const HTTP_HEADERS = 'http_headers'; 不支持http header透传?

Tracing AMQP Workflow

For a workflow as follows:

Start (Service A) -- amqp --> General Processing (Service B) ---
--- amqp --> Fork into two queues Task C (Service C) and D (Service D)

The exact similar case of jaegertracing/jaeger-client-python#122

From the code examples:

$tracer = $config->initTrace('Service A', '0.0.0.0:6831');
$spanContext = $tracer->extract(Formats\TEXT_MAP, $_SERVER);

$serverSpan = $tracer->startSpan('get data', ['child_of' => $spanContext]);
$serverSpan->addBaggageItem("version", "1.6.0");

$tracer->inject($serverSpan->getContext(), Formats\TEXT_MAP, $_SERVER);

Questions

  1. what does extract(Formats\TEXT_MAP, $_SERVER) achieve?
  2. Is it the server's spanContext that needs to be shared across all services and have them bi child_of of it?
  3. How would you recommend to share a trace that goes from Service A to Service D to cover the mentioned workflow?

Much appreciated!

两个微服务trace-id怎么不同?

第一个服务:
image
traceID: "15dd6f536e02bfd215dd6f536e01da6c",
spanID: "15dd6f538a7c7f00",
traceID: "15dd6f536e02bfd215dd6f536e01da6c",
spanID: "15dd6f536e01da6c",

第二个服务:
image
traceID: "15dd6f54a0b18e0515dd6f54a0afe764",

分布式链路跟踪,多个服务的trace-id应该是相同的吧?是我理解错了,还是哪里操作不对?
每个项目入口:
image

有个疑问

public function buildTags(){

        $thriftTags = [];
        if(empty($this->tags)){
            return $thriftTags;
        }

        foreach ($this->tags as $k => $v){
            switch(gettype($v)){
                case "string":
                    $thriftTags[] = [
                        'key' => $k,
                        'vType' => 'STRING',
                        'vStr' => $v,
                    ];
                    break;
                case "boolean":
                    $thriftTags[] = [
                        'key' => $k,
                        'vType' => 'BOOL',
                        'vBool' => $v,
                    ];
                    break;
                case "double":
                    $thriftTags[] = [
                        'key' => $k,
                        'vType' => 'DOUBLE',
                        'vDouble' => $v,
                    ];
                    break;
                case "integer":
                    $thriftTags[] = [
                        'key' => $k,
                        'vType' => 'DOUBLE',
                        'vDouble' => $v,
                    ];
                    break;
                case "array":
                    $thriftTags[] = [
                        'key' => $k,
                        'vType' => 'STRING',
                        'vStr' => json_encode($v, JSON_UNESCAPED_UNICODE),
                    ]; 
                //缺少 break;?
                default:
                    $thriftTags[] = [
                        'key' => $k,
                        'vType' => 'STRING',
                        'vStr' => is_string($v),
                    ];
            }
        }
        return $thriftTags;
    }

Istio example数据异常

按照master/example的代码进行部署测试,会上报如图所示的异常数据。正常访问没有问题,稍微提升Istio1.php的访问量就会异常。我是用浏览器刷的
"version": "v2.0.9-beta"
php version:7.1.8
Swoole version:4.4.12
image

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.