PHP code example of waffle-commons / telemetry-otel
1. Go to this page and download the library: Download waffle-commons/telemetry-otel library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
waffle-commons / telemetry-otel example snippets
use Waffle\Commons\TelemetryOtel\Factory\OtelTracerFactory;
use Waffle\Commons\TelemetryOtel\Propagation\W3CTraceContextPropagator;
// Local/dev: export spans as JSON to php://stdout (docker logs becomes a zero-dependency
// span collector). Swap OtelTracerFactory::create($serviceName, $exporter) for a real
// OTLP exporter in production.
$tracer = OtelTracerFactory::console(serviceName: 'waffle-app');
$propagator = new W3CTraceContextPropagator();
$container->set(TracerInterface::class, $tracer);