Flow PHP

functions.php

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 $attributes = [] ]) : Resource
Parameters
$attributes : array<string, array<string|int, bool|float|int|string>|bool|float|int|string>|Attributes = []

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 $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>|Attributes = []

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 $attributes = [] ]) : SpanLink
Parameters
$context : SpanContext

The linked span context

$attributes : array<string, array<string|int, bool|float|int|string>|bool|float|int|string>|Attributes = []

Link attributes

Return values
SpanLink

span_limits()

Create SpanLimits configuration.

span_limits([int $attributeCountLimit = 128 ][, int $eventCountLimit = 128 ][, int $linkCountLimit = 128 ][, int $attributePerEventCountLimit = 128 ][, int $attributePerLinkCountLimit = 128 ][, null|int $attributeValueLengthLimit = null ]) : SpanLimits
Parameters
$attributeCountLimit : int = 128

Maximum number of attributes per span

$eventCountLimit : int = 128

Maximum number of events per span

$linkCountLimit : int = 128

Maximum number of links per span

$attributePerEventCountLimit : int = 128

Maximum number of attributes per event

$attributePerLinkCountLimit : int = 128

Maximum number of attributes per link

$attributeValueLengthLimit : null|int = null

Maximum length for string attribute values (null = unlimited)

Return values
SpanLimits

log_record_limits()

Create LogRecordLimits configuration.

log_record_limits([int $attributeCountLimit = 128 ][, null|int $attributeValueLengthLimit = null ]) : LogRecordLimits
Parameters
$attributeCountLimit : int = 128

Maximum number of attributes per log record

$attributeValueLengthLimit : null|int = null

Maximum length for string attribute values (null = unlimited)

Return values
LogRecordLimits

metric_limits()

Create MetricLimits configuration.

metric_limits([int $cardinalityLimit = 2000 ]) : MetricLimits
Parameters
$cardinalityLimit : int = 2000

Maximum number of unique attribute combinations per instrument

Return values
MetricLimits

memory_exporter()

Create a MemoryExporter.

memory_exporter() : MemoryExporter

Unified exporter that stores logs, metrics, and spans in memory for direct access. Useful for testing and inspection without serialization.

Return values
MemoryExporter

tracer_provider()

Create a TracerProvider.

