You instrument three services with the OpenTelemetry SDK over a week, you point them at a backend trace store (Jaeger, Tempo, an APM vendor that speaks OTLP), and you call it done. Three weeks later the network jitter to the backend spikes during a busy hour, the SDK’s in-process exporter starts queueing, the queue fills, span memory pressure grows, and one of the services OOMs in the middle of business hours. The bug isn’t the network. The bug is that you skipped the OpenTelemetry Collector — the thing that’s supposed to absorb that exact failure mode and stop it from bleeding into the application.
What’s happening
The OpenTelemetry Collector is a process that sits between your SDK and your backend. It accepts spans over OTLP (gRPC or HTTP), batches them, retries on transient backend errors, applies sampling rules, and ships to one or more exporters. Without it, each application process is doing its own batching and retries against the backend — which means when the backend is slow, every process pays the same cost. On a managed PaaS, you can run the Collector in two shapes. The sidecar shape puts one Collector node in the environment and every application points at it (OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector.prod-api:4318). The agent shape runs a Collector inside every application container (typically as a process started before the application), and the application talks to it on localhost:4318. They have different failure modes: the sidecar is one node, so if it dies you lose traces from every service until it recovers; the agent is per-process, so if it dies you lose traces from one process. The sidecar is cheaper, simpler, and the obvious starting point. You graduate to agent mode when trace volume per service exceeds what one sidecar can absorb, or when you need per-service sampling rules.
How to verify
Confirm one service is emitting OTLP. From the application container’s shell or exec endpoint:
env | grep -E '^OTEL_'
# Expected:
# OTEL_SERVICE_NAME=api-prod
# OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector.prod-api:4318
# OTEL_TRACES_SAMPLER=parentbased_traceidratio
# OTEL_TRACES_SAMPLER_ARG=0.1
Hit a known endpoint and watch the Collector logs accept the spans:
curl -fsS https://api.example.com/healthz >/dev/null
# Then from the Collector node:
journalctl -u otelcol -n 50 --no-pager | grep -E 'TracesExporter|num_spans'
# expected log line like:
# {"kind": "exporter", "data_type": "traces", "name": "otlp", "num_spans": 14}
If num_spans: 0 and the application is serving traffic, either the SDK isn’t pointed at the Collector (env var typo, wrong port — gRPC is 4317, HTTP is 4318), or the sampler is dropping everything before export. Set OTEL_TRACES_SAMPLER=always_on for a minute to test.
The fix
Sidecar shape (recommended starting point). Add a single Collector node to the PaaS environment. The minimum useful config (/etc/otelcol/config.yaml):
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
processors:
batch:
send_batch_size: 1024
send_batch_max_size: 2048
timeout: 2s
memory_limiter:
check_interval: 1s
limit_percentage: 80
spike_limit_percentage: 25
tail_sampling:
decision_wait: 10s
num_traces: 50000
policies:
- name: errors
type: status_code
status_code: { status_codes: [ERROR] }
- name: slow
type: latency
latency: { threshold_ms: 1000 }
- name: sample-rest
type: probabilistic
probabilistic: { sampling_percentage: 10 }
exporters:
otlp/tempo:
endpoint: tempo.observability:4317
tls:
insecure: true
sending_queue:
enabled: true
num_consumers: 4
queue_size: 10000
retry_on_failure:
enabled: true
initial_interval: 5s
max_interval: 30s
max_elapsed_time: 300s
service:
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, batch, tail_sampling]
exporters: [otlp/tempo]
telemetry:
metrics:
address: 0.0.0.0:8888
Application containers point at the Collector with one set of environment variables:
OTEL_SERVICE_NAME=api-prod
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector.prod-api:4318
OTEL_RESOURCE_ATTRIBUTES=service.namespace=acme,deployment.environment=prod
OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=1.0
Two things matter in the config above. memory_limiter is the difference between “we drop spans for 30 seconds when backend is slow” and “the Collector OOMs and you lose all traces for 5 minutes” — keep it. tail_sampling is what lets you keep every error and slow request while throwing away most of the boring traffic — without it, 100% sampling at any non-trivial scale costs more than the traces are worth.
Agent shape (graduate to this when sidecar is the bottleneck). Bundle the Collector binary into the application’s start sequence, run it as a background process bound to 127.0.0.1:4318, point the SDK there. Each application container’s startup hook:
# /var/www/webroot/start-with-otel.sh
set -euo pipefail
# Install once per container start - cached via template ideally
if [[ ! -x /opt/otelcol/otelcol-contrib ]]; then
mkdir -p /opt/otelcol
curl -sSL "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.105.0/otelcol-contrib_0.105.0_linux_amd64.tar.gz" \
| tar -xz -C /opt/otelcol otelcol-contrib
fi
# Local agent config: receive OTLP, forward to upstream Collector or backend
cat > /opt/otelcol/config.yaml <<'YAML'
receivers:
otlp:
protocols:
http:
endpoint: 127.0.0.1:4318
processors:
batch: { timeout: 2s }
memory_limiter: { check_interval: 1s, limit_percentage: 80 }
exporters:
otlp/upstream:
endpoint: otel-collector.prod-api:4317
tls: { insecure: true }
sending_queue: { enabled: true, queue_size: 5000 }
service:
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlp/upstream]
YAML
/opt/otelcol/otelcol-contrib --config=/opt/otelcol/config.yaml >/var/log/otelcol.log 2>&1 &
# Application points at local agent
export OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318
# Exec the actual app
exec "$@"
Agent shape doubles your container’s resource footprint slightly and adds a process to manage, but it isolates one service’s trace pipeline from another’s. If a downstream service starts emitting 50× the spans of yesterday, the local agent absorbs it without dragging the rest of the environment down.
Two rules. First, never set OTEL_TRACES_SAMPLER=always_on permanently on a production service unless you have done the volume math — at 200 RPS with 20 spans per request, you’re emitting 4000 spans per second per service. That’s a real bill. Use tail sampling at the Collector to keep what matters. Second, alert on the Collector’s own metrics — otelcol_exporter_send_failed_spans and otelcol_processor_dropped_spans — because the Collector failing silently is the same failure mode you were trying to escape.
We stand up OpenTelemetry Collectors on managed PaaS and pick the shape that matches the traffic, as part of environment management on managed PaaS — scope a tracing rollout when you’d rather not own the collector tuning yourself.