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.
Synopsis
Section titled “Synopsis”final class OtlpDecoder
| Source | OtlpDecoder.php |
Methods
Section titled “Methods”| Method | Description |
|---|---|
decodeMetrics(string $body, string $contentType): array<ReceivedMetric> | |
decodeTraces(string $body, string $contentType): array<ReceivedSpan> |
decodeMetrics()
Section titled “decodeMetrics()”public function decodeMetrics(string $body, string $contentType): array<ReceivedMetric>
| Parameter | Type | Description |
|---|---|---|
$body | string | |
$contentType | string |
Returns array``<ReceivedMetric>
decodeTraces()
Section titled “decodeTraces()”public function decodeTraces(string $body, string $contentType): array<ReceivedSpan>
| Parameter | Type | Description |
|---|---|---|
$body | string | |
$contentType | string |
Returns array``<ReceivedSpan>