Resource Attribute Handling in OTLP Batches
Yes, the batch processor preserves unique resource attributes for each signal. In the OpenTelemetry (OTel) data model, telemetry is not sent as a flat list of signals; instead, it is structured as a collection of Resource Spans (or Resource Metrics/Logs). Each group of signals sharing the same resource metadata is encapsulated within a ResourceSpans object.
How Persistence is Maintained
When the batch processor aggregates data, it does not strip the resource context. The OTLP exporter transmits a ExportTraceServiceRequest, which contains a repeated field of ResourceSpans. Each ResourceSpans message contains:
- The Resource: A set of attributes identifying the entity producing the telemetry (e.g.,
service.name, host.id).
- The ScopeSpans: A set of spans produced by a specific instrumentation library, which in turn contain the individual spans.
Because the resource attributes are tied to the ResourceSpans wrapper rather than the individual span, the OTLP exporter maintains a 1:N relationship between a resource and its associated signals within a single request. This prevents metadata loss and ensures correct attribution at the backend.
Conditions for Attribute Loss or Merging
The OTLP exporter itself does not merge or drop attributes during transmission. However, attribute loss typically occurs due to the following pipeline configurations:
- Resource Processor Overwrites: If a
resourcedetection or transform processor is configured after the batch processor, it may overwrite or delete specific attributes across all signals in the batch.
- Backend Deduplication: Some backends may merge resources if they share an identical set of attributes, which is intended behavior for storage efficiency.
- Dynamic Resource Changes: If resource attributes are modified at the SDK level while the batch processor is buffering, the signals already in the buffer will retain the attributes they had at the time of creation.
Verification Steps
To verify that resource attributes are persisting correctly through your batching pipeline, you can use the debug exporter (formerly logging exporter) in your collector configuration:
exporters:
debug:
verbosity: detailed
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [debug]
Inspect the output logs for the Resource block. You should see distinct ResourceSpans entries if the batch contains signals from different resources.
Diagnostic Detail Needed: Are you using a custom transform processor between the batch processor and the exporter? This is the most common point where attributes are inadvertently dropped.