Use basis-company/telemetry instead!
The recommended way to install the library is through Composer:
$ composer require basis-company/opentelemetry
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
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.