Production-ready guide covering opentelemetry collector pipeline architecture with implementation patterns, code examples, and anti-patterns for enterprise engineering teams.
The OpenTelemetry Collector (OTel Collector) is a high-performance, extensible component that ingests telemetry data—traces, metrics, and logs—from distributed systems, processes it, and forwards it to one or more backends. It matters when you need to standardize telemetry collection across microservices, reduce backend load through preprocessing, deduplicate or enrich data at scale, or unify instrumentation from heterogeneous sources. The Collector’s pipeline architecture enables this by defining a clear, composable flow from ingestion to export, where each stage is configurable, observable, and independently testable.
The pipeline begins with receivers, which are components that listen for incoming telemetry. These can be configured to support protocols like gRPC, HTTP, OTLP, OpenTelemetry Protocol (OTLP), Prometheus, Jaeger, Zipkin, and more. Receivers are defined in the Collector’s config.yaml file under the receivers section.
receivers:
otlp:
protocols:
grpc:
endpoint: "0.0.0.0:4317"
http:
endpoint: "0.0.0.0:4318"
prometheus:
config:
scrape_configs:
- job_name: "my-app"
scrape_interval: "30s"
static_configs:
- targets: ["localhost:8080/metrics"]
jaeger:
endpoint: "0.0.0.0:14250"
zipkin:
endpoint: "0.0.0.0:9411"
Each receiver starts a listener and processes incoming data into OpenTelemetry’s Span, Metric, or LogData objects. The OTLP receiver, for example, supports both gRPC and HTTP. When a service sends data via gRPC to 0.0.0.0:4317, it must use the opentelemetry.proto.collector traces.v1.TraceService service. The request body is a ExportTraceServiceRequest with a list of ResourceSpans and InstrumentationLibrarySpans.
If a receiver fails to parse incoming data, it emits logs with a receiver.name field and a error key. For instance, a malformed OTLP request results in:
{
"level": "error",
"ts": 1640995200,
"msg": "Failed to unmarshal OTLP request",
"receiver": "otlp",
"error": "json: cannot unmarshal object into Go struct",
"request_id": "a1b2c3d4"
}
Receiver-specific configuration options are critical. The prometheus receiver’s scrape_interval must be a valid Go duration (30s, 5m, 1h30m). If scrape_interval is set to 30m but the prometheus job’s interval is 5m, the Collector uses the scrape_interval from the config, and the interval field is ignored—common source of confusion.
After ingestion, data flows through processors, which transform and enrich telemetry in memory before export. Processors are defined in the processors section and applied in sequence.
processors:
batch:
send_batch_max_size: 1000
timeout: "10s"
send_batch_max_size: 5000
memory_limiter:
check_interval: "1s"
limit_mib: 100
spike_limit_mib: 150
transform:
traces:
rules:
- from: "attributes.service.name"
to: "service.name"
type: "string"
- from: "attributes.http.status_code"
to: "http.status_code"
type: "int"
metrics:
rules:
- from: "labels.job"
to: "job"
type: "string"
- from: "sum"
to: "value"
type: "float"
The batch processor collects data over time or until a size threshold is reached. It buffers data in memory and sends batches to the next stage. The timeout is the maximum time to wait before sending a batch, even if it’s not full.
The memory_limiter processor monitors memory usage and can pause or drop incoming data when memory exceeds limit_mib. If the spike limit is exceeded, it triggers a spike event, which can be logged or sent to a metrics backend.
The transform processor applies rules to both traces and metrics. It uses a declarative YAML structure where each rule maps from a source path to a target path. The from path supports dot notation (e.g., attributes.service.name), and the type field ensures correct type conversion. A string rule will convert a float value to string, while an int rule can round or truncate floats.
A common failure occurs when transform rules are applied to traces but the input is missing expected fields. If attributes.service.name is missing, the transform processor generates a warning:
{
"level": "warning",
"ts": 1640995205,
"msg": "Transform rule failed: missing field",
"processor": "transform",
"rule": "from: attributes.service.name, to: service.name",
"field": "attributes.service.name",
"expected_type": "string"
}
Processors can be combined. For example, batch and memory_limiter can be nested:
processors:
batch:
send_batch_max_size: 1000
timeout: "10s"
memory_limiter:
check_interval: "1s"
limit_mib: 100
spike_limit_mib: 150
processors:
- batch
Here, the memory_limiter wraps the batch processor, so memory pressure applies to the entire batch processing step.
The final stage of the pipeline is exporters, which send processed data to one or more backends. Exporters are defined in the exporters section and can be chained.
exporters:
otlp:
endpoint: "collector-backend:4317"
timeout: "10s"
compression: "gzip"
headers:
"Authorization": "Bearer abc123"
"X-Source": "otel-collector"
prometheus:
endpoint: "http://prometheus:9090"
namespace: "myapp"
metric_prefix: "myapp_"
logging:
level: "info"
output: "stdout"
jaeger:
endpoint: "http://jaeger:14250"
protocol: "grpc"
timeout: "5s"
Each exporter supports a common interface: ExportTrace, ExportMetric, and ExportLog methods. The otlp exporter uses the OTLP protocol over gRPC or HTTP. For gRPC, it sends ExportTraceServiceRequest, ExportMetricsServiceRequest, and ExportLogsServiceRequest messages.
The compression field in otlp exporter supports gzip, snappy, and none. When set to gzip, the Collector compresses the entire request body before sending. The headers field is a map of key-value pairs, with string keys and values.
The logging exporter writes data to stdout (or a file) in JSON format. Each exported item is a JSON object with a level field, and the output field determines the sink. For stdout, it writes each log line with a timestamp.
Exporters can be grouped and used in a multi-exporter pipeline:
service:
pipelines:
traces:
receivers: [otlp, jaeger]
processors: [batch, memory_limiter]
exporters: [otlp, logging, prometheus]
metrics:
receivers: [prometheus, otlp]
processors: [batch]
exporters: [otlp, jaeger]
In this configuration, traces are received from both OTLP and Jaeger, batched and memory-limited, then exported to OTLP, logging, and Prometheus. Metrics are collected from Prometheus and OTLP, batched, and sent to OTLP and Jaeger.
The collector handles failures at each stage. If an exporter fails to send data, it logs the error and may retry.
For example, the otlp exporter sends a request and receives a Status response from the backend. If the response has a code field of 1, it indicates a UNAVAILABLE state. The Collector logs:
{
"level": "error",
"ts": 1640995210,
"msg": "Failed to export traces to OTLP endpoint",
"exporter": "otlp",
"endpoint": "collector-backend:4317",
"error": "rpc error: code = Unavailable desc = all SubConns are in TransientFailure",
"status_code": 1,
"status_message": "Service unavailable"
}
The collector can be configured with retry logic:
exporters:
otlp:
endpoint: "collector-backend:4317"
retry_on_failure:
enabled: true
initial_interval: "1s"
max_interval: "30s"
max_elapsed_time: "5m"
exponential_backoff: true
Here, on failure, the exporter retries with increasing intervals, up to max_interval, and stops after max_elapsed_time.
A common failure mode is memory exhaustion during processing. If the memory_limiter processor’s limit_mib is exceeded, it can drop incoming data. If spike_limit_mib is exceeded, it triggers a spike event and logs:
{
"level": "warning",
"ts": 1640995215,
"msg": "Memory spike detected",
"processor": "memory_limiter",
"current_memory_mib": 160,
"spike_limit_mib": 150,
"peak_memory_mib": 180
}
The collector can be monitored via its own metrics endpoint (/metrics), exposed via a built-in HTTP server.
curl localhost:8888/metrics
Key metrics include:
otelcol_receiver_received_spans_total – count of spans receivedotelcol_processor_batch_dropped_spans_total – spans dropped due to batch limitsotelcol_exporter_sent_traces_total – traces successfully sentotelcol_processor_memory_limiter_memory_usage_bytes – current memory usageThe Collector validates configuration at startup. Invalid YAML results in a startup failure:
{
"error": "failed to load configuration",
"details": [
"invalid key 'send_batch_max_size' in processor 'batch': expected integer, got float",
"unknown receiver 'zipkinx': expected 'zipkin'"
],
"config_file": "/etc/otel-collector.yaml"
}
The --config flag specifies the configuration file:
./otelcol --config /etc/otel-collector.yaml --log-level debug
The --log-level flag sets the logging level: debug, info, warn, error. Debug logs include full trace spans and processor state.
A subtle but critical point: processors are applied in order, and each processor modifies the data in place. If a transform processor renames an attribute, the next processor sees the updated structure. A batch processor that batches after transform will batch the transformed data, not the raw input.
Another sharp edge: the batch processor’s timeout is not a hard deadline. It starts a timer when the first item arrives, and sends the batch when the timer expires or the size threshold is met. If a new item arrives just before the timer expires, the batch is sent immediately. But if the timer expires and no new item arrives, the batch is sent even if it’s not full.
Finally, the Collector can be run as a daemon with systemctl, or in a container with docker run, and is designed to be self-contained. It ships with built-in health checks, metrics, and tracing, making it a robust, production-ready component in any observability stack.
This page was rewritten on 18 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.
We use cookies for analytics (Google Analytics) and advertising (Google AdSense) to improve your experience and support free content. Privacy Policy