What it is
OpenTelemetry (OTel) is a CNCF project that standardises how software produces and transports telemetry: an API and SDKs for many languages, instrumentation libraries for common frameworks, semantic conventions for attribute names, the OTLP protocol, and the Collector. It does not store or visualise data; backends do.
Why it exists
Before OTel, each vendor had its own agents, libraries and formats, so changing backends meant re-instrumenting every service, and libraries could not ship instrumentation without picking a vendor. OTel separates producing telemetry (once, in a standard way) from storing and analysing it (any backend).
How it works
API and SDK. Libraries and application code call the API (tracer.startSpan, meter.createCounter). Without an SDK, calls are no-ops. The application installs and configures the SDK once: a resource (service.name, version, environment), a sampler, processors (e.g. batch) and exporters. Configuration can also come from standard environment variables such as OTEL_SERVICE_NAME and OTEL_EXPORTER_OTLP_ENDPOINT.
Instrumentation. Instrumentation libraries (or zero-code agents in Java, .NET, Python, Node.js and others) create spans and metrics for HTTP servers and clients, gRPC, database drivers and messaging clients, and propagate W3C Trace Context. You add spans and attributes for business logic.
OTLP. The OpenTelemetry Protocol carries traces, metrics and logs over gRPC (port 4317) or HTTP (4318, protobuf or JSON).
Collector. A standalone binary configured as pipelines per signal: receivers (OTLP, Prometheus scraping, host metrics, log files…) → processors (memory_limiter, batch, attribute and resource rules, filtering, tail_sampling) → exporters (OTLP to a backend, Prometheus remote write, vendor exporters). Distributions (core, contrib, vendor builds) differ in which components they include.
Signals and context. Logs emitted within a span carry its trace and span ids; metric points can carry exemplars that reference a trace. This is what lets you jump between signals.
Sampling. Head sampling happens in the SDK at the root span, typically ParentBased(TraceIdRatioBased(p)): the root decides by trace id and children follow the sampled flag, so traces are complete and the cost is low, but the decision is blind to outcome. Tail sampling happens in the Collector: it buffers spans per trace for a decision window, then applies policies (errors, latency above a threshold, attributes, a probabilistic baseline). It needs all spans of a trace on the same collector instance.
Scaling. A common layout is an agent collector per node or as a sidecar, close to the apps, plus a pool of gateway collectors. Agents use the load-balancing exporter with trace id as the routing key, so each trace's spans reach one gateway, which tail-samples and exports.
Backpressure. SDK and Collector exporters use bounded queues with retries. When a backend is slow, the memory_limiter refuses data, upstream exporters retry and eventually drop. The Collector exposes its own metrics (accepted, refused, dropped, queue size) for monitoring.
When to use it
For new instrumentation in almost any service today: it is supported by all major observability vendors and open-source backends. Use the Collector whenever more than a handful of services export telemetry, or when you need redaction, sampling or multiple destinations.
When not to
- A tiny system where a single vendor agent already does everything and switching is unlikely may not need the extra moving part of a Collector.
- Do not expect OTel to replace a backend: you still need storage, querying, dashboards and alerting.
- Some language SDKs and signals mature at different speeds; check the status of the signal and language you depend on.
Trade-offs
| Choice | You gain | You pay |
|---|---|---|
| Collector instead of direct export | Central config, redaction, batching, vendor independence | Another service to run, scale and monitor |
| Head sampling | Cheap, simple, complete traces | Rare errors and slow traces are mostly lost |
| Tail sampling | Keeps errors and slow traces | Buffering memory, all spans sent first, trace-id routing |
| Agent + gateway tiers | Scalability, tail sampling across instances | More components, more configuration |
| Zero-code agents | Fast coverage | Less control; generic span names; runtime overhead |
Alternatives
- Vendor-specific agents and SDKs: often feature-rich, but lock instrumentation to one vendor.
- Prometheus client libraries for metrics only, scraped directly; OTel can interoperate with them.
- eBPF-based instrumentation: no code changes, sees network-level behaviour, limited view inside processes and of business context.
Failure modes
- Silent drops: queues overflow during backend outages and nobody watches the collector's dropped-data metrics.
- Fragmented tail sampling: spans of one trace reach different gateways, so policies decide on fragments.
- Collector OOM: no
memory_limiter, or a tail-sampling window too long for the traffic. - Missing resource attributes: telemetry without
service.nameor environment cannot be filtered. - Inconsistent sampling: services with different head samplers that ignore the parent's decision produce partial traces.
- Sensitive data: attributes with personal data exported before redaction.
In production
Instrument with OTel SDKs and auto-instrumentation, set resource attributes everywhere, export OTLP to a local agent collector, route by trace id to a gateway pool for tail sampling, batch and limit memory at every collector, redact in the pipeline, and monitor the pipeline's own metrics. Combine a modest head-sampling rate with tail rules if volume is very high.
Common misconceptions
- "OpenTelemetry is a backend." It produces and transports telemetry; storage and UI come from elsewhere.
- "The Collector is required." It is optional, but recommended in production.
- "Head sampling keeps errors." It decides before the outcome is known.
- "If the telemetry backend is down, my app slows down." Correctly configured exporters drop data instead of blocking.
Interview angle
You may be asked how to add observability to a fleet of services. Describe OTel SDKs with auto-instrumentation, OTLP to collectors, per-signal pipelines, resource attributes and semantic conventions, and the head versus tail sampling trade-off including trace-id routing for tail sampling. Mention backpressure behaviour and monitoring the pipeline.
Model assumptions
This lesson is fully scripted: no node runs in the simulation engine. Requests, span exports and refusals are scripted packets, and configuration snippets are annotations; timings are illustrative. Component names and configuration keys follow the OpenTelemetry specification and Collector contrib components as of 2026, but exact options vary by version and distribution.