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
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 $attributes = [] ]) : Resource
Parameters
- $attributes : array<string, array<string|int, bool|float|int|string>|bool|float|int|string>|Attributes = []
-
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 $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
GenericEventspan_link()
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
SpanLinkspan_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
SpanLimitslog_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
LogRecordLimitsmetric_limits()
Create MetricLimits configuration.
metric_limits([int $cardinalityLimit = 2000 ]) : MetricLimits
Parameters
- $cardinalityLimit : int = 2000
-
Maximum number of unique attribute combinations per instrument
Return values
MetricLimitsvoid_span_processor()
Create a VoidSpanProcessor.
void_span_processor() : VoidSpanProcessor
No-op span processor that discards all data.
Return values
VoidSpanProcessorvoid_metric_processor()
Create a VoidMetricProcessor.
void_metric_processor() : VoidMetricProcessor
No-op metric processor that discards all data.
Return values
VoidMetricProcessorvoid_log_processor()
Create a VoidLogProcessor.
void_log_processor() : VoidLogProcessor
No-op log processor that discards all data.
Return values
VoidLogProcessorvoid_exporter()
Create a VoidExporter.
void_exporter() : VoidExporter
No-op unified exporter that discards logs, metrics, and spans.
Return values
VoidExportermemory_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
MemoryExportermemory_span_processor()
Create a MemorySpanProcessor.
memory_span_processor(Exporter $exporter[, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : MemorySpanProcessor
Parameters
- $exporter : Exporter
-
The exporter to send spans to
- $errorHandler : ErrorHandler = new ErrorLogHandler()
-
Handler for Throwables raised by the exporter
Return values
MemorySpanProcessormemory_metric_processor()
Create a MemoryMetricProcessor.
memory_metric_processor(Exporter $exporter[, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : MemoryMetricProcessor
Parameters
- $exporter : Exporter
-
The exporter to send metrics to
- $errorHandler : ErrorHandler = new ErrorLogHandler()
-
Handler for Throwables raised by the exporter
Return values
MemoryMetricProcessormemory_log_processor()
Create a MemoryLogProcessor.
memory_log_processor(Exporter $exporter[, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : MemoryLogProcessor
Parameters
- $exporter : Exporter
-
The exporter to send logs to
- $errorHandler : ErrorHandler = new ErrorLogHandler()
-
Handler for Throwables raised by the exporter
Return values
MemoryLogProcessortracer_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
TracerProviderlogger_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
LoggerProvidermeter_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
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 ][, 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
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(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
BatchingSpanProcessorpass_through_span_processor()
Create a PassThroughSpanProcessor.
pass_through_span_processor(Exporter $exporter[, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : PassThroughSpanProcessor
Parameters
- $exporter : Exporter
-
The exporter to send spans to
- $errorHandler : ErrorHandler = new ErrorLogHandler()
-
Handler for Throwables raised by the exporter
Return values
PassThroughSpanProcessorbatching_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
BatchingMetricProcessorpass_through_metric_processor()
Create a PassThroughMetricProcessor.
pass_through_metric_processor(Exporter $exporter[, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : PassThroughMetricProcessor
Parameters
- $exporter : Exporter
-
The exporter to send metrics to
- $errorHandler : ErrorHandler = new ErrorLogHandler()
-
Handler for Throwables raised by the exporter
Return values
PassThroughMetricProcessorbatching_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
BatchingLogProcessorpass_through_log_processor()
Create a PassThroughLogProcessor.
pass_through_log_processor(Exporter $exporter[, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : PassThroughLogProcessor
Parameters
- $exporter : Exporter
-
The exporter to send logs to
- $errorHandler : ErrorHandler = new ErrorLogHandler()
-
Handler for Throwables raised by the exporter
Return values
PassThroughLogProcessorseverity_filtering_log_processor()
Create a SeverityFilteringLogProcessor.
severity_filtering_log_processor(LogProcessor $processor[, Severity $minimumSeverity = Severity::INFO ]) : SeverityFilteringLogProcessor
Parameters
- $processor : LogProcessor
-
The processor to wrap
- $minimumSeverity : Severity = Severity::INFO
-
Minimum severity level (default: INFO)
Return values
SeverityFilteringLogProcessorconsole_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
ConsoleExporterconsole_span_options()
Create ConsoleSpanOptions with all display options enabled (default behavior).
console_span_options() : ConsoleSpanOptions
Return values
ConsoleSpanOptionsconsole_span_options_minimal()
Create ConsoleSpanOptions with minimal display (legacy compact format).
console_span_options_minimal() : ConsoleSpanOptions
Return values
ConsoleSpanOptionsconsole_log_options()
Create ConsoleLogOptions with all display options enabled (default behavior).
console_log_options() : ConsoleLogOptions
Return values
ConsoleLogOptionsconsole_log_options_minimal()
Create ConsoleLogOptions with minimal display (legacy compact format).
console_log_options_minimal() : ConsoleLogOptions
Return values
ConsoleLogOptionsconsole_metric_options()
Create ConsoleMetricOptions with all display options enabled (default behavior).
console_metric_options() : ConsoleMetricOptions
Return values
ConsoleMetricOptionsconsole_metric_options_minimal()
Create ConsoleMetricOptions with minimal display (legacy compact format).
console_metric_options_minimal() : ConsoleMetricOptions
Return values
ConsoleMetricOptionsalways_on_exemplar_filter()
Create an AlwaysOnExemplarFilter.
always_on_exemplar_filter() : AlwaysOnExemplarFilter
Return values
AlwaysOnExemplarFilteralways_off_exemplar_filter()
Create an AlwaysOffExemplarFilter.
always_off_exemplar_filter() : AlwaysOffExemplarFilter
Return values
AlwaysOffExemplarFiltertrace_based_exemplar_filter()
Create a TraceBasedExemplarFilter.
trace_based_exemplar_filter() : TraceBasedExemplarFilter
Return values
TraceBasedExemplarFilterpropagation_context()
Create a PropagationContext.
propagation_context([null|SpanContext $spanContext = null ][, null|Baggage $baggage = null ]) : PropagationContext
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
Parameters
- $data : array<string, string> = []
-
Initial carrier data
Return values
ArrayCarriersuperglobal_carrier()
Create a SuperglobalCarrier.
superglobal_carrier() : SuperglobalCarrier
Return values
SuperglobalCarrierw3c_trace_context()
Create a W3CTraceContext propagator.
w3c_trace_context() : W3CTraceContext
Return values
W3CTraceContextw3c_baggage()
Create a W3CBaggage propagator.
w3c_baggage() : W3CBaggage
Return values
W3CBaggagecomposite_propagator()
Create a CompositePropagator.
composite_propagator(Propagator ...$propagators) : CompositePropagator
Parameters
- $propagators : Propagator
-
The propagators to combine
Return values
CompositePropagatorchain_detector()
Create a ChainDetector.
chain_detector(ResourceDetector ...$detectors) : ChainDetector
Parameters
- $detectors : ResourceDetector
-
The detectors to chain
Return values
ChainDetectoros_detector()
Create an OsDetector.
os_detector() : OsDetector
Return values
OsDetectorhost_detector()
Create a HostDetector.
host_detector() : HostDetector
Return values
HostDetectorprocess_detector()
Create a ProcessDetector.
process_detector() : ProcessDetector
Return values
ProcessDetectorenvironment_detector()
Create an EnvironmentDetector.
environment_detector() : EnvironmentDetector
Return values
EnvironmentDetectorcomposer_detector()
Create a ComposerDetector.
composer_detector() : ComposerDetector
Return values
ComposerDetectormanual_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
ManualDetectorcaching_detector()
Create a CachingDetector.
caching_detector(ResourceDetector $detector[, null|string $cachePath = null ]) : CachingDetector
Parameters
- $detector : ResourceDetector
-
The detector to wrap
- $cachePath : null|string = null
-
Cache file path (default: sys_get_temp_dir()/flow_telemetry_resource.cache)
Return values
CachingDetectorresource_detector()
Create a resource detector chain.
resource_detector([array<string|int, ResourceDetector> $detectors = [] ]) : ChainDetector
Parameters
- $detectors : array<string|int, ResourceDetector> = []
-
Optional custom detectors (empty = use defaults)
Return values
ChainDetectorerror_log_handler()
Create the default ErrorLogHandler. Writes via PHP's error_log().
error_log_handler([ErrorLogMessageType $messageType = ErrorLogMessageType::OperatingSystem ][, bool $expandNewlines = false ][, string $messagePrefix = '[flow-telemetry]' ]) : ErrorLogHandler
Parameters
- $messageType : ErrorLogMessageType = ErrorLogMessageType::OperatingSystem
- $expandNewlines : bool = false
- $messagePrefix : string = '[flow-telemetry]'
Return values
ErrorLogHandlerstream_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
StreamHandlersyslog_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
SyslogHandlerudp_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
UdpSyslogHandlercomposite_error_handler()
Fan errors out to multiple handlers.
composite_error_handler(ErrorHandler ...$handlers) : CompositeErrorHandler
Parameters
- $handlers : ErrorHandler
Return values
CompositeErrorHandlernull_error_handler()
Discard every error. Use only in tests or for explicit silence.
null_error_handler() : NullErrorHandler