OpenTelemetry
medium 30 minOpenTelemetry is an open standard, with libraries and a Collector, for making and moving traces, metrics and logs.
Video lesson · Chapter 1 of 5
One lost order crosses two services
OpenTelemetry in 90 seconds
1:30Reel coming soon
Theory
Read or listen first. About 2 min.
What it is
OpenTelemetry, or OTel, is a set of agreements and programs for telemetry: the traces, metrics and logs that a system produces about itself. It has a specification, libraries for many languages, a protocol called OTLP, agreed names for data, and a program called the Collector.
It does not store data or draw charts. That is left to backends such as Jaeger, Prometheus, the ELK Stack or a vendor.
It is a project of the Cloud Native Computing Foundation, under the Apache 2.0 licence.
Why it exists
Before, each monitoring product had its own library. Changing the product meant changing the code of every service. Library authors had to choose one product or none.
OpenTelemetry puts a common plug between. Code and frameworks speak one language, the Collector speaks it too, and the choice of backend becomes a few lines of configuration. The project puts it this way: you own the data you generate, and you learn one set of APIs.
A short history
May 2019
Two projects, OpenTracing and OpenCensus, agree to merge. The CNCF accepts OpenTelemetry on 7 May.
August 2021
The project moves to the incubating level.
November 2021
The W3C Trace Context recommendation, which defines
traceparent, appears in its current edition.2023
The names for HTTP data are declared stable.
2026
The specification deprecates OpenTracing compatibility in March. CNCF lists 11 May as the graduation date, and the announcement follows on 21 May. The profiles signal enters public alpha.
Words to know
- Signal
- One kind of telemetry: traces, metrics, logs, baggage, and profiles in development.
- API
- The functions that code calls. Without an SDK they do nothing.
- SDK
- The implementation that samples, batches and exports. The application chooses it.
- Instrumentation library
- A package that makes spans and metrics for a framework, such as an HTTP client.
- OTLP
- The OpenTelemetry protocol: gRPC on port 4317, HTTP on port 4318.
- Resource
- Who produced the data:
service.name, version, host. - Semantic conventions
- Agreed names, such as
http.request.method. - Collector
- A program that receives, processes and exports telemetry.
- Baggage
- Key and value pairs that travel with a request to other services.
How it works
Step through the idea, or press Play.
Instrument. API calls in code and libraries
Understand it
Start here
One plug for the brass band
A brass band wants to be recorded. Every instrument has its own kind of plug, and the recorder has one socket. Imagine buying new instruments for each new recorder.
The plug is the standard. The box is the Collector. The recorders are yours to choose.
The whole
Parts and borders
One protocol in, any backend out
Traces
The path of a request, as spans. Stable.
Metrics
Counters, gauges and histograms, summed up in the process. Stable API and protocol.
Logs
Existing log libraries are bridged and get trace ids. Stable in the specification.
Baggage
Values that travel with the request. Not telemetry by itself.
Profiles
Which code uses the CPU. Public alpha in 2026.
Conventions
The same names everywhere, so one dashboard fits all services.
Status differs by language (November 2026)
| Language | Traces | Metrics | Logs |
|---|---|---|---|
| Java, .NET, C++, PHP | Stable | Stable | Stable |
| Go | Stable | Stable | Release candidate |
| Python, JavaScript | Stable | Stable | Development |
| Ruby, Swift, Erlang | Stable | Development | Development |
| Rust | Beta | Stable | Stable |
In the code
API and SDK are separate on purpose
A library should be able to make spans without forcing a product on its users. So it depends on the small API only. If the application installs no SDK, the calls do almost nothing. If it does, the SDK decides about sampling, batches and export.
Who depends on what
Ways to instrument
| Way | Effort | You get |
|---|---|---|
| Zero-code agent or wrapper | Change the start command | HTTP, database and messaging spans of known libraries |
| eBPF instrumentation | Run a program on the host | HTTP and gRPC spans without touching the process |
| Instrumentation libraries | A few lines at start | The same, chosen by you |
| Manual spans and metrics | Code in business functions | What only you know: order value, cache hit, plan |
pip install opentelemetry-distro opentelemetry-exporter-otlpopentelemetry-bootstrap -a installexport OTEL_SERVICE_NAME=checkoutexport OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobufexport OTEL_TRACES_SAMPLER=parentbased_traceidratioexport OTEL_TRACES_SAMPLER_ARG=0.1opentelemetry-instrument python app.pyContext
How a trace crosses a border
Inject and extract
traceparent: 00-0af7…319c-b7ad…3331-01
| Part | Length | Meaning |
|---|---|---|
| Version | 2 hex digits | 00 today, ff is forbidden |
| Trace id | 32 hex digits | 16 bytes, not all zero |
| Parent id | 16 hex digits | The calling span, 8 bytes, not all zero |
| Flags | 2 hex digits | 01 means sampled |
Metrics
Aggregated in the process, limited by attributes
A counter in OpenTelemetry does not send each increment. The SDK adds them up for each combination of attributes and exports the sums, every 60 seconds by default. Cumulative sums count from the start of the process, delta sums since the last export. Prometheus wants cumulative.
How many series does one metric make?
So a user id belongs on a span, not on a metric. Exemplars build the bridge: a histogram can carry a few trace ids as examples. By default these come from sampled traces.
OTLP
The protocol
| OTLP over gRPC | OTLP over HTTP | |
|---|---|---|
| Port | 4317 | 4318 |
| Address | One service | /v1/traces, /v1/metrics, /v1/logs |
| Encoding | Protobuf | Protobuf or JSON |
| Good for | Inside the cluster | Proxies, browsers, the default of SDK exporters |
The receiver can say: all accepted, partly accepted, or try later. Errors such as UNAVAILABLE are retried with growing pauses. If an answer is lost, the client sends again, so a backend may get duplicates. The specification calls that the right trade-off for telemetry.
Collector
Receivers, processors, exporters
receivers: otlp: protocols: grpc: { endpoint: localhost:4317 } http: { endpoint: localhost:4318 }processors: memory_limiter: check_interval: 1s limit_percentage: 80 spike_limit_percentage: 20 attributes/mask: actions: - { key: http.request.header.authorization, action: delete } - { key: user.email, action: hash } batch: send_batch_size: 8192 timeout: 200msexporters: otlp_grpc/traces: endpoint: jaeger:4317 tls: { ca_file: /etc/otel/ca.crt } otlp_http/vendor: endpoint: https://otlp.vendor.example headers: { api-key: "${env:VENDOR_KEY}" }service: pipelines: traces: receivers: [otlp] processors: [memory_limiter, attributes/mask, batch] exporters: [otlp_grpc/traces, otlp_http/vendor]Agent and gateway
Where to run a Collector
| Pattern | Good | Cost |
|---|---|---|
| None: SDK to backend | Simple, fine for a trial | Credentials and retries in every service |
| Agent on each host | Quick handover, host metadata, log files | Configuration on every host |
| Gateway, several copies | One place for rules and keys | A service to scale and to keep up |
| Agent and gateway | Both | Two layers to watch |
The project ships several builds: core, contrib with very many components, k8s, otlp and one for profiling. For production, build your own with the builder tool (ocb) and include only what you use.
Sampling
Keeping less, but the right things
The SDK default is parentbased_always_on: keep everything, and follow the caller. With parentbased_traceidratio the first service decides from the trace id, and the others follow the flag. The documentation suggests thinking about sampling from about 1,000 traces a second.
Tail sampling needs two layers
Is the default memory enough?
Sample well
- Let the first service decide, and pass the flag on
- Make metrics from spans before sampling
- Keep all errors and slow traces with tail sampling
- Different shares for loud and quiet services
Sample badly
- Each service rolls its own dice
- Two Collectors behind a plain balancer decide on halves of a trace
- Rates computed from kept traces
- 1 percent everywhere, also for ten requests a day
Limits
Every queue ends somewhere
Where data can be dropped
| Place | Default | When it is full |
|---|---|---|
| SDK span queue | 2,048 spans, batches of 512, at least every 5 s | New spans are dropped |
| Span attributes, events | 128 each | More are ignored |
| Collector memory limiter | You set it | Data is refused, the sender retries |
| Collector sending queue | 1,000 requests, 10 senders | New data is rejected |
| Collector retries | From 5 s up to 30 s, for 300 s in all | The batch is dropped |
The fastest one SDK can export
The backend is down
Operate
Running the Collector
- 1
Watch it
It reports its own metrics: accepted, refused, sent, failed, queue size and capacity. Scale up when a queue stays at 60 to 70 percent.
- 2
Know what scales
OTLP receivers are stateless and go behind a balancer. Tail sampling needs routing by trace id. Prometheus scraping needs targets shared out.
- 3
Do not scale against a slow backend
More Collectors press harder on the part that is already too slow.
- 4
Listen narrowly
Since 0.110 the default address is localhost. If others must reach it, use a specific address, TLS and authentication.
- 5
Pin versions
The Collector releases often, and its components have different levels of stability. Read the changelog before an upgrade.
- 6
Mask early
OpenTelemetry cannot know what is personal in your data. Collect less, delete or hash attributes before they leave.
Move
Changing a running system
Move without a gap
Collectors accept other formats too: Zipkin, Jaeger's older ones, Prometheus scraping, log files. So services can move one at a time. The OpenTracing bridge is deprecated since March 2026, so plan to replace such code.
Choose
When it fits and when not
| Situation | Choice | Why |
|---|---|---|
| Several languages, several backends | OpenTelemetry | One way for all |
| You publish a library | The OpenTelemetry API only | Users choose the SDK |
| Only Prometheus metrics in Go services | The Prometheus client is fine | Simple, and the Collector can scrape it later |
| A vendor feature that needs its own agent | The vendor's agent for that part | Not everything is in the standard |
| A small script | Logs | A pipeline would be larger than the script |
| You need a database and dashboards | A backend | OpenTelemetry has none |
Summary
The whole topic in one minute.
Libraries call the API, the application installs the SDK, and the SDK sends OTLP. Context travels in headers so that spans of different services form one trace.
The Collector stands between services and backends: receive, protect memory, filter, sample, batch, export. That is where you change vendors, remove secrets and keep credentials.
Everything has a queue with a limit. Telemetry is dropped before it hurts the application, so measure the drops, and watch the number of attribute combinations.
- OpenTelemetry makes and moves telemetry. It stores nothing.
- API in libraries, SDK in the application, OTLP on the wire, Collector in between.
- Context travels in traceparent. Baggage travels too, and is not secret.
- Metrics: keep attribute combinations few. 2,000 is the default limit.
- Tail sampling needs all spans of a trace in one Collector, and memory.
- Every queue has a limit: measure what is dropped.
- The Collector is the place for keys, masks and the change of backend.
Sources
- OpenTelemetry: what it is
- OpenTelemetry: status by language
- Specification: SDK environment variables
- Specification: OTLP
- Specification: metrics SDK and cardinality limits
- OpenTelemetry: Collector configuration
- OpenTelemetry: scaling the Collector
- OpenTelemetry: sampling
- Tail sampling processor
- W3C: Trace Context
- CNCF: OpenTelemetry project page