Skip to content

OtlpDecoder

Decodes OTLP ExportTraceServiceRequest/ExportMetricsServiceRequest protobuf (or JSON) payloads — exactly what the OTel PHP OTLP/HTTP exporter sends, per telemetry.otlp.protocol — into plain ReceivedSpan/ ReceivedMetric value objects.

Only the metric shapes TelemetryMiddleware actually emits (gauge, sum, histogram) are decoded; exponential histogram and summary metrics are silently skipped rather than guessed at.

A malformed/hostile payload (bad protobuf bytes, absurdly deep nested attribute values) must never crash the dashboard: every public method here wraps decode failures in MalformedRequestException for the receiver to catch, and attribute flattening is depth-guarded.

final class OtlpDecoder

SourceOtlpDecoder.php
MethodDescription
decodeMetrics(string $body, string $contentType): array<ReceivedMetric>
decodeTraces(string $body, string $contentType): array<ReceivedSpan>

public function decodeMetrics(string $body, string $contentType): array<ReceivedMetric>

ParameterTypeDescription
$bodystring
$contentTypestring

Returns array``<ReceivedMetric>

public function decodeTraces(string $body, string $contentType): array<ReceivedSpan>

ParameterTypeDescription
$bodystring
$contentTypestring

Returns array``<ReceivedSpan>