Flow PHP

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
throws
InvalidArgumentException

if the hex string is invalid

Return values
TraceId

span_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
throws
InvalidArgumentException

if the hex string is invalid

Return values
SpanId

baggage()

Create a Baggage.

baggage([array<string, string> $entries = [] ]) : Baggage
Parameters
$entries : array<string, string> = []

Initial key-value entries

Return values
Baggage

context()

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
Context

memory_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
MemoryContextStorage

resource()

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
Resource

span_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
GenericEvent

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
SpanLink

void_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
VoidSpanProcessor

void_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
VoidMetricProcessor

void_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
VoidLogProcessor

void_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
VoidSpanExporter

void_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
VoidMetricExporter

void_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
VoidLogExporter

memory_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
MemorySpanExporter

memory_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
MemoryMetricExporter

memory_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
MemoryLogExporter

tracer_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
TracerProvider

logger_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
LoggerProvider

meter_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
MeterProvider

telemetry()

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
Telemetry

instrumentation_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
InstrumentationScope

batching_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
BatchingSpanProcessor

batching_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
BatchingMetricProcessor

batching_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
BatchingLogProcessor

console_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
ConsoleSpanExporter

console_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
ConsoleMetricExporter

console_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
ConsoleLogExporter

always_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
AlwaysOnExemplarFilter

trace_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
TraceBasedExemplarFilter

propagation_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
PropagationContext

array_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
ArrayCarrier

superglobal_carrier()

Create a SuperglobalCarrier.

superglobal_carrier() : SuperglobalCarrier

Read-only carrier that extracts context from PHP superglobals ($_SERVER, $_GET, $_POST, $_COOKIE).

Return values
SuperglobalCarrier

w3c_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
W3CTraceContext

w3c_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
W3CBaggage

composite_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

Return values
CompositePropagator

        
On this page

Search results