/**
* Create curl transport options for OTLP.
*
* Returns a CurlTransportOptions builder for configuring curl transport settings
* using a fluent interface.
*
* Example usage:
* ```php
* $options = otlp_curl_options()
* ->withTimeout(60)
* ->withConnectTimeout(15)
* ->withHeader('Authorization', 'Bearer token')
* ->withCompression()
* ->withSslVerification(verifyPeer: true);
*
* $transport = otlp_curl_transport($endpoint, $serializer, $options);
* ```
*/
otlp_curl_options() : CurlTransportOptions DSL References
DSL stands for Domain Specific Language. In the case of Flow, the DSL is used to define simple functions that can be used to transform data. Most of those functions are initializing a new instance of a class under the hood since Flow is fully object-oriented. Please look at the examples below to get a better understanding of how to use the DSL functions.
HELPER
/**
* Create an async curl transport for OTLP endpoints.
*
* Creates a CurlTransport that uses curl_multi for non-blocking I/O.
* Unlike HttpTransport (PSR-18), this transport queues requests and executes
* them asynchronously. Completed requests are processed on subsequent send()
* calls or on shutdown().
*
* Requires: ext-curl PHP extension
*
* Example usage:
* ```php
* // JSON over HTTP (async) with default options
* $transport = otlp_curl_transport(
* endpoint: 'http://localhost:4318',
* serializer: otlp_json_serializer(),
* );
*
* // Protobuf over HTTP (async) with custom options
* $transport = otlp_curl_transport(
* endpoint: 'http://localhost:4318',
* serializer: otlp_protobuf_serializer(),
* options: otlp_curl_options()
* ->withTimeout(60)
* ->withHeader('Authorization', 'Bearer token')
* ->withCompression(),
* );
* ```
*
* @param string $endpoint OTLP endpoint URL (e.g., 'http://localhost:4318')
* @param Serializer $serializer Serializer for encoding telemetry data (JSON or Protobuf)
* @param CurlTransportOptions $options Transport configuration options
*/
otlp_curl_transport(string $endpoint, Serializer $serializer, CurlTransportOptions $options) : CurlTransport /**
* 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.
*
* Requires:
* - ext-grpc PHP extension
* - google/protobuf package
* - open-telemetry/gen-otlp-protobuf package
*
* Example usage:
* ```php
* $transport = otlp_grpc_transport(
* endpoint: 'localhost:4317',
* serializer: otlp_protobuf_serializer(),
* );
* ```
*
* @param string $endpoint gRPC endpoint (e.g., 'localhost:4317')
* @param ProtobufSerializer $serializer Protobuf serializer for encoding telemetry data
* @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)
*/
otlp_grpc_transport(string $endpoint, ProtobufSerializer $serializer, array $headers, bool $insecure) : GrpcTransport /**
* Create an HTTP transport for OTLP endpoints.
*
* Creates an HttpTransport configured to send telemetry data to an OTLP-compatible
* endpoint using PSR-18 HTTP client. Supports both JSON and Protobuf formats.
*
* Example usage:
* ```php
* // JSON over HTTP
* $transport = otlp_http_transport(
* client: $client,
* requestFactory: $psr17Factory,
* streamFactory: $psr17Factory,
* endpoint: 'http://localhost:4318',
* serializer: otlp_json_serializer(),
* );
*
* // Protobuf over HTTP
* $transport = otlp_http_transport(
* client: $client,
* requestFactory: $psr17Factory,
* streamFactory: $psr17Factory,
* endpoint: 'http://localhost:4318',
* serializer: otlp_protobuf_serializer(),
* );
* ```
*
* @param ClientInterface $client PSR-18 HTTP client
* @param RequestFactoryInterface $requestFactory PSR-17 request factory
* @param StreamFactoryInterface $streamFactory PSR-17 stream factory
* @param string $endpoint OTLP endpoint URL (e.g., 'http://localhost:4318')
* @param Serializer $serializer Serializer for encoding telemetry data (JSON or Protobuf)
* @param array<string, string> $headers Additional headers to include in requests
*/
otlp_http_transport(ClientInterface $client, RequestFactoryInterface $requestFactory, StreamFactoryInterface $streamFactory, string $endpoint, Serializer $serializer, array $headers) : HttpTransport /**
* Create a JSON serializer for OTLP.
*
* Returns a JsonSerializer that converts telemetry data to OTLP JSON wire format.
* Use this with HttpTransport for JSON over HTTP.
*
* Example usage:
* ```php
* $serializer = otlp_json_serializer();
* $transport = otlp_http_transport($client, $reqFactory, $streamFactory, $endpoint, $serializer);
* ```
*/
otlp_json_serializer() : JsonSerializer /**
* Create a logger provider configured for OTLP export.
*
* Example usage:
* ```php
* $processor = batching_log_processor(otlp_log_exporter($transport));
* $provider = otlp_logger_provider($processor, $clock);
* $logger = $provider->logger($resource, 'my-service', '1.0.0');
* ```
*
* @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 an OTLP log exporter.
*
* Example usage:
* ```php
* $exporter = otlp_log_exporter($transport);
* $processor = batching_log_processor($exporter);
* ```
*
* @param Transport $transport The transport for sending log data
*/
otlp_log_exporter(Transport $transport) : OTLPLogExporter /**
* Create a meter provider configured for OTLP export.
*
* Example usage:
* ```php
* $processor = batching_metric_processor(otlp_metric_exporter($transport));
* $provider = otlp_meter_provider($processor, $clock);
* $meter = $provider->meter($resource, 'my-service', '1.0.0');
* ```
*
* @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 an OTLP metric exporter.
*
* Example usage:
* ```php
* $exporter = otlp_metric_exporter($transport);
* $processor = batching_metric_processor($exporter);
* ```
*
* @param Transport $transport The transport for sending metric data
*/
otlp_metric_exporter(Transport $transport) : OTLPMetricExporter /**
* Create a Protobuf serializer for OTLP.
*
* Returns a ProtobufSerializer that converts telemetry data to OTLP Protobuf binary format.
* Use this with HttpTransport for Protobuf over HTTP, or with GrpcTransport.
*
* Requires:
* - google/protobuf package
* - open-telemetry/gen-otlp-protobuf package
*
* Example usage:
* ```php
* $serializer = otlp_protobuf_serializer();
* $transport = otlp_http_transport($client, $reqFactory, $streamFactory, $endpoint, $serializer);
* ```
*/
otlp_protobuf_serializer() : ProtobufSerializer /**
* Create an OTLP span exporter.
*
* Example usage:
* ```php
* $exporter = otlp_span_exporter($transport);
* $processor = batching_span_processor($exporter);
* ```
*
* @param Transport $transport The transport for sending span data
*/
otlp_span_exporter(Transport $transport) : OTLPSpanExporter /**
* Create a tracer provider configured for OTLP export.
*
* Example usage:
* ```php
* $processor = batching_span_processor(otlp_span_exporter($transport));
* $provider = otlp_tracer_provider($processor, $clock);
* $tracer = $provider->tracer($resource, 'my-service', '1.0.0');
* ```
*
* @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