TracerProvider
Read onlyYes
FinalYes
Entry point for the tracing API.
Creates and manages tracers for different instrumentation scopes. The behavior (void, memory, OTLP, etc.) is determined by the injected processor.
Example usage:
// For testing with memory storage
$processor = new MemoryProcessor($exporter, $exporter, $exporter);
$provider = new TracerProvider($processor, new SystemClock());
// For OTLP export
$processor = batching_span_processor(otlp_span_exporter($transport));
$provider = new TracerProvider($processor, new SystemClock());
// For void/disabled tracing
$provider = new TracerProvider(new VoidProcessor(), new SystemClock());
$tracer = $provider->tracer('my-service', '1.0.0');
$span = $tracer->span('operation');
$tracer->complete($span);
Methods
- __construct() : mixed
- tracer() : Tracer
- Create a tracer for the given instrumentation scope.
Methods
__construct()
public
__construct(SpanProcessor $processor, ClockInterface $clock, ContextStorage $contextStorage[, Sampler $sampler = new AlwaysOnSampler() ]) : mixed
Parameters
- $processor : SpanProcessor
- $clock : ClockInterface
- $contextStorage : ContextStorage
- $sampler : Sampler = new AlwaysOnSampler()
tracer()
Create a tracer for the given instrumentation scope.
public
tracer(resource $resource, string $name[, string $version = 'unknown' ][, null|string $schemaUrl = null ][, null|Attributes $attributes = null ]) : Tracer
Note: Instance caching is handled by the Telemetry class. This method always creates a new Tracer instance.
Parameters
- $resource : resource
-
The resource context for all spans from this tracer
- $name : string
-
The name of the instrumentation scope (e.g., library name)
- $version : string = 'unknown'
-
The version of the instrumentation scope
- $schemaUrl : null|string = null
-
Schema URL for semantic conventions
- $attributes : null|Attributes = null
-
Additional scope attributes