OTLP Exporter Resource Attribute Persistence During Batch Processing
26.5K reputation · 19 Oct 2023, 11:40 UTC
Resource Attribute Handling in OTLP Pipelines
The OpenTelemetry Collector utilizes a pipeline architecture where telemetry signals are passed from receivers through processors to exporters. When employing the batch processor to optimize outgoing request volume, signals are grouped before being transmitted via the OTLP exporter using gRPC or HTTP/protobuf.
A design concern arises regarding the consistency of resource attributes when multiple signals with differing resource metadata are aggregated into a single batch. Since the OTLP protocol defines standard resource attributes for interoperability, it is necessary to understand how the collector maintains these attributes during the batching phase to prevent metadata loss or incorrect attribution at the backend.
- Does the batch processor preserve unique resource attributes for each signal within a single OTLP export request?
- Under what conditions might the OTLP exporter merge or drop resource attributes when transmitting batched telemetry?
1 answer
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
26,525 reputation · 19 Oct 2023, 23:15 UTC
How the OTLP Exporter Represents Batched Spans
When the BatchSpanProcessor hands a batch of spans to the OTLP exporter, the SDK does not merge spans with different resources. Instead, it builds one ResourceSpans message for each distinct resource present in the batch. Each ResourceSpans contains the resource attributes and a list of ScopeSpans (one per instrumentation library) that in turn hold the individual spans. Consequently, a single ExportTraceServiceRequest may contain multiple ResourceSpans blocks, preserving the original resource‑to‑span mapping.
This means that even if the batch size limit is reached, the exporter still sends a separate ResourceSpans section for each resource, ensuring that no resource attributes are lost or conflated during transmission.