DSL References
DSL stands for Domain Specific Language. In Flow, the DSL is a set of small functions that wrap object construction so pipelines read top-to-bottom. See the examples for usage in context.
TYPE
/**
* Create a Baggage.
*
* @param array<string, string> $entries Initial key-value entries
*/
baggage(array $entries) : Baggage /**
* Create a Context.
*
* If no TraceId is provided, generates a new one.
* If no Baggage is provided, creates an empty one.
*
* @param null|TraceId $traceId Optional TraceId to use
* @param null|Baggage $baggage Optional Baggage to use
*/
context(?TraceId $traceId, ?Baggage $baggage) : Context /**
* Create an InstrumentationScope.
*
* @param string $name The instrumentation scope name
* @param string $version The instrumentation scope version
* @param null|string $schemaUrl Optional schema URL
*/
instrumentation_scope(string $name, string $version, ?string $schemaUrl, Attributes $attributes) : InstrumentationScope /**
* Create a PropagationContext.
*
* @param null|SpanContext $spanContext Optional span context
* @param null|Baggage $baggage Optional baggage
*/
propagation_context(?SpanContext $spanContext, ?Baggage $baggage) : PropagationContext /**
* Create a Resource.
*
* @param array<string, array<bool|float|int|string>|bool|float|int|string>|Attributes $attributes Resource attributes
*/
resource(Attributes|array $attributes) : Resource /**
* Create a SpanContext.
*
* @param TraceId $traceId The trace ID
* @param SpanId $spanId The span ID
* @param null|SpanId $parentSpanId Optional parent span ID
*/
span_context(TraceId $traceId, SpanId $spanId, ?SpanId $parentSpanId) : SpanContext /**
* Create a SpanEvent (GenericEvent) with an explicit timestamp.
*
* @param string $name Event name
* @param \DateTimeImmutable $timestamp Event timestamp
* @param array<string, array<bool|float|int|string>|bool|float|int|string>|Attributes $attributes Event attributes
*/
span_event(string $name, DateTimeImmutable $timestamp, Attributes|array $attributes) : GenericEvent /**
* Create a SpanId.
*
* If a hex string is provided, creates a SpanId from it.
* Otherwise, generates a new random SpanId.
*
* @param null|string $hex Optional 16-character hexadecimal string
*
* @throws \InvalidArgumentException if the hex string is invalid
*/
span_id(?string $hex) : SpanId /**
* Create a SpanLink.
*
* @param SpanContext $context The linked span context
* @param array<string, array<bool|float|int|string>|bool|float|int|string>|Attributes $attributes Link attributes
*/
span_link(SpanContext $context, Attributes|array $attributes) : SpanLink /**
* Create a TraceId.
*
* If a hex string is provided, creates a TraceId from it.
* Otherwise, generates a new random TraceId.
*
* @param null|string $hex Optional 32-character hexadecimal string
*
* @throws \InvalidArgumentException if the hex string is invalid
*/
trace_id(?string $hex) : TraceId HELPER
/**
* Create an AlwaysOffExemplarFilter.
*/
always_off_exemplar_filter() : AlwaysOffExemplarFilter /**
* Create an AlwaysOnExemplarFilter.
*/
always_on_exemplar_filter() : AlwaysOnExemplarFilter /**
* Create an ArrayCarrier.
*
* @param array<string, string> $data Initial carrier data
*/
array_carrier(array $data) : ArrayCarrier /**
* Create a BatchingLogProcessor.
*
* @param Exporter $exporter The exporter to send logs to
* @param int $batchSize Number of logs to collect before exporting (default 512)
* @param ErrorHandler $errorHandler Handler for Throwables raised by the exporter
*/
batching_log_processor(Exporter $exporter, int $batchSize, ErrorHandler $errorHandler) : BatchingLogProcessor /**
* Create a BatchingMetricProcessor.
*
* @param Exporter $exporter The exporter to send metrics to
* @param int $batchSize Number of metrics to collect before exporting (default 512)
* @param ErrorHandler $errorHandler Handler for Throwables raised by the exporter
*/
batching_metric_processor(Exporter $exporter, int $batchSize, ErrorHandler $errorHandler) : BatchingMetricProcessor /**
* Create a BatchingSpanProcessor.
*
* @param Exporter $exporter The exporter to send spans to
* @param int $batchSize Number of spans to collect before exporting (default 512)
* @param ErrorHandler $errorHandler Handler for Throwables raised by the exporter
*/
batching_span_processor(Exporter $exporter, int $batchSize, ErrorHandler $errorHandler) : BatchingSpanProcessor /**
* Create a CachingDetector.
*
* @param ResourceDetector $detector The detector to wrap
* @param null|string $cachePath Cache file path (default: sys_get_temp_dir()/flow_telemetry_resource.cache)
*/
caching_detector(ResourceDetector $detector, ?string $cachePath) : CachingDetector /**
* Create a ChainDetector.
*
* @param ResourceDetector ...$detectors The detectors to chain
*/
chain_detector(ResourceDetector $detectors) : ChainDetector /**
* Create a ComposerDetector.
*/
composer_detector() : ComposerDetector /**
* Fan errors out to multiple handlers.
*/
composite_error_handler(ErrorHandler $handlers) : CompositeErrorHandler /**
* Create a CompositePropagator.
*
* @param Propagator ...$propagators The propagators to combine
*/
composite_propagator(Propagator $propagators) : CompositePropagator /**
* Create a unified ConsoleExporter for logs, metrics, and spans.
*
* Outputs telemetry to the console with ASCII table formatting and optional ANSI colors.
*
* @param bool $colors Whether to use ANSI colors (default: true)
* @param null|int $maxLogBodyLength Maximum length for log body+attributes column (null = no limit)
* @param ConsoleLogOptions $logOptions Display options for log records
* @param ConsoleMetricOptions $metricOptions Display options for metrics
* @param ConsoleSpanOptions $spanOptions Display options for spans
*/
console_exporter(bool $colors, ?int $maxLogBodyLength, ConsoleLogOptions $logOptions, ConsoleMetricOptions $metricOptions, ConsoleSpanOptions $spanOptions) : ConsoleExporter /**
* Create ConsoleLogOptions with all display options enabled (default behavior).
*/
console_log_options() : ConsoleLogOptions /**
* Create ConsoleLogOptions with minimal display (legacy compact format).
*/
console_log_options_minimal() : ConsoleLogOptions /**
* Create ConsoleMetricOptions with all display options enabled (default behavior).
*/
console_metric_options() : ConsoleMetricOptions /**
* Create ConsoleMetricOptions with minimal display (legacy compact format).
*/
console_metric_options_minimal() : ConsoleMetricOptions /**
* Create ConsoleSpanOptions with all display options enabled (default behavior).
*/
console_span_options() : ConsoleSpanOptions /**
* Create ConsoleSpanOptions with minimal display (legacy compact format).
*/
console_span_options_minimal() : ConsoleSpanOptions /**
* Create an EnvironmentDetector.
*/
environment_detector() : EnvironmentDetector /**
* Create the default ErrorLogHandler. Writes via PHP's error_log().
*/
error_log_handler(ErrorLogMessageType $messageType, bool $expandNewlines, string $messagePrefix) : ErrorLogHandler /**
* Create a HostDetector.
*/
host_detector() : HostDetector /**
* Create a LoggerProvider.
*
* @param LogProcessor $processor The processor for logs
* @param ClockInterface $clock The clock for timestamps
* @param ContextStorage $contextStorage Storage for span correlation
* @param LogRecordLimits $limits Limits for log record attributes
* @param ErrorHandler $errorHandler Handler for runtime Throwables raised by the processor
*/
logger_provider(LogProcessor $processor, ClockInterface $clock, ContextStorage $contextStorage, LogRecordLimits $limits, ErrorHandler $errorHandler) : LoggerProvider /**
* Create LogRecordLimits configuration.
*
* @param int $attributeCountLimit Maximum number of attributes per log record
* @param null|int $attributeValueLengthLimit Maximum length for string attribute values (null = unlimited)
*/
log_record_limits(int $attributeCountLimit, ?int $attributeValueLengthLimit) : LogRecordLimits /**
* Create a ManualDetector.
*
* @param array<string, array<bool|float|int|string>|bool|float|int|string> $attributes Resource attributes
*/
manual_detector(array $attributes) : ManualDetector /**
* Create a 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.
*
* @param null|Context $context Optional initial context
*/
memory_context_storage(?Context $context) : MemoryContextStorage /**
* Create a MemoryExporter.
*
* Unified exporter that stores logs, metrics, and spans in memory for direct access.
* Useful for testing and inspection without serialization.
*/
memory_exporter() : MemoryExporter /**
* Create a MemoryLogProcessor.
*
* @param Exporter $exporter The exporter to send logs to
* @param ErrorHandler $errorHandler Handler for Throwables raised by the exporter
*/
memory_log_processor(Exporter $exporter, ErrorHandler $errorHandler) : MemoryLogProcessor /**
* Create a MemoryMetricProcessor.
*
* @param Exporter $exporter The exporter to send metrics to
* @param ErrorHandler $errorHandler Handler for Throwables raised by the exporter
*/
memory_metric_processor(Exporter $exporter, ErrorHandler $errorHandler) : MemoryMetricProcessor /**
* Create a MemorySpanProcessor.
*
* @param Exporter $exporter The exporter to send spans to
* @param ErrorHandler $errorHandler Handler for Throwables raised by the exporter
*/
memory_span_processor(Exporter $exporter, ErrorHandler $errorHandler) : MemorySpanProcessor /**
* Create a MeterProvider.
*
* @param MetricProcessor $processor The processor for metrics
* @param ClockInterface $clock The clock for timestamps
* @param AggregationTemporality $temporality Aggregation temporality for metrics
* @param ExemplarFilter $exemplarFilter Filter for exemplar sampling (default: TraceBasedExemplarFilter)
* @param MetricLimits $limits Cardinality limits for metric instruments
* @param ErrorHandler $errorHandler Handler for runtime Throwables raised by the processor
*/
meter_provider(MetricProcessor $processor, ClockInterface $clock, AggregationTemporality $temporality, ExemplarFilter $exemplarFilter, MetricLimits $limits, ErrorHandler $errorHandler) : MeterProvider /**
* Create MetricLimits configuration.
*
* @param int $cardinalityLimit Maximum number of unique attribute combinations per instrument
*/
metric_limits(int $cardinalityLimit) : MetricLimits /**
* Discard every error. Use only in tests or for explicit silence.
*/
null_error_handler() : NullErrorHandler /**
* Create an OsDetector.
*/
os_detector() : OsDetector /**
* Create a PassThroughLogProcessor.
*
* @param Exporter $exporter The exporter to send logs to
* @param ErrorHandler $errorHandler Handler for Throwables raised by the exporter
*/
pass_through_log_processor(Exporter $exporter, ErrorHandler $errorHandler) : PassThroughLogProcessor /**
* Create a PassThroughMetricProcessor.
*
* @param Exporter $exporter The exporter to send metrics to
* @param ErrorHandler $errorHandler Handler for Throwables raised by the exporter
*/
pass_through_metric_processor(Exporter $exporter, ErrorHandler $errorHandler) : PassThroughMetricProcessor /**
* Create a PassThroughSpanProcessor.
*
* @param Exporter $exporter The exporter to send spans to
* @param ErrorHandler $errorHandler Handler for Throwables raised by the exporter
*/
pass_through_span_processor(Exporter $exporter, ErrorHandler $errorHandler) : PassThroughSpanProcessor /**
* Create a ProcessDetector.
*/
process_detector() : ProcessDetector /**
* Create a resource detector chain.
*
* @param array<ResourceDetector> $detectors Optional custom detectors (empty = use defaults)
*/
resource_detector(array $detectors) : ChainDetector /**
* Create a SeverityFilteringLogProcessor.
*
* @param LogProcessor $processor The processor to wrap
* @param Severity $minimumSeverity Minimum severity level (default: INFO)
*/
severity_filtering_log_processor(LogProcessor $processor, Severity $minimumSeverity) : SeverityFilteringLogProcessor /**
* Create SpanLimits configuration.
*
* @param int $attributeCountLimit Maximum number of attributes per span
* @param int $eventCountLimit Maximum number of events per span
* @param int $linkCountLimit Maximum number of links per span
* @param int $attributePerEventCountLimit Maximum number of attributes per event
* @param int $attributePerLinkCountLimit Maximum number of attributes per link
* @param null|int $attributeValueLengthLimit Maximum length for string attribute values (null = unlimited)
*/
span_limits(int $attributeCountLimit, int $eventCountLimit, int $linkCountLimit, int $attributePerEventCountLimit, int $attributePerLinkCountLimit, ?int $attributeValueLengthLimit) : SpanLimits /**
* Create a StreamHandler. Appends formatted Throwables (one per line) to a file
* path or php:// stream wrapper.
*/
stream_error_handler(string $destination, int $filePermissions, bool $createDirectories, string $messagePrefix) : StreamHandler /**
* Create a SuperglobalCarrier.
*/
superglobal_carrier() : SuperglobalCarrier /**
* Create a SyslogHandler. Writes via openlog/syslog/closelog.
*/
syslog_error_handler(string $ident, SyslogFacility $facility, int $logOpts, SyslogSeverity $severity) : SyslogHandler /**
* Create a new Telemetry instance with the given providers.
*
* If providers are not specified, void providers (no-op) are used.
*
* @param \Flow\Telemetry\Resource $resource The resource describing the entity producing telemetry
* @param null|TracerProvider $tracerProvider The tracer provider (null for void/disabled)
* @param null|MeterProvider $meterProvider The meter provider (null for void/disabled)
* @param null|LoggerProvider $loggerProvider The logger provider (null for void/disabled)
* @param ErrorHandler $errorHandler Handler propagated to default void providers when explicit ones are not supplied
*/
telemetry(Resource $resource, ?TracerProvider $tracerProvider, ?MeterProvider $meterProvider, ?LoggerProvider $loggerProvider, ErrorHandler $errorHandler) : Telemetry /**
* Create a TracerProvider.
*
* @param SpanProcessor $processor The processor for spans
* @param ClockInterface $clock The clock for timestamps
* @param ContextStorage $contextStorage Storage for context propagation
* @param Sampler $sampler Sampling strategy for spans
* @param SpanLimits $limits Limits for span attributes, events, and links
* @param ErrorHandler $errorHandler Handler for runtime Throwables raised by the processor
*/
tracer_provider(SpanProcessor $processor, ClockInterface $clock, ContextStorage $contextStorage, Sampler $sampler, SpanLimits $limits, ErrorHandler $errorHandler) : TracerProvider /**
* Create a TraceBasedExemplarFilter.
*/
trace_based_exemplar_filter() : TraceBasedExemplarFilter /**
* Create a UdpSyslogHandler. Sends RFC 5424-style syslog frames over UDP.
*/
udp_syslog_error_handler(string $host, int $port, string $ident, SyslogFacility $facility, SyslogSeverity $severity) : UdpSyslogHandler /**
* Create a VoidExporter.
*
* No-op unified exporter that discards logs, metrics, and spans.
*/
void_exporter() : VoidExporter /**
* Create a VoidLogProcessor.
*
* No-op log processor that discards all data.
*/
void_log_processor() : VoidLogProcessor /**
* Create a VoidMetricProcessor.
*
* No-op metric processor that discards all data.
*/
void_metric_processor() : VoidMetricProcessor /**
* Create a VoidSpanProcessor.
*
* No-op span processor that discards all data.
*/
void_span_processor() : VoidSpanProcessor /**
* Create a W3CBaggage propagator.
*/
w3c_baggage() : W3CBaggage /**
* Create a W3CTraceContext propagator.
*/
w3c_trace_context() : W3CTraceContext