OpenTelemetry Explained: A Practical Guide for Engineering Teams
What OpenTelemetry is, how the API, SDK, Collector and OTLP fit together, and how to roll it out across your services without rewriting them.
On this page
Most engineering teams arrive at OpenTelemetry the same way. Someone is chasing a slow request through five services, the logs in each service use a different format, the metrics are named three different ways, and the tracing library in one service only talks to one backend. OpenTelemetry (often shortened to OTel) exists to remove that friction: one vendor-neutral way to produce, describe and ship telemetry, so the question "what happened to this request?" has a single answer.
This guide explains what OpenTelemetry actually is, how its parts fit together, and how to roll it out in a real organisation without a big-bang rewrite. It is written for engineers who will do the work and for the leads who need to plan it.
What OpenTelemetry is (and is not)
OpenTelemetry is a Cloud Native Computing Foundation project that defines APIs, SDKs, a wire protocol and a set of naming rules for telemetry data, plus a standalone data pipeline called the Collector. It covers generating, collecting, processing and exporting telemetry.
It deliberately does not include a storage backend or a user interface. You still need somewhere to store and query traces, metrics and logs. That split is the point: instrumentation is a long-lived investment that touches every service, while backends change as budgets, scale and requirements change. OTel lets you keep the first while changing the second.
The signals
OpenTelemetry organises telemetry into signals. The three you will use every day are:
- Traces record the path of one request through a system. A trace is a tree of spans; each span is a timed operation (an HTTP handler, a database query, a queue publish) with attributes, events and a status.
- Metrics are numeric measurements aggregated over time: counters, up-down counters, gauges and histograms. They are cheap to store and ideal for dashboards and alerting.
- Logs are timestamped records. OTel's approach is to bridge your existing logging libraries rather than replace them, and to attach trace and span IDs to each record so a log line can be joined to the trace that produced it.
Two further concepts complete the picture. Baggage is a set of key-value pairs that propagates alongside the trace context, so a value set at the edge (a tenant ID, for example) is readable downstream. Profiles are being added as a further signal. Maturity differs by signal and by language, so check the specification status page before you commit to a signal in a particular runtime.
API versus SDK
This distinction confuses many teams, and it matters for library authors.
The API is the set of interfaces your code calls: get a tracer, start a span, record a measurement. It has no behaviour of its own. If nothing configures an implementation, API calls are effectively no-ops. That is why a shared library can depend on the OTel API safely: it adds instrumentation without forcing any exporter, sampler or backend on the application that uses it.
The SDK is the implementation the application owner installs and configures. It decides how spans are sampled, how telemetry is batched, which resource attributes describe the process (service name, version, environment, host), and which exporters send data out.
A simple rule: libraries depend on the API; applications configure the SDK.
Instrumentation: zero-code and code-based
There are two ways to get telemetry out of a service, and most teams use both.
Zero-code instrumentation (sometimes called automatic instrumentation) attaches to a running application and instruments popular frameworks and clients without source changes. The mechanism depends on the language: a Java agent, a Python or Node.js bootstrap, eBPF-based approaches, or an operator in Kubernetes that injects instrumentation into pods. It gets you HTTP server and client spans, database calls and messaging spans quickly.
Code-based instrumentation uses the API directly to add spans and attributes that carry business meaning: the order ID, the payment provider, the cache decision, the feature flag that was evaluated. Zero-code instrumentation tells you a request was slow; your own spans tell you why it mattered.
A sensible rollout starts with zero-code instrumentation for breadth, then adds manual spans around the handful of operations that matter most to customers.
Most SDKs read standard environment variables, which keeps configuration out of code:
OTEL_SERVICE_NAME=checkout-api
OTEL_RESOURCE_ATTRIBUTES=service.version=2.14.0,deployment.environment.name=production
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=0.25
OTEL_SERVICE_NAME is the single most important setting. A service without a name shows up as unknown_service (sometimes with the process name appended) and is nearly impossible to reason about in a busy backend.
OTLP: the protocol
The OpenTelemetry Protocol (OTLP) defines how telemetry is encoded and transported between SDKs, Collectors and backends. It uses Protocol Buffers and runs over gRPC or HTTP. The conventional default ports are 4317 for gRPC and 4318 for HTTP, and over HTTP each signal has its own path: /v1/traces, /v1/metrics and /v1/logs.
Standardising on OTLP everywhere is one of the most valuable decisions you can make. When every service emits OTLP and every hop accepts OTLP, swapping a backend or adding a second destination becomes a Collector configuration change.
The Collector
The Collector is a standalone process that receives, processes and exports telemetry. You can run applications without it and export directly to a backend, but in production almost every team puts a Collector in the path because it moves operational concerns out of application code: retries, batching, redaction, enrichment, sampling and routing.
A Collector configuration has three main building blocks:
- Receivers get data in. The
otlpreceiver accepts OTLP; others scrape Prometheus endpoints, tail log files or read from message queues. - Processors transform data in flight: batching, memory protection, adding Kubernetes metadata, filtering, redacting attributes, sampling.
- Exporters send data out, over OTLP or in a backend-specific format.
These are wired together in pipelines under the service section, one per signal. Two further component types exist: connectors, which join pipelines (for example, deriving metrics from spans), and extensions, which add capabilities such as health checks.
Here is a realistic starting configuration for a gateway Collector:
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
processors:
memory_limiter:
check_interval: 1s
limit_percentage: 80
spike_limit_percentage: 20
k8sattributes: {}
resource:
attributes:
- key: deployment.environment.name
value: production
action: upsert
batch: {}
exporters:
otlphttp:
endpoint: https://telemetry-backend.example.com
debug:
verbosity: basic
extensions:
health_check: {}
service:
extensions: [health_check]
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, k8sattributes, resource, batch]
exporters: [otlphttp]
metrics:
receivers: [otlp]
processors: [memory_limiter, k8sattributes, resource, batch]
exporters: [otlphttp]
logs:
receivers: [otlp]
processors: [memory_limiter, k8sattributes, resource, batch]
exporters: [otlphttp]
Two details are worth calling out. Put memory_limiter first in each pipeline so the Collector sheds load before it runs out of memory, and put batch near the end so exports are efficient. A component defined but not referenced in a pipeline is simply not used.
The Collector ships in several distributions. The core distribution contains a small, stable set of components; the contrib distribution includes many more (including k8sattributes and tail_sampling). Many teams build a custom distribution containing only the components they need, which shrinks the binary and the attack surface.
Agent and gateway patterns
There are two common deployment shapes, and they combine well:
- Agent: a Collector on every node (a Kubernetes DaemonSet) or as a sidecar. Applications export to
localhostor the node, which keeps network hops short and lets the agent add host and pod metadata. - Gateway: a centrally managed pool of Collectors behind a load balancer. It is where you apply organisation-wide policy such as redaction, tail sampling and routing to one or more backends.
Start with whichever is simpler for your platform, usually a gateway, and add agents when you need node-level metadata or host metrics.
Semantic conventions
Telemetry is only useful if it is consistent. Semantic conventions are OpenTelemetry's agreed names and meanings for attributes, spans and metrics. Instead of one team writing status, another http_status and a third responseCode, everyone uses http.response.status_code. Other common examples include http.request.method, http.route, server.address, service.name and service.version.
Following the conventions has practical payoffs: dashboards and queries work across services, backends can build features on known attributes, and instrumentation libraries produce data that lines up with your manual spans. When you add your own attributes, namespace them (for example app.order.tier) so they never collide with future standard names.
Context propagation and W3C Trace Context
A distributed trace only works if every service knows it is part of the same request. Context propagation carries the trace ID and the current span ID across process boundaries, usually in HTTP headers or message metadata.
OpenTelemetry uses the W3C Trace Context standard by default. The traceparent header has four dash-separated fields:
traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
│ │ │ └ trace flags (01 = sampled)
│ │ └ parent span ID (16 hex characters)
│ └ trace ID (32 hex characters)
└ version
A companion tracestate header carries vendor-specific data, and baggage travels in its own baggage header.
Broken traces almost always come from a gap in propagation: a proxy that strips headers, an async job that does not carry context onto a queue message, a thread pool that loses the current context, or a service still using an older proprietary header format. When you see orphaned spans, follow the request hop by hop and check where traceparent disappears.
Sampling: head versus tail
High-traffic systems can produce more traces than anyone wants to store. Sampling decides which traces to keep.
Head sampling decides at the start of a trace, usually by hashing the trace ID against a ratio. It is cheap and stateless, and the parentbased_traceidratio sampler shown earlier respects an upstream decision so a trace is kept or dropped consistently across services. Its weakness is that it decides before anything interesting has happened, so it drops errors and slow requests at the same rate as healthy ones.
Tail sampling decides after the trace is complete, so it can keep every trace with an error or high latency and a fraction of the rest. In OpenTelemetry this is done in the Collector with the tail_sampling processor:
processors:
tail_sampling:
decision_wait: 10s
policies:
- name: keep-errors
type: status_code
status_code:
status_codes: [ERROR]
- name: keep-slow
type: latency
latency:
threshold_ms: 500
- name: baseline
type: probabilistic
probabilistic:
sampling_percentage: 10
Sampling also has cost and fidelity trade-offs that are organisational, not just technical. Some teams prefer to keep all spans and control cost through retention and attribute hygiene instead. Decide deliberately, and write the policy down.
Cardinality and cost
Cardinality is the number of unique combinations of attribute values on a metric. Every unique combination is a separate time series. A request counter labelled with method, route and status code is fine; the same counter labelled with user ID, request ID or a raw URL path can produce an unbounded number of series, slow every query and inflate storage.
Practical rules:
- Use
http.route(the template, such as/orders/:id), never the raw path, on metrics. - Put high-cardinality identifiers on spans and logs, where they are expected, not on metric attributes.
- Use Collector processors to drop or hash attributes you do not want stored.
- Review new metrics in code review, the same way you would review a new database index.
Using the data: RED, USE and SLOs
Instrumentation is a means, not an end. Two simple methods give your dashboards a backbone:
- RED for request-driven services: Rate, Errors and Duration of requests.
- USE for resources such as CPU, memory, disks and connection pools: Utilisation, Saturation and Errors.
On top of that, service level objectives (SLOs) turn telemetry into decisions. An SLO sets a target for a service level indicator, for example the proportion of checkout requests that succeed within a latency threshold over 28 days. The gap between the target and 100% is the error budget. Alerting on how fast you are burning that budget, rather than on every spike, is the approach described in Google's SRE workbook and is far kinder to on-call engineers.
If your metrics reach a Prometheus-compatible store, an availability SLI for HTTP can be as simple as:
sum(rate(http_server_request_duration_seconds_count{http_response_status_code!~"5.."}[5m]))
/
sum(rate(http_server_request_duration_seconds_count[5m]))
Exact metric and label names depend on how OTLP metrics are translated into Prometheus naming in your pipeline, so confirm them in your backend before building alerts.
A rollout plan that works
Rolling out OpenTelemetry is mostly a change-management exercise. A phased plan keeps risk low:
- Pick one critical user journey. Checkout, login or an API that customers call directly. Map the services on its path.
- Stand up a Collector. A gateway with OTLP in and your current backend out. Add
memory_limiter,batchand a resource processor from day one. - Enable zero-code instrumentation on each service in the journey, with
OTEL_SERVICE_NAME, version and environment set consistently. - Verify propagation end to end. One request should produce one trace across every hop. Fix gaps before going wider.
- Correlate logs. Make sure trace and span IDs appear on log records so engineers can jump from a log to its trace.
- Add manual spans and attributes that carry business meaning for the operations people actually ask about.
- Define SLOs and alerts for the journey using RED metrics, then retire the noisy alerts they replace.
- Write the conventions down: naming, attribute namespaces, sampling policy, PII rules. Then repeat for the next journey.
Security and data protection
Telemetry often contains more sensitive data than teams expect: user IDs, email addresses in URLs, SQL statements with literal values, authorisation headers captured by over-eager instrumentation. Treat the telemetry pipeline as a data system:
- Use TLS between SDKs, Collectors and backends, and authenticate exporters.
- Redact or drop sensitive attributes in the Collector so a single policy covers every service.
- Do not put secrets or personal data in baggage; it is propagated to every downstream service, including third parties you call.
- Restrict who can change Collector configuration, because it controls where all telemetry goes.
Choosing a backend
Because OTel separates instrumentation from storage, the backend decision becomes more reversible. Evaluate backends on how faithfully they accept OTLP and semantic conventions, how they handle high-cardinality data, whether logs, metrics and traces are correlated in one place, how sampling and retention are controlled, and how they fit your security model (SSO, roles, audit logs, deployment options). The OpenTelemetry project maintains a list of vendors and projects that support it natively.
One example of a backend built around OpenTelemetry from the start:
Whatever you choose, keep instrumentation vendor-neutral and run a short proof of concept with your own traffic on your own critical journey before committing.
Summary
OpenTelemetry gives you one standard for producing telemetry and one protocol for moving it. Libraries use the API, applications configure the SDK, the Collector handles the operational work, OTLP carries the data, and semantic conventions keep it consistent. Get propagation right, decide your sampling policy deliberately, keep cardinality under control, and connect the data to SLOs. Do that for one critical journey, then repeat.
Frequently asked questions
Is OpenTelemetry a replacement for Prometheus or Jaeger?
No. OpenTelemetry generates and transports telemetry; it does not store or visualise it. Prometheus, Jaeger and commercial platforms are backends that can receive OpenTelemetry data.
Do I need the Collector?
Not strictly, because SDKs can export directly to a backend. In production most teams use one, because it centralises batching, retries, redaction, sampling and routing outside application code.
Should I use head or tail sampling?
Head sampling is simple and cheap but drops errors at the same rate as healthy traffic. Tail sampling keeps the interesting traces but needs all spans of a trace to reach the same Collector. Many teams combine a light head sample with tail-based policies.
How do I connect logs to traces?
Use the OpenTelemetry log bridge or appender for your logging library, or add the active trace and span IDs to your log format. A backend can then join a log record to the trace that produced it.
Will OpenTelemetry slow down my services?
Instrumentation has some overhead, which depends on the language, the instrumentation used and the volume of spans. Batch exports, avoid creating spans in tight loops, and measure the overhead in your own load tests before a wide rollout.
References
Related resources
Keep reading
OpenTelemetry vs Vendor-Specific Instrumentation
TrustHappens Editorial Team
Comparison7 min read
Modern Observability: Logs, Metrics and Distributed Tracing Explained
TrustHappens Editorial Team
Insight7 min read
How to Troubleshoot Kubernetes Production Incidents
TrustHappens Editorial Team
Insight6 min read
Stay Ahead of What Matters.
Practical guides on observability & cloud and more, delivered to your inbox.