basis-company / opentelemetry
Installs: 3 298
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.1|^8
Requires (Dev)
- composer/xdebug-handler: ^1.3
- phpunit/phpunit: ^7.5.16
README
Use basis-company/telemetry instead!
OpenTelemetry php library
Installation
The recommended way to install the library is through Composer:
$ composer require basis-company/opentelemetry
Tracing
Library is under active development, but simple example should be present in readme.
In addition, see tracing tests for full-featured example.
<?php use OpenTelemetry\Tracing\Builder; use OpenTelemetry\Tracing\SpanContext; $spanContext = SpanContext::generate(); // or extract from headers $tracer = Builder::create()->setSpanContext($spanContext)->getTracer(); // start a span, register some events $span = $tracer->createSpan('session.generate'); // set attributes as array $span->setAttributes([ 'remote_ip' => '5.23.99.245' ]); // set attribute one by one $span->setAttribute('country', 'Russia'); $span->addEvent('found_login', [ 'id' => 67235, 'username' => 'nekufa', ]); $span->addEvent('generated_session', [ 'id' => md5(microtime(true)) ]); $span->end(); // pass status as an optional argument
Testing
To make sure the tests in this repo work as you expect, you can use the included docker test wrapper:
1.) Make sure that you have docker installed
2.) Execute ./resources/test-using-docker
from your bash compatible shell.