Each service exports its spans straight to the tracing vendor, so the endpoint, the key, and the redaction rules sit in every service’s config. A change of backend is a release of every service. While the vendor’s intake is down, each SDK retries until its timeout and then drops the span, and a header recorded by mistake leaves with it.
What you get
You will end up with a Collector config that receives OTLP, refuses data before it runs out of memory, redacts one attribute, batches, and exports. A check fails a pipeline without that order. This is for a platform team that owns many services.
Short answer
Run the OpenTelemetry Collector with an OTLP receiver, a pipeline that starts with
memory_limiter and batches after it, and one otlp_http exporter to your backend. Point each
service’s OTLP exporter at the Collector instead of the vendor. The backend, redaction, and
sampling then change in one config, and the Collector’s own metrics show every span it
accepted, sent, or still holds in its queue.
You will need
Node 22.15 or later for the sample, a service instrumented with an OpenTelemetry SDK, and a
backend that accepts OTLP. Verified 2026-11-30 against Node 22.23.5 and the core distribution of
the Collector, otelcol 0.166.0, installed from the release tarball the
Linux install page names. The
service uses @opentelemetry/sdk-trace 3.1.1 and @opentelemetry/exporter-trace-otlp-http
0.301.2, whose engines field asks for Node 22.15.
Approaches compared
| Approach | When it fits | What it costs you | When to pick something else |
|---|---|---|---|
| A central Collector gateway | Many services, one place for credentials, sampling, and redaction | One more service to scale, keep available and give enough memory | A handful of services that already share one host |
| A Collector agent per host | You want host attributes and a local buffer next to each workload | A process on every host or pod, each with its own config to roll out | You run serverless functions with no host to put it on |
| Direct OTLP export from the application | Development, tests, or one service with one backend | Each backend change, redaction rule or key rotation is a code change in every service | More than one service, or a backend you expect to change |
| The Datadog Agent | Datadog is your backend and its Agent already runs on each host | Forwards to Datadog, needs an Agent on every sending host, and some Datadog products do not support upstream SDK data | You want to keep the choice of backend in your own config |
Direct export has the fewest parts, and the records below show it failing the export when
the backend refuses connections. A gateway keeps the backend out of every service, at the price of
one more thing that must stay up. An agent adds host.name and a buffer on each host, and
multiplies the configs you roll out. The Datadog Agent is that agent tier with Datadog as the
only destination, enabled with otlp_config.receiver.protocols.http.endpoint in datadog.yaml.
Write the pipeline config
The pipeline order is the whole design. memory_limiter runs first, so it can refuse data before
anything else holds it. The batch processor’s README
asks for batching after the limiter and after any sampling, because batching should follow every
step that drops data.
receivers:
otlp:
protocols:
http:
endpoint: ${env:OTLP_HTTP_ENDPOINT:-127.0.0.1:4318}
processors:
memory_limiter:
check_interval: 1s
limit_mib: 400
spike_limit_mib: 80
transform/redact:
trace_statements:
- delete_key(span.attributes, "http.request.header.authorization")
batch:
timeout: 200ms
exporters:
otlp_http:
endpoint: ${env:BACKEND_ENDPOINT:-http://127.0.0.1:4319}
encoding: json
limit_mib is the hard limit and limit_mib minus spike_limit_mib the soft one, which the
limiter’s README
defines. Over the soft limit it refuses data. The same README also asks for GOMEMLIMIT at 80%
of the Collector’s hard memory limit. The redaction uses the
transform processor
and its delete_key function. encoding: json suits the stand-in backend here, and the
exporter’s default is proto. The exporter is spelled otlp_http in this release.1
The receiver’s fallback address uses 4318, the default port for OTLP over HTTP.2 The rest of
the file exposes the Collector’s own metrics on 127.0.0.1 with a pull reader, as the
internal telemetry page shows,
and lists the three processors in order.
Check the order before you deploy
otelcol validate checks the config without starting the Collector. It does not check the order
of processors. check-config.mjs does, for every pipeline:
node check-config.mjs collector.yaml agent.yaml
collector.yaml traces: [memory_limiter, transform/redact, batch] ok
agent.yaml traces: [memory_limiter, resource_detection, batch] ok
It exits 1 when the limiter is missing, is not first, sets no limit or no check_interval, or
when batch is missing or runs before it. Run it in the same CI job that runs otelcol validate.
Point the service at the Collector
The service changes one value: the URL its OTLP exporter sends to, which moves from the vendor’s intake to the Collector’s receiver.
export async function sendOneSpan(tracesUrl, { timeoutMillis = 3000 } = {}) {
const exporter = new OTLPTraceExporter({ url: tracesUrl, timeoutMillis })
record.sh downloads otelcol 0.166.0, checks its SHA-256 against the one published beside it,
and starts the Collector, a stand-in backend and the service on loopback ports. The service
records one client span that carries an Authorization value on purpose.
Check it worked
Read what the backend received and what the Collector counted:
node show.mjs collector
collector: the service exports to the Collector, which exports to the backend
app export: success
backend received 1 span
GET /v1/orders
resource: service.name=checkout
attributes: http.request.method=GET, url.full=https://api.example.com/v1/orders, http.response.status_code=200
Collector metrics:
otelcol_exporter_queue_capacity{exporter=otlp_http} 1000
otelcol_exporter_queue_size{exporter=otlp_http} 0
otelcol_exporter_sent_spans{exporter=otlp_http} 1
otelcol_receiver_accepted_spans{receiver=otlp,transport=http} 1
otelcol_receiver_refused_spans{receiver=otlp,transport=http} 0
Collector log: no warnings
otelcol_receiver_accepted_spans and otelcol_exporter_sent_spans both read 1, and the span
arrived without http.request.header.authorization. The direct-export record kept it. The tests
hold the records to these claims and the configs to the order rule:
node --test collector.test.mjs
1..10
# tests 10
# suites 0
# pass 10
# fail 0
# cancelled 0
# skipped 0
# todo 0
Hold spans through a backend outage
With the backend down, the same span went to the Collector, and then straight to the closed port:
node show.mjs outage-collector outage-direct
outage-collector: the backend is down; the service exports to the Collector, which is then stopped
app export: success
Collector metrics before it stopped:
otelcol_exporter_queue_capacity{exporter=otlp_http} 1000
otelcol_exporter_queue_size{exporter=otlp_http} 1
otelcol_receiver_accepted_spans{receiver=otlp,transport=http} 1
otelcol_receiver_refused_spans{receiver=otlp,transport=http} 0
Collector log:
info: Exporting failed. Will retry the request after interval. error="failed to make an HTTP request: Post \"http://127.0.0.1:<backend>/v1/traces\": dial tcp 127.0.0.1:<backend>: connect: connection refused"
error: Exporting failed. Dropping data. error="interrupted due to shutdown: failed to make an HTTP request: Post \"http://127.0.0.1:<backend>/v1/traces\": dial tcp 127.0.0.1:<backend>: connect: connection refused" dropped_items=1
outage-direct: the backend is down; the service exports straight to it
app export: failed: Error: ECONNREFUSED
The Collector accepted the span and queued it for retry, while direct export failed. The
queue is in memory, so stopping the Collector dropped the span. A
persistent queue
needs a storage extension, and this build lists only health_check, pprof and zpages, as
node show.mjs validate prints. The
contrib distribution’s manifest
lists filestorage.
The agent tier runs the same way: agent.yaml adds resource_detection, and the backend
received host.name and os.type on the span’s resource, as node show.mjs agent-gateway
prints.
When it goes wrong
The Collector runs out of memory during a backend outage. The pipeline has no memory_limiter,
and the Collector accepts that config:
node check-config.mjs no-limiter.yaml
no-limiter.yaml traces: [transform/redact, batch] FAIL, memory_limiter is missing
records/validate.txt holds otelcol validate no-limiter.yaml: exit 0, although that file
declares no limiter at all. The same record holds exit 1 for a pipeline that names a processor
it never configures, so validate does refuse what it checks. Only the order check stands
between no-limiter.yaml and production.
Every export fails with a retryable status. The limiter is set below what the Collector holds at rest, so it refuses everything:
node show.mjs limiter
limiter: memory_limiter with limit_mib 4 and spike_limit_mib 1, below what the Collector holds at rest
one request with no retry: 503 {"code":14,"message":"data refused due to high memory usage"}
app export: failed: OTLPExporterError: Export failed with retryable status
backend received 0 spans
The receiver answered 503, which the
OTLP specification lists as
retryable. The SDK tried six times, and the counter otelcol_receiver_refused_spans reads 7
with the probe. Size limit_mib from the memory the Collector is given, or use
limit_percentage in a container.
When not to do this
Do not put a Collector in front of one service in development. Direct export has fewer parts, and the failures it hides only matter once there is an outage to buffer through.
Do not count the in-memory queue as durability. It holds data through a backend outage and loses it on a restart, as the record shows. If losing that window matters, run the contrib distribution with a persistent queue, and size the disk for it.
Do not run a gateway without two replicas and a memory limit set from the container’s limit. It has become the one path every service’s telemetry takes, so it needs the care any shared service gets.
Skip your own Collector when Datadog is the backend you will keep and its Agent already runs on every host. Its OTLP receiver covers the same ground with one less process, and the cost is that the choice of backend moves out of your config.
Related how-tos
Last verified
Verified 2026-11-30 against Node 22.23.5. Every output block is what the command preceding it
printed in the page’s code directory, from records that record.sh wrote with otelcol 0.166.0
and the SDK packages in versions. The Datadog Agent was not run, and its row is read from its
OTLP ingestion documentation.
Footnotes
-
The README of the exporter calls it
otlp_httpand keepsotlphttpas a deprecated alias, which it says will be removed in a future version without naming one. Started with the deprecated spelling,otelcol0.166.0 runs and logs"otlphttp" alias is deprecated; use "otlp_http" instead, a linerecord.shkeeps inrecords/alias.txt. ↩︎ Back to text -
The IANA port registry lists 4317 as the OpenTelemetry Protocol, registered on 2020-12-09, and 4318 as unassigned. The OTLP specification names 4318 as the default port for OTLP over HTTP all the same, one higher than the port OpenTelemetry registered. ↩︎ Back to text