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.
HELPER
/**
* Create curl transport options for OTLP.
*/
otlp_curl_options() : CurlTransportOptions /**
* Create an async curl transport for OTLP endpoints.
*
* Creates a CurlTransport that uses curl_multi for non-blocking I/O.
* Requests are queued and executed asynchronously. OTLP/HTTP allows JSON
* or Protobuf encoding; defaults to JSON.
*
* Requires: ext-curl PHP extension
*
* @param string $endpoint OTLP endpoint URL (e.g., 'http://localhost:4318')
* @param JsonSerializer|ProtobufSerializer $serializer Serializer for encoding telemetry data (JSON or Protobuf)
* @param CurlTransportOptions $options Transport configuration options
* @param ?Transport $failover Optional failover transport receiving prior batches when primary fails
*/
otlp_curl_transport(string $endpoint, JsonSerializer|ProtobufSerializer $serializer, CurlTransportOptions $options, ?Transport $failover) : Transport /**
* Create an OTLP exporter that dispatches logs, metrics, and spans through a single transport.
*
* Example usage:
* ```php
* $exporter = otlp_exporter($transport);
* $spanProcessor = batching_span_processor($exporter);
* $metricProcessor = batching_metric_processor($exporter);
* $logProcessor = batching_log_processor($exporter);
* ```
*
* @param Transport $transport The transport for sending telemetry data
* @param ErrorHandler $errorHandler Handler for Throwables raised by the transport
*/
otlp_exporter(Transport $transport, ErrorHandler $errorHandler) : OTLPExporter /**
* Create a gRPC transport for OTLP endpoints.
*
* Creates a GrpcTransport configured to send telemetry data to an OTLP-compatible
* endpoint using gRPC protocol with Protobuf serialization. OTLP/gRPC mandates
* Protobuf, so the serializer is built internally and not configurable.
*
* Requires:
* - ext-grpc PHP extension
* - google/protobuf package
*
* @param string $endpoint gRPC endpoint (e.g., 'localhost:4317')
* @param array<string, string> $headers Additional headers (metadata) to include in requests
* @param bool $insecure Whether to use insecure channel credentials (default true for local dev)
* @param int $timeoutMs Per-call deadline in milliseconds (covers connect + send + receive)
* @param int $shutdownTimeoutMs Wall-clock budget for draining pending calls at shutdown
* @param ?Transport $failover Optional failover transport receiving prior batches when primary fails
*/
otlp_grpc_transport(string $endpoint, array $headers, bool $insecure, int $timeoutMs, int $shutdownTimeoutMs, ?Transport $failover) : Transport /**
* Create a JSON serializer for OTLP.
*
* Returns a JsonSerializer that converts telemetry data to OTLP JSON wire format.
* Use this with CurlTransport for JSON over HTTP.
*
* Example usage:
* ```php
* $serializer = otlp_json_serializer();
* $transport = otlp_curl_transport($endpoint, $serializer);
* ```
*/
otlp_json_serializer() : JsonSerializer /**
* Create a logger provider configured for OTLP export.
*
* @param LogProcessor $processor The processor for handling log records
* @param ClockInterface $clock The clock for timestamps
* @param ContextStorage $contextStorage The context storage for propagating context
*/
otlp_logger_provider(LogProcessor $processor, ClockInterface $clock, ContextStorage $contextStorage) : LoggerProvider /**
* Create a meter provider configured for OTLP export.
*
* @param MetricProcessor $processor The processor for handling metrics
* @param ClockInterface $clock The clock for timestamps
* @param AggregationTemporality $temporality The aggregation temporality for metrics
*/
otlp_meter_provider(MetricProcessor $processor, ClockInterface $clock, AggregationTemporality $temporality) : MeterProvider /**
* Create a Protobuf serializer for OTLP.
*
* Returns a ProtobufSerializer that converts telemetry data to OTLP Protobuf binary format.
* Use this with CurlTransport for Protobuf over HTTP, or with GrpcTransport.
*
* Requires:
* - google/protobuf package
*
* Example usage:
* ```php
* $serializer = otlp_protobuf_serializer();
* $transport = otlp_curl_transport($endpoint, $serializer);
* ```
*/
otlp_protobuf_serializer() : ProtobufSerializer /**
* Create a stream transport for OTLP that writes JSONL to a single destination.
*
* Accepts an absolute file path or a php:// stream wrapper such as
* 'php://stdout', 'php://stderr', 'php://memory', or 'php://temp'. Each
* export() call appends one JSON Line under LOCK_EX so concurrent writers
* interleave at line boundaries. The $filePermissions and $createDirectories
* parameters apply only when the destination is a file path.
*
* Per the OTLP File Exporter spec only JSON encoding is supported.
*/
otlp_stream_transport(string $destination, int $filePermissions, bool $createDirectories) : Transport /**
* Create a tracer provider configured for OTLP export.
*
* @param SpanProcessor $processor The processor for handling spans
* @param ClockInterface $clock The clock for timestamps
* @param Sampler $sampler The sampler for deciding whether to record spans
* @param ContextStorage $contextStorage The context storage for propagating trace context
*/
otlp_tracer_provider(SpanProcessor $processor, ClockInterface $clock, Sampler $sampler, ContextStorage $contextStorage) : TracerProvider