tracer_provider(SpanProcessor $processor, ClockInterface $clock, ContextStorage $contextStorage[, Sampler $sampler = new AlwaysOnSampler() ][, SpanLimits $limits = new SpanLimits() ][, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : TracerProvider
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

$limits : SpanLimits = new SpanLimits()

Limits for span attributes, events, and links

$errorHandler : ErrorHandler = new ErrorLogHandler()

Handler for runtime Throwables raised by the processor

Return values
TracerProvider

logger_provider()

Create a LoggerProvider.

logger_provider(LogProcessor $processor, ClockInterface $clock, ContextStorage $contextStorage[, LogRecordLimits $limits = new LogRecordLimits() ][, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : LoggerProvider
Parameters
$processor : LogProcessor

The processor for logs

$clock : ClockInterface

The clock for timestamps

$contextStorage : ContextStorage

Storage for span correlation

$limits : LogRecordLimits = new LogRecordLimits()

Limits for log record attributes

$errorHandler : ErrorHandler = new ErrorLogHandler()

Handler for runtime Throwables raised by the processor

Return values
LoggerProvider

meter_provider()

Create a MeterProvider.

meter_provider(MetricProcessor $processor, ClockInterface $clock[, AggregationTemporality $temporality = AggregationTemporality::CUMULATIVE ][, ExemplarFilter $exemplarFilter = new TraceBasedExemplarFilter() ][, MetricLimits $limits = new MetricLimits() ][, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : MeterProvider
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)

$limits : MetricLimits = new MetricLimits()

Cardinality limits for metric instruments

$errorHandler : ErrorHandler = new ErrorLogHandler()

Handler for runtime Throwables raised by the processor

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 ][, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : 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)

$errorHandler : ErrorHandler = new ErrorLogHandler()

Handler propagated to default void providers when explicit ones are not supplied

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(Exporter $exporter[, int $batchSize = 512 ][, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : BatchingSpanProcessor
Parameters
$exporter : Exporter

The exporter to send spans to

$batchSize : int = 512

Number of spans to collect before exporting (default 512)

$errorHandler : ErrorHandler = new ErrorLogHandler()

Handler for Throwables raised by the exporter

Return values
BatchingSpanProcessor

batching_metric_processor()

Create a BatchingMetricProcessor.

batching_metric_processor(Exporter $exporter[, int $batchSize = 512 ][, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : BatchingMetricProcessor
Parameters
$exporter : Exporter

The exporter to send metrics to

$batchSize : int = 512

Number of metrics to collect before exporting (default 512)

$errorHandler : ErrorHandler = new ErrorLogHandler()

Handler for Throwables raised by the exporter

Return values
BatchingMetricProcessor

batching_log_processor()

Create a BatchingLogProcessor.

batching_log_processor(Exporter $exporter[, int $batchSize = 512 ][, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : BatchingLogProcessor
Parameters
$exporter : Exporter

The exporter to send logs to

$batchSize : int = 512

Number of logs to collect before exporting (default 512)

$errorHandler : ErrorHandler = new ErrorLogHandler()

Handler for Throwables raised by the exporter

Return values
BatchingLogProcessor

console_exporter()

Create a unified ConsoleExporter for logs, metrics, and spans.

console_exporter([bool $colors = true ][, null|int $maxLogBodyLength = 100 ][, ConsoleLogOptions $logOptions = new ConsoleLogOptions() ][, ConsoleMetricOptions $metricOptions = new ConsoleMetricOptions() ][, ConsoleSpanOptions $spanOptions = new ConsoleSpanOptions() ]) : ConsoleExporter

Outputs telemetry to the console with ASCII table formatting and optional ANSI colors.

Parameters
$colors : bool = true

Whether to use ANSI colors (default: true)

$maxLogBodyLength : null|int = 100

Maximum length for log body+attributes column (null = no limit)

$logOptions : ConsoleLogOptions = new ConsoleLogOptions()

Display options for log records

$metricOptions : ConsoleMetricOptions = new ConsoleMetricOptions()

Display options for metrics

$spanOptions : ConsoleSpanOptions = new ConsoleSpanOptions()

Display options for spans

Return values
ConsoleExporter

array_carrier()

Create an ArrayCarrier.

array_carrier([array<string, string> $data = [] ]) : ArrayCarrier
Parameters
$data : array<string, string> = []

Initial carrier data

Return values
ArrayCarrier

manual_detector()

Create a ManualDetector.

manual_detector(array<string, array<string|int, bool|float|int|string>|bool|float|int|string> $attributes) : ManualDetector
Parameters
$attributes : array<string, array<string|int, bool|float|int|string>|bool|float|int|string>

Resource attributes

Return values
ManualDetector

stream_error_handler()

Create a StreamHandler. Appends formatted Throwables (one per line) to a file path or php:// stream wrapper.

stream_error_handler(string $destination[, int $filePermissions = 0644 ][, bool $createDirectories = true ][, string $messagePrefix = '[flow-telemetry]' ]) : StreamHandler
Parameters
$destination : string
$filePermissions : int = 0644
$createDirectories : bool = true
$messagePrefix : string = '[flow-telemetry]'
Return values
StreamHandler

syslog_error_handler()

Create a SyslogHandler. Writes via openlog/syslog/closelog.

syslog_error_handler([string $ident = 'flow-telemetry' ][, SyslogFacility $facility = SyslogFacility::User ][, int $logOpts = LOG_PID ][, SyslogSeverity $severity = SyslogSeverity::Error ]) : SyslogHandler
Parameters
$ident : string = 'flow-telemetry'
$facility : SyslogFacility = SyslogFacility::User
$logOpts : int = LOG_PID
$severity : SyslogSeverity = SyslogSeverity::Error
Return values
SyslogHandler

udp_syslog_error_handler()

Create a UdpSyslogHandler. Sends RFC 5424-style syslog frames over UDP.

udp_syslog_error_handler(string $host[, int $port = 514 ][, string $ident = 'flow-telemetry' ][, SyslogFacility $facility = SyslogFacility::User ][, SyslogSeverity $severity = SyslogSeverity::Error ]) : UdpSyslogHandler
Parameters
$host : string
$port : int = 514
$ident : string = 'flow-telemetry'
$facility : SyslogFacility = SyslogFacility::User
$severity : SyslogSeverity = SyslogSeverity::Error
Return values
UdpSyslogHandler
On this page

Search results