Skip to content
Search

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<array-key, mixed>|bool|\DateTimeInterface|float|int|string|\Throwable>|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<array-key, mixed>|bool|\DateTimeInterface|float|int|string|\Throwable>|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<array-key, mixed>|bool|\DateTimeInterface|float|int|string|\Throwable>|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

/**
 * Combine matchers so that every one must match (logical AND).
 */
all(Matcher $matchers) : All
/**
 * Create an AlwaysOnSampler. Records and samples every span.
 */
always_on_sampler() : AlwaysOnSampler
/**
 * Combine matchers so that at least one must match (logical OR).
 */
any(Matcher $matchers) : Any
/**
 * Create an ArrayCarrier.
 *
 * @param array<string, string> $data Initial carrier data
 */
array_carrier(array $data) : ArrayCarrier
/**
 * Create an AttributeFilter from a matcher.
 *
 * @param Matcher $matcher the matcher to evaluate against a signal's attributes (compose with all(), any(), not())
 * @param bool $exclude when true (default) a match drops the signal; when false only matching signals are kept
 * @param list<AttributeSource> $sources which attribute sets to inspect (signal, resource and/or scope); the matcher is
 *                                       OR-combined across them, defaulting to the signal's own attributes
 * @param null|string $cacheDir directory for the generated matcher file (defaults to the system temp directory). It is
 *                              `require`d, so it MUST be trusted - not writable by untrusted users. Prefer an
 *                              application-private directory over the shared system temp in multi-tenant environments.
 * @param int $cacheDirPermissions mode applied when the cache directory is created (octal, subject to umask; defaults
 *                                 to 0700 - owner only, since the directory holds `require`d PHP)
 */
attribute_filter(Matcher $matcher, bool $exclude, array $sources, ?string $cacheDir, int $cacheDirPermissions) : AttributeFilter
/**
 * Create an AttributeFilteringLogMiddleware that drops log entries matching the filter.
 *
 * @param AttributeFilter $filter The attribute filter to apply
 */
attribute_filtering_log_middleware(AttributeFilter $filter) : AttributeFilteringLogMiddleware
/**
 * Create an AttributeFilteringMetricProcessor.
 *
 * @param MetricProcessor $processor The processor to wrap
 * @param AttributeFilter $filter The attribute filter to apply
 */
attribute_filtering_metric_processor(MetricProcessor $processor, AttributeFilter $filter) : AttributeFilteringMetricProcessor
/**
 * Create an AttributeFilteringSpanProcessor.
 *
 * @param SpanProcessor $processor The processor to wrap
 * @param AttributeFilter $filter The attribute filter to apply
 */
attribute_filtering_span_processor(SpanProcessor $processor, AttributeFilter $filter) : AttributeFilteringSpanProcessor
/**
 * Create an AttributeMatchingSampler. Drops spans whose start-time attributes match
 * the filter (or keeps ONLY matching spans when the filter's exclude is false), and
 * defers all other spans to the delegate sampler.
 *
 * Only attributes available at span start are visible; attributes added later are not.
 *
 * @param AttributeFilter $filter The attribute filter evaluated against the span's start attributes
 * @param Sampler $delegate Sampler that decides spans which do not match (default: AlwaysOnSampler)
 */
attribute_matching_sampler(AttributeFilter $filter, Sampler $delegate) : AttributeMatchingSampler
/**
 * Create a single attribute-matching rule for an AttributeFilter.
 *
 * @param array<string>|string $path attribute path: a top-level key, or segments descending into nested array values
 * @param MatchMode $mode comparison applied between the value at the path and the expected value
 * @param bool|DateTimeInterface|float|int|string $expected expected value (must be a string for the pattern modes)
 * @param bool $caseSensitive applies to the substring modes only (STARTS_WITH, ENDS_WITH, CONTAINS)
 */
attribute_rule(array|string $path, MatchMode $mode, DateTimeInterface|string|int|float|bool $expected, bool $caseSensitive) : AttributeRule
/**
 * 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 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 ConsoleMetricOptions with all display options enabled (default behavior).
 */
console_metric_options() : ConsoleMetricOptions
/**
 * Create ConsoleSpanOptions with all display options enabled (default behavior).
 */
console_span_options() : ConsoleSpanOptions
/**
 * Create an EnrichingLogMiddleware that merges default attributes into every log
 * entry. Attributes set at the call site win over these defaults.
 *
 * @param array<string, array<array-key, mixed>|bool|\DateTimeInterface|float|int|string|\Throwable>|Attributes $attributes
 */
enriching_log_middleware(Attributes|array $attributes) : EnrichingLogMiddleware
/**
 * Create the default ErrorLogHandler. Writes via PHP's error_log().
 */
error_log_handler(ErrorLogMessageType $messageType, bool $expandNewlines, string $messagePrefix) : ErrorLogHandler
/**
 * 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<array-key, mixed>|bool|\DateTimeInterface|float|int|string|\Throwable> $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
/**
 * Negate a matcher (logical NOT).
 */
not(Matcher $matcher) : Not
/**
 * Discard every error. Use only in tests or for explicit silence.
 */
null_error_handler() : NullErrorHandler
/**
 * Create a ParentBasedSampler. Honors the parent span's sampling decision, falling
 * back to the root sampler for spans without a parent.
 *
 * @param Sampler $root Sampler used for root spans (no parent)
 */
parent_based_sampler(Sampler $root) : ParentBasedSampler
/**
 * 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 PipelineLogProcessor: run each log entry through an ordered chain of
 * middleware, then forward the survivors to a single sink.
 *
 * @param list<LogMiddleware> $middleware run in order; the first to drop an entry short-circuits the rest
 * @param LogSink $sink the terminal processor that exports surviving entries
 */
pipeline_log_processor(array $middleware, LogSink $sink) : PipelineLogProcessor
/**
 * Create a resource detector chain.
 *
 * @param array<ResourceDetector> $detectors Optional custom detectors (empty = use defaults)
 */
resource_detector(array $detectors) : ChainDetector
/**
 * Create a SeverityFilteringLogMiddleware that drops log entries below a minimum severity.
 *
 * @param Severity $minimumSeverity Minimum severity level (default: INFO)
 */
severity_filtering_log_middleware(Severity $minimumSeverity) : SeverityFilteringLogMiddleware
/**
 * 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 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 TraceIdRatioBasedSampler. Samples a deterministic fraction of traces.
 *
 * @param float $ratio Sampling probability between 0.0 and 1.0
 */
trace_id_ratio_based_sampler(float $ratio) : TraceIdRatioBasedSampler
/**
 * 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
Contributors

Built in the open.

Join us on GitHub
scroll back to top