websupport / yii-opentracing
OpenTracing component for Yii
Installs: 14 877
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 12
Forks: 1
Open Issues: 0
Type:yii-extension
Requires
- php: >=7.2
- opentracing/opentracing: ^1.0.0
- ralouphie/getallheaders: ^2.0 || ^3.0
- yiisoft/yii: ^1.1.18
Requires (Dev)
- jonahgeorge/jaeger-client-php: dev-master
- phpunit/phpunit: ^8.5.0
- roave/security-advisories: dev-master
Suggests
- jonahgeorge/jaeger-client-php: Required for reporting data to Jaeger
Conflicts
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-10-25 00:24:25 UTC
README
Yii OpenTracing extension
OpenTracing extension for Yii 1
Installation
Install Yii extension with composer
composer require websupport/yii-opentracing
Install client library (depends on your tracing system)
composer require jonahgeorge/jaeger-client-php
Configuration
Default (NoopTracer) configuration without client library
# opentracing component must be preloaded 'preload' => ['opentracing'], ... 'components' => [ 'opentracing' => [ 'class' => \Websupport\OpenTracing\OpenTracing::class, ], ],
Jaeger client configuration
# opentracing component must be preloaded 'preload' => ['opentracing'], ... 'components' => [ 'opentracing' => [ 'class' => \Websupport\OpenTracing\JaegerOpenTracing::class, 'agentHost' => 'localhost', 'agentPort' => 5775, 'sampler' => [ 'type' => \Jaeger\SAMPLER_TYPE_CONST, 'param' => true, ], 'traceIdHeader' => 'x-trace-id', 'baggageHeaderPrefix' => 'x-ctx-trace-', ], ],
OpenTracing in CActiveRecord
OpenTracing can be enabled in CActiveRecord
using behaviors
.
<?php use Websupport\OpenTracing\OpenTracingActiveRecordBehavior; class Model extends CActiveRecord { public function behaviors() { return [ 'OpenTracingActiveRecordBehavior' => [ 'class' => OpenTracingActiveRecordBehavior::class, 'opentracingId' => 'opentracing' // string opentracing component name ] ]; } }
Sentry integration
If you are using Sentry to track errors and want to store Sentry Event ID within current trace, you can achieve this in conjunction with websupport/yii-sentry component.
After installing and configuring this component, each trace, where any error occurred will have its error.sentry_id
tag filled with Sentry Event ID.
'components' => [ 'opentracing' => [ 'class' => \Websupport\OpenTracing\JaegerOpenTracing::class, 'sentryId' => 'sentry' // or name of your yii-sentry component ... ], 'sentry' => [ // yii-sentry component 'class' => \Websupport\YiiSentry\Client::class ... ] ],