jcchavezs/zipkin-opentracing
Composer 安装命令:
composer require jcchavezs/zipkin-opentracing
包简介
A Zipkin bridge with OpenTracing
README 文档
README
Zipkin implementation for OpenTracingTracer in PHP.
This library allows OpenTracing API consumers to use Zipkin as their tracing backend. For details on how to work with spans and traces we suggest looking at the documentation and README from the OpenTracing API.
Getting started
Required Reading
In order to understand OpenTracing API, one must first be familiar with the OpenTracing project and terminology more generally.
To understand how Zipkin works, you can look at Zipkin Architecture and Zipkin PHP documentation.
Installation
composer require jcchavezs/zipkin-opentracing
Usage
Firstly, we need to setup a tracer:
use OpenTracing\GlobalTracer; use Psr\Log\NullLogger; use Zipkin\Endpoint; use Zipkin\Samplers\BinarySampler; use Zipkin\TracingBuilder; use Zipkin\Reporters\Http; $endpoint = Endpoint::create('my_service', '127.0.0.1', null, 8081); $reporter = new Zipkin\Reporters\Http(); $sampler = BinarySampler::createAsAlwaysSample(); $tracing = TracingBuilder::create() ->havingLocalEndpoint($endpoint) ->havingSampler($sampler) ->havingReporter($reporter) ->build(); $zipkinTracer = new ZipkinOpenTracing\Tracer($tracing); GlobalTracer::set($zipkinTracer); // optional
Creating Spans
- Starting a root span
- Starting a span for a given request
- Active span and scope manager
- Using span options
Propagation of context
Flushing Spans to the agent
PHP as a request scoped language has no simple means to pass the collected spans data to a background process without
blocking the main request thread/process. It is mandatory to execute the Tracer::flush() after the response is served
to the client by using register_shutdown_function.
use OpenTracing\GlobalTracer; $application->run(); register_shutdown_function(function() { GlobalTracer::get()->flush(); });
Contribution
Run tests
composer test
Fix lint
composer fix-lint
jcchavezs/zipkin-opentracing 适用场景与选型建议
jcchavezs/zipkin-opentracing 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.06M 次下载、GitHub Stars 达 24, 最近一次更新时间为 2018 年 01 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jcchavezs/zipkin-opentracing 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jcchavezs/zipkin-opentracing 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.06M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 24
- 点击次数: 36
- 依赖项目数: 14
- 推荐数: 2
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-20