DSL
Functions
trace_id()
Create a TraceId.
trace_id([null|string $hex = null ]) : TraceId
If a hex string is provided, creates a TraceId from it. Otherwise, generates a new random TraceId.
Parameters
- $hex : null|string = null
-
Optional 32-character hexadecimal string
Tags
Return values
TraceIdspan_id()
Create a SpanId.
span_id([null|string $hex = null ]) : SpanId
If a hex string is provided, creates a SpanId from it. Otherwise, generates a new random SpanId.
Parameters
- $hex : null|string = null
-
Optional 16-character hexadecimal string
Tags
Return values
SpanIdbaggage()
Create a Baggage.
baggage([array<string, string> $entries = [] ]) : Baggage
Parameters
- $entries : array<string, string> = []
-
Initial key-value entries
Return values
Baggagecontext()
Create a Context.
context([null|TraceId $traceId = null ][, null|Baggage $baggage = null ]) : Context
If no TraceId is provided, generates a new one. If no Baggage is provided, creates an empty one.
Parameters
- $traceId : null|TraceId = null
-
Optional TraceId to use
- $baggage : null|Baggage = null
-
Optional Baggage to use
Return values
Contextmemory_context_storage()
Create a MemoryContextStorage.
memory_context_storage([null|Context $context = null ]) : MemoryContextStorage
In-memory context storage for storing and retrieving the current context. A single instance should be shared across all providers within a request lifecycle.
Parameters
- $context : null|Context = null
-
Optional initial context
Return values
MemoryContextStorageresource()
Create a Resource.
resource([array<string, array<string|int, bool|float|int|string>|bool|float|int|string> $attributes = [] ]) : Resource
Parameters
- $attributes : array<string, array<string|int, bool|float|int|string>|bool|float|int|string> = []
-
Resource attributes
Return values
Resourcespan_context()
Create a SpanContext.
span_context(TraceId $traceId, SpanId $spanId[, null|SpanId $parentSpanId = null ]) : SpanContext
Parameters
- $traceId : TraceId
-
The trace ID
- $spanId : SpanId
-
The span ID
- $parentSpanId : null|SpanId = null
-
Optional parent span ID
Return values
SpanContextspan_event()
Create a SpanEvent (GenericEvent) with an explicit timestamp.
span_event(string $name, DateTimeImmutable $timestamp[, array<string, array<string|int, bool|float|int|string>|bool|float|int|string> $attributes = [] ]) : GenericEvent
Parameters
- $name : string
-
Event name
- $timestamp : DateTimeImmutable
-
Event timestamp
- $attributes : array<string, array<string|int, bool|float|int|string>|bool|float|int|string> = []
-
Event attributes
Return values
GenericEventspan_link()
Create a SpanLink.
span_link(SpanContext $context[, array<string, array<string|int, bool|float|int|string>|bool|float|int|string> $attributes = [] ]) : SpanLink
Parameters
- $context : SpanContext
-
The linked span context
- $attributes : array<string, array<string|int, bool|float|int|string>|bool|float|int|string> = []
-
Link attributes
Return values
SpanLinkvoid_span_processor()
Create a VoidSpanProcessor.
void_span_processor() : VoidSpanProcessor
No-op span processor that discards all data. Use this when tracing is disabled to minimize overhead.
Return values
VoidSpanProcessorvoid_metric_processor()
Create a VoidMetricProcessor.
void_metric_processor() : VoidMetricProcessor
No-op metric processor that discards all data. Use this when metrics collection is disabled to minimize overhead.
Return values
VoidMetricProcessorvoid_log_processor()
Create a VoidLogProcessor.
void_log_processor() : VoidLogProcessor
No-op log processor that discards all data. Use this when logging is disabled to minimize overhead.
Return values
VoidLogProcessorvoid_span_exporter()
Create a VoidSpanExporter.
void_span_exporter() : VoidSpanExporter
No-op span exporter that discards all data. Use this when telemetry export is disabled to minimize overhead.
Return values
VoidSpanExportervoid_metric_exporter()
Create a VoidMetricExporter.
void_metric_exporter() : VoidMetricExporter
No-op metric exporter that discards all data. Use this when telemetry export is disabled to minimize overhead.
Return values
VoidMetricExportervoid_log_exporter()
Create a VoidLogExporter.
void_log_exporter() : VoidLogExporter
No-op log exporter that discards all data. Use this when telemetry export is disabled to minimize overhead.
Return values
VoidLogExportermemory_span_exporter()
Create a MemorySpanExporter.
memory_span_exporter() : MemorySpanExporter
Span exporter that stores data in memory. Provides direct getter access to exported spans. Useful for testing and inspection without serialization.
Return values
MemorySpanExportermemory_metric_exporter()
Create a MemoryMetricExporter.
memory_metric_exporter() : MemoryMetricExporter
Metric exporter that stores data in memory. Provides direct getter access to exported metrics. Useful for testing and inspection without serialization.
Return values
MemoryMetricExportermemory_log_exporter()
Create a MemoryLogExporter.
memory_log_exporter() : MemoryLogExporter
Log exporter that stores data in memory. Provides direct getter access to exported log entries. Useful for testing and inspection without serialization.
Return values
MemoryLogExportermemory_span_processor()
Create a MemorySpanProcessor.
memory_span_processor(SpanExporter $exporter) : MemorySpanProcessor
Span processor that stores spans in memory and exports via configured exporter. Useful for testing.
Parameters
- $exporter : SpanExporter
-
The exporter to send spans to
Return values
MemorySpanProcessormemory_metric_processor()
Create a MemoryMetricProcessor.
memory_metric_processor(MetricExporter $exporter) : MemoryMetricProcessor
Metric processor that stores metrics in memory and exports via configured exporter. Useful for testing.
Parameters
- $exporter : MetricExporter
-
The exporter to send metrics to
Return values
MemoryMetricProcessormemory_log_processor()
Create a MemoryLogProcessor.
memory_log_processor(LogExporter $exporter) : MemoryLogProcessor
Log processor that stores log records in memory and exports via configured exporter. Useful for testing.
Parameters
- $exporter : LogExporter
-
The exporter to send logs to
Return values
MemoryLogProcessortracer_provider()
Create a TracerProvider.
tracer_provider(SpanProcessor $processor, ClockInterface $clock, ContextStorage $contextStorage[, Sampler $sampler = new AlwaysOnSampler() ]) : TracerProvider
Creates a provider that uses a SpanProcessor for processing spans. For void/disabled tracing, pass void_processor(). For memory-based testing, pass memory_processor() with exporters.
Parameters
- $processor : SpanProcessor
-
The processor for spans
- $clock : ClockInterface
-
The clock for timestamps
- $contextStorage : ContextStorage
-
Storage for context propagation
- $sampler : Sampler = new AlwaysOnSampler()
-
Sampling strategy for spans
Return values
TracerProviderlogger_provider()
Create a LoggerProvider.
logger_provider(LogProcessor $processor, ClockInterface $clock, ContextStorage $contextStorage) : LoggerProvider
Creates a provider that uses a LogProcessor for processing logs. For void/disabled logging, pass void_processor(). For memory-based testing, pass memory_processor() with exporters.
Parameters
- $processor : LogProcessor
-
The processor for logs
- $clock : ClockInterface
-
The clock for timestamps
- $contextStorage : ContextStorage
-
Storage for span correlation
Return values
LoggerProvidermeter_provider()
Create a MeterProvider.
meter_provider(MetricProcessor $processor, ClockInterface $clock[, AggregationTemporality $temporality = AggregationTemporality::CUMULATIVE ][, ExemplarFilter $exemplarFilter = new TraceBasedExemplarFilter() ]) : MeterProvider
Creates a provider that uses a MetricProcessor for processing metrics. For void/disabled metrics, pass void_processor(). For memory-based testing, pass memory_processor() with exporters.
Parameters
- $processor : MetricProcessor
-
The processor for metrics
- $clock : ClockInterface
-
The clock for timestamps
- $temporality : AggregationTemporality = AggregationTemporality::CUMULATIVE
-
Aggregation temporality for metrics
- $exemplarFilter : ExemplarFilter = new TraceBasedExemplarFilter()
-
Filter for exemplar sampling (default: TraceBasedExemplarFilter)
Return values
MeterProvidertelemetry()
Create a new Telemetry instance with the given providers.
telemetry(resource $resource[, null|TracerProvider $tracerProvider = null ][, null|MeterProvider $meterProvider = null ][, null|LoggerProvider $loggerProvider = null ]) : Telemetry
If providers are not specified, void providers (no-op) are used.
Parameters
- $resource : resource
-
The resource describing the entity producing telemetry
- $tracerProvider : null|TracerProvider = null
-
The tracer provider (null for void/disabled)
- $meterProvider : null|MeterProvider = null
-
The meter provider (null for void/disabled)
- $loggerProvider : null|LoggerProvider = null
-
The logger provider (null for void/disabled)
Return values
Telemetryinstrumentation_scope()
Create an InstrumentationScope.
instrumentation_scope(string $name[, string $version = 'unknown' ][, null|string $schemaUrl = null ][, Attributes $attributes = new Attributes() ]) : InstrumentationScope
Parameters
- $name : string
-
The instrumentation scope name
- $version : string = 'unknown'
-
The instrumentation scope version
- $schemaUrl : null|string = null
-
Optional schema URL
- $attributes : Attributes = new Attributes()
Return values
InstrumentationScopebatching_span_processor()
Create a BatchingSpanProcessor.
batching_span_processor(SpanExporter $exporter[, int $batchSize = 512 ]) : BatchingSpanProcessor
Collects spans in memory and exports them in batches for efficiency. Spans are exported when batch size is reached, flush() is called, or shutdown().
Parameters
- $exporter : SpanExporter
-
The exporter to send spans to
- $batchSize : int = 512
-
Number of spans to collect before exporting (default 512)
Return values
BatchingSpanProcessorpass_through_span_processor()
Create a PassThroughSpanProcessor.
pass_through_span_processor(SpanExporter $exporter) : PassThroughSpanProcessor
Exports each span immediately when it ends. Useful for debugging where immediate visibility is more important than performance.
Parameters
- $exporter : SpanExporter
-
The exporter to send spans to
Return values
PassThroughSpanProcessorbatching_metric_processor()
Create a BatchingMetricProcessor.
batching_metric_processor(MetricExporter $exporter[, int $batchSize = 512 ]) : BatchingMetricProcessor
Collects metrics in memory and exports them in batches for efficiency. Metrics are exported when batch size is reached, flush() is called, or shutdown().
Parameters
- $exporter : MetricExporter
-
The exporter to send metrics to
- $batchSize : int = 512
-
Number of metrics to collect before exporting (default 512)
Return values
BatchingMetricProcessorpass_through_metric_processor()
Create a PassThroughMetricProcessor.
pass_through_metric_processor(MetricExporter $exporter) : PassThroughMetricProcessor
Exports each metric immediately when processed. Useful for debugging where immediate visibility is more important than performance.
Parameters
- $exporter : MetricExporter
-
The exporter to send metrics to
Return values
PassThroughMetricProcessorbatching_log_processor()
Create a BatchingLogProcessor.
batching_log_processor(LogExporter $exporter[, int $batchSize = 512 ]) : BatchingLogProcessor
Collects log records in memory and exports them in batches for efficiency. Logs are exported when batch size is reached, flush() is called, or shutdown().
Parameters
- $exporter : LogExporter
-
The exporter to send logs to
- $batchSize : int = 512
-
Number of logs to collect before exporting (default 512)
Return values
BatchingLogProcessorpass_through_log_processor()
Create a PassThroughLogProcessor.
pass_through_log_processor(LogExporter $exporter) : PassThroughLogProcessor
Exports each log record immediately when processed. Useful for debugging where immediate visibility is more important than performance.
Parameters
- $exporter : LogExporter
-
The exporter to send logs to
Return values
PassThroughLogProcessorconsole_span_exporter()
Create a ConsoleSpanExporter.
console_span_exporter([bool $colors = true ]) : ConsoleSpanExporter
Outputs spans to the console with ASCII table formatting. Useful for debugging and development.
Parameters
- $colors : bool = true
-
Whether to use ANSI colors (default: true)
Return values
ConsoleSpanExporterconsole_metric_exporter()
Create a ConsoleMetricExporter.
console_metric_exporter([bool $colors = true ]) : ConsoleMetricExporter
Outputs metrics to the console with ASCII table formatting. Useful for debugging and development.
Parameters
- $colors : bool = true
-
Whether to use ANSI colors (default: true)
Return values
ConsoleMetricExporterconsole_log_exporter()
Create a ConsoleLogExporter.
console_log_exporter([bool $colors = true ][, null|int $maxBodyLength = 100 ]) : ConsoleLogExporter
Outputs log records to the console with severity-based coloring. Useful for debugging and development.
Parameters
- $colors : bool = true
-
Whether to use ANSI colors (default: true)
- $maxBodyLength : null|int = 100
-
Maximum length for body+attributes column (null = no limit, default: 100)
Return values
ConsoleLogExporteralways_on_exemplar_filter()
Create an AlwaysOnExemplarFilter.
always_on_exemplar_filter() : AlwaysOnExemplarFilter
Records exemplars whenever a span context is present. Use this filter for debugging or when complete trace context is important.
Return values
AlwaysOnExemplarFilteralways_off_exemplar_filter()
Create an AlwaysOffExemplarFilter.
always_off_exemplar_filter() : AlwaysOffExemplarFilter
Never records exemplars. Use this filter to disable exemplar collection entirely for performance optimization.
Return values
AlwaysOffExemplarFiltertrace_based_exemplar_filter()
Create a TraceBasedExemplarFilter.
trace_based_exemplar_filter() : TraceBasedExemplarFilter
Records exemplars only when the span is sampled (has SAMPLED trace flag). This is the default filter, balancing exemplar collection with performance.
Return values
TraceBasedExemplarFilterpropagation_context()
Create a PropagationContext.
propagation_context([null|SpanContext $spanContext = null ][, null|Baggage $baggage = null ]) : PropagationContext
Value object containing both trace context (SpanContext) and application data (Baggage) that can be propagated across process boundaries.
Parameters
- $spanContext : null|SpanContext = null
-
Optional span context
- $baggage : null|Baggage = null
-
Optional baggage
Return values
PropagationContextarray_carrier()
Create an ArrayCarrier.
array_carrier([array<string, string> $data = [] ]) : ArrayCarrier
Carrier backed by an associative array with case-insensitive key lookup.
Parameters
- $data : array<string, string> = []
-
Initial carrier data
Return values
ArrayCarriersuperglobal_carrier()
Create a SuperglobalCarrier.
superglobal_carrier() : SuperglobalCarrier
Read-only carrier that extracts context from PHP superglobals ($_SERVER, $_GET, $_POST, $_COOKIE).
Return values
SuperglobalCarrierw3c_trace_context()
Create a W3CTraceContext propagator.
w3c_trace_context() : W3CTraceContext
Implements W3C Trace Context specification for propagating trace context using traceparent and tracestate headers.
Return values
W3CTraceContextw3c_baggage()
Create a W3CBaggage propagator.
w3c_baggage() : W3CBaggage
Implements W3C Baggage specification for propagating application-specific key-value pairs using the baggage header.
Return values
W3CBaggagecomposite_propagator()
Create a CompositePropagator.
composite_propagator(Propagator ...$propagators) : CompositePropagator
Combines multiple propagators into one. On extract, all propagators are invoked and their contexts are merged. On inject, all propagators are invoked.
Parameters
- $propagators : Propagator
-
The propagators to combine