In brief
OpenTelemetry is an open standard and toolkit for collecting telemetry from applications: traces, metrics and logs. An application instrumented once with OpenTelemetry sends data over the OTLP protocol to a Collector, which filters it and forwards it to the monitoring system of your choice, open source or commercial. Changing monitoring vendors therefore does not require code changes. OpenTelemetry does not store data or draw charts. It provides a common language: the same attribute names and one request ID across all services.
What OpenTelemetry is and what it is not
OpenTelemetry is a Cloud Native Computing Foundation project created by merging two earlier projects, OpenTracing and OpenCensus. Both tried to solve the same problem: every monitoring vendor had its own agent and data format, so changing tools meant re-instrumenting every application.
| OpenTelemetry is | OpenTelemetry is not |
|---|---|
| a specification, API and SDKs for many languages | a telemetry database |
| a data transport protocol (OTLP) | a system for charts and alerts |
| a Collector to receive, process and send data | ready-made monitoring out of the box |
| a set of naming conventions | a single vendor's tool |
Data goes on to a system you already have or will choose: open source or commercial. OpenTelemetry is the layer between the application and that system. Observability concepts are explained in Observability.
Three signals and how they connect
| Signal | What it shows | Example from an order system |
|---|---|---|
| trace | one request's path through services, with the time of each step | placing an order: portal 40 ms, pricing service 120 ms, database write 900 ms |
| metric | numbers over time: counters, histograms, gauges | orders per minute, 95th percentile response time |
| log | an event with content and context | "order rejected: customer item code missing" |
The value of OpenTelemetry is not in the signals themselves, because companies have collected logs and metrics for years. It is in linking them. Every log entry carries a trace ID, so from an alert on a metric you go to a specific slow request, and from there to the logs of that one operation.
The trace ID travels between services in the `traceparent` header defined by the W3C Trace Context standard. With messaging, for example Kafka or RabbitMQ, the context has to be passed in message headers, otherwise the trace breaks at the queue. Choosing a messaging system is covered in Kafka vs RabbitMQ.
Components: from code to the monitoring system
- API and SDK. Libraries for languages such as Java, .NET, Python, Go and JavaScript. The API creates traces and metrics in code, the SDK decides what to do with them.
- Automatic instrumentation. For popular frameworks, HTTP clients and database drivers, traces are created without changing application code.
- OTLP. The protocol the application uses to send data, over gRPC or HTTP.
- Collector. A separate process that receives data (receivers), processes it (processors) and sends it on (exporters). It handles retries, batching, encryption and filtering of sensitive data.
- Semantic conventions. Shared attribute names such as `service.name`, `http.request.method`, `http.response.status_code`. Thanks to them, a dashboard built for one service works for all of them.
The Collector is usually deployed in two tiers: close to the application (on the same node) and centrally, as a gateway through which all telemetry passes to the monitoring system.
Rolling it out in a company, step by step
- Service and environment names. Every service has `service.name`, a version and an environment in its resource attributes. Without this, production and test data mix on the charts.
- One service to start. Automatic instrumentation in the service that causes the most trouble, for example order handling. The first results show up within days.
- The Collector as a gateway. Applications send data to the Collector, not directly to a vendor. Changing the monitoring system then means changing the Collector configuration.
- Context propagation. Check that traces pass through all services, queues and batch jobs. Broken traces are the most common problem in the first weeks.
- Sampling. Not every trace needs to be stored, as explained below.
- Logs with the trace ID. The logging library adds the ID to every entry.
- Objectives and alerts. Indicators for service level objectives are built on OpenTelemetry metrics, as described in SLOs and error budgets.
A note on personal data: trace attributes and log content should not contain national ID numbers, email addresses or document content. Collector processors can remove or mask selected attributes before data leaves the company network.
Cost, sampling and pitfalls
Telemetry can cost more than the servers it describes. Three mechanisms keep the bill under control:
- Head sampling. The decision is made when the request starts, for example keep 10% of traces. Simple and cheap, but it can drop a trace with an error.
- Tail sampling. The decision is made after most of the trace is collected, usually in the Collector: keep all traces with errors and all slower than 2 seconds, sample the rest. It gives better data, but needs a stateful Collector that is itself monitored.
- Metric cardinality. A label with a customer or order number on a metric creates millions of series. That data belongs in traces and logs, not in metrics.
Signal maturity differs between languages: one language's SDK may have stable traces and metrics while logs are still in development. Before rolling out, check the project's status page for the languages you use. A comparison with APM tools is in APM: application performance monitoring.
OpenTelemetry was part of the observability stack in the project for a cloud platform and DevOps for a payments fintech. We build platforms with central observability, where new versions go live without downtime, in our Platform and DevOps service.
Questions and answers
Does OpenTelemetry replace a monitoring system?
No. OpenTelemetry collects and transports data but does not store or display it. You still need a system to store traces, metrics and logs and to provide charts and alerts. The advantage is that this system can be changed without re-instrumenting applications.
Does instrumentation slow the application down?
Every measurement costs some CPU time and memory, but with a sensible configuration the overhead is small compared with service response times. The number of attributes, log size and missing sampling have the biggest impact. It is worth measuring the overhead in a performance test before going to production.
Does OpenTelemetry work with older applications?
Usually yes, if the language and framework have automatic instrumentation or a library can be added to the code. For systems that cannot be changed, you collect what comes out of them: logs from files, metrics from the database, traces from an API gateway in front of the system. The Collector also accepts data in other popular formats.
Where do you start when the company already has several monitoring tools?
With the Collector as a shared gateway and one service instrumented with OpenTelemetry. The Collector can send data to the old and new systems in parallel, so the transition happens without a gap in monitoring. Old agents are switched off one by one once the new data is complete.