Malhar Ujawane

Blog

Explainer·(updated October 31, 2026)

What is OpenTelemetry? Traces, metrics and logs, explained

OpenTelemetry is the open standard for producing traces, metrics and logs and sending them to any backend. How spans, OTLP and the Collector fit together.

What is OpenTelemetry? Traces, metrics and logs, explained

OpenTelemetry (OTel) is an open-source standard and set of SDKs for producing telemetry (traces, metrics and logs) from your code and shipping it, in one vendor-neutral format called OTLP, to whatever backend you choose. You instrument once, and any backend that accepts OTLP can read the result. The project’s own docs are blunt about the scope: “OpenTelemetry is not an observability backend itself” (What is OpenTelemetry?).

That last sentence is the one most people miss. OTel does not store data or draw dashboards. It owns the part before the backend: the API you call in code, the SDK that batches and samples, the wire protocol, the naming conventions for attributes, and a proxy (the Collector) that sits in the middle.

Where did OpenTelemetry come from?

Two earlier projects tried to solve the same problem and split the community. OpenTracing gave you a tracing API; OpenCensus, which had “roots at Google,” gave you tracing and metrics libraries. On May 21, 2019, Ben Sigelman (co-creator of OpenTracing) and Morgan McLean (OpenCensus product lead at Google) announced that “OpenTracing and OpenCensus are merging into a single project,” which was “now a CNCF sandbox project,” with backwards compatibility through bridges and both old projects going read-only before the end of 2019.

The CNCF project page lists the rest of the timeline: accepted May 7, 2019, incubating on August 26, 2021, and graduated in 2026. The CNCF announced the graduation on May 21, 2026, seven years to the day after the merger post. Graduated is the CNCF’s top maturity level.

How does OpenTelemetry work?

Five parts, from your code outward.

  1. API. What application and library code calls: start a span, add an attribute, record a metric. It’s a thin interface with no-op defaults, so a library can instrument itself without forcing an SDK on its users.
  2. SDK. The implementation the application installs. It decides sampling, batches finished spans and hands them to an exporter.
  3. Semantic conventions. Agreed names for attributes, so an HTTP span from Java and one from Go both say http.request.method and http.response.status_code. The HTTP span conventions are marked Stable, and they also fix span names: “HTTP span names SHOULD be {method} {target}” with a low-cardinality target such as the route, never the raw URL path.
  4. OTLP. The wire protocol. The spec defines it over gRPC (default port 4317) and HTTP (default port 4318), with POST paths /v1/traces, /v1/metrics and /v1/logs, and Protobuf payloads “encoded either in binary format or in JSON format.”
  5. Collector. A separate process, described as a “vendor-agnostic way to receive, process and export telemetry data” (Collector docs). It is built from receivers, processors, exporters, connectors and extensions. Your service sends OTLP to a local Collector and moves on; the Collector handles retries, batching, encryption and filtering of sensitive data, then fans out to one or more backends.

What are traces, spans and context propagation?

A trace is one request’s path through a system. It is made of spans: timed operations with a name, a kind (server, client, internal, producer, consumer), attributes, and a parent. Every span in a trace shares the same 16-byte trace ID; each has its own 8-byte span ID and points to its parent’s.

Inside one process, the SDK tracks the “current span” so a new span knows its parent. Across processes, the parent has to travel in the request. That is context propagation, and the default carrier is the W3C Trace Context traceparent header, a W3C Recommendation since November 23, 2021. Its format is version-traceid-parentid-flags, for example 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01, where the last byte’s rightmost bit means “sampled.”

Propagation is the part that makes distributed tracing work and the part that breaks most often. One service that drops the header, or one queue that doesn’t carry it, and the trace splits into two unrelated pieces.

What does OpenTelemetry look like in code?

The SDK needs a package install, so here is the mechanism instead, in Python 3 standard library only. Two “services” run in one process. The checkout service starts a server span, makes a client span for its call to inventory, and puts a traceparent header on the call. The inventory service parses the header and continues the same trace. A contextvars variable plays the role of the SDK’s current-span context. The export is shaped like OTLP/JSON, with span kinds using the numbers from the OTLP trace proto (2 is server, 3 is client).

# tracer.py: a 40-line tracer. Parent/child spans, W3C traceparent propagation
# between two "services", and an OTLP/JSON-shaped export. Python 3 stdlib only.
import contextvars, json, random, time

rng = random.Random(7)                      # seeded so the ids are reproducible
current = contextvars.ContextVar("span", default=None)
finished = []
SERVER, CLIENT = 2, 3                       # SpanKind values from the OTLP proto

class Span:
    def __init__(self, name, kind, attrs, trace_id=None, parent_id=None):
        parent = current.get()
        self.trace_id = trace_id or (parent.trace_id if parent else f"{rng.getrandbits(128):032x}")
        self.parent_id = parent_id or (parent.span_id if parent else "")
        self.span_id, self.name, self.kind, self.attrs = f"{rng.getrandbits(64):016x}", name, kind, attrs
    def __enter__(self):
        self.start, self.token = time.time_ns(), current.set(self); return self
    def __exit__(self, *exc):
        self.end = time.time_ns(); current.reset(self.token); finished.append(self)
    def traceparent(self):                  # version-traceid-parentid-flags (01 = sampled)
        return f"00-{self.trace_id}-{self.span_id}-01"

def inventory_service(headers):             # service B: continue the caller's trace
    _, trace_id, parent_id, _ = headers["traceparent"].split("-")
    with Span("GET /inventory/:sku", SERVER, {"http.request.method": "GET"}, trace_id, parent_id):
        with Span("SELECT stock", CLIENT, {"db.system.name": "postgresql"}):
            time.sleep(0.002)

with Span("POST /checkout", SERVER, {"http.request.method": "POST"}):        # service A
    with Span("GET", CLIENT, {"http.request.method": "GET", "server.address": "inventory"}) as call:
        headers = {"traceparent": call.traceparent()}
        print("outgoing header:", headers["traceparent"])
        inventory_service(headers)

print("export (one OTLP/JSON span per line, timestamps omitted):")
for s in finished:
    print(json.dumps({"traceId": s.trace_id, "spanId": s.span_id, "parentSpanId": s.parent_id,
                      "name": s.name, "kind": s.kind,
                      "attributes": [{"key": k, "value": {"stringValue": v}} for k, v in s.attrs.items()]}))
assert len({s.trace_id for s in finished}) == 1, "all four spans share one trace"

Output (Python 3.13.11):

outgoing header: 00-6513270e269e0d37f2a74de452e6b438-d23f0824128b2f33-01
export (one OTLP/JSON span per line, timestamps omitted):
{"traceId": "6513270e269e0d37f2a74de452e6b438", "spanId": "9531985d5d9dc9f8", "parentSpanId": "1818e811892f902b", "name": "SELECT stock", "kind": 3, "attributes": [{"key": "db.system.name", "value": {"stringValue": "postgresql"}}]}
{"traceId": "6513270e269e0d37f2a74de452e6b438", "spanId": "1818e811892f902b", "parentSpanId": "d23f0824128b2f33", "name": "GET /inventory/:sku", "kind": 2, "attributes": [{"key": "http.request.method", "value": {"stringValue": "GET"}}]}
{"traceId": "6513270e269e0d37f2a74de452e6b438", "spanId": "d23f0824128b2f33", "parentSpanId": "0c5c7fd0a6a3a450", "name": "GET", "kind": 3, "attributes": [{"key": "http.request.method", "value": {"stringValue": "GET"}}, {"key": "server.address", "value": {"stringValue": "inventory"}}]}
{"traceId": "6513270e269e0d37f2a74de452e6b438", "spanId": "0c5c7fd0a6a3a450", "parentSpanId": "", "name": "POST /checkout", "kind": 2, "attributes": [{"key": "http.request.method", "value": {"stringValue": "POST"}}]}

Read the IDs. The span ID inside the outgoing header (d23f...) is the client span in checkout, and it shows up again as the parentSpanId of the server span in inventory. That one string is the only thing linking the two services. Spans export in the order they finish, so the database call comes first and the root comes last; a backend rebuilds the tree from parent IDs, not from order.

A real SDK adds what the toy skips: start and end timestamps in nanoseconds (start_time_unix_nano and end_time_unix_nano in the proto), resource attributes such as service.name, sampling, batching, status codes, events and the binary Protobuf encoding.

Traces vs metrics vs logs: which signal answers what?

Metrics are cheap aggregates: request rate, error rate, latency histograms, queue depth. They tell you that something is wrong and when it started. Traces tell you where: which hop in which request spent the time or threw the error. Logs carry the detail a developer wrote down at that line.

OTel’s contribution is correlation. When a log record is written inside an active span, the SDK can stamp it with the trace and span IDs, so you can jump from a slow trace to the exact log lines it produced. The signals are not equally mature everywhere, though. The status page currently lists Python with traces and metrics Stable and logs in Development, JavaScript the same, and Java Stable on all three. Check your language before you plan a migration around OTel logs.

Where does OpenTelemetry break?

Cardinality. Every unique attribute combination on a metric is a separate time series. Put a user ID or a raw URL on a metric and the bill explodes. The HTTP conventions’ rule against using the URI path as a span name exists for the same reason.

Volume. Tracing every request at scale is expensive. You’ll need a sampling decision, either up front in the SDK (cheap, blind) or after the fact in the Collector (sees errors and slow traces, but must buffer whole traces).

Broken propagation. Async jobs, message queues and third-party services drop context unless someone carries it explicitly. Expect partial traces until you fix each boundary.

Sensitive data. Auto-instrumentation records URLs, SQL statements and headers. From the privacy-compliance seat I had at Walmart, this is the line I’d circle: telemetry is a data pipeline that copies production data into another system with its own retention and its own access list. The Collector’s processors are the right place to drop or hash attributes before anything leaves your network.

Collector stability is uneven. The status page describes the Collector as “mixed, since core collector components currently have mixed stability levels.” Pin versions and read each component’s README for its own stability level.

Why does OpenTelemetry matter for AI systems?

An AI agent is a chain of model calls and tool calls, and when one is slow or wrong you need the same thing you need for microservices: a tree of timed operations with inputs and outputs attached. OTel has GenAI semantic conventions for exactly this, maintained in their own repository, though I’d treat them as moving until they’re marked Stable. Long-running agent loops built on durable execution produce traces that span hours and restarts, which makes propagation discipline even more important. If you’re evaluating agents, traces are also the raw material; see how to evaluate AI agents.

Below the application, eBPF tools can produce telemetry without touching code, by watching syscalls and network traffic from the kernel. They complement SDK instrumentation; they don’t see your business attributes.

What I would do

  1. Instrument with the OTel API and SDK, never a vendor’s proprietary agent API. Switching backends then means changing an exporter, not your code.
  2. Send OTLP to a Collector next to each service, not straight to the vendor. Do filtering, redaction and sampling there.
  3. Set service.name and deployment environment as resource attributes on day one. Unlabeled telemetry is close to useless.
  4. Start with auto-instrumentation for HTTP, gRPC and database clients, then add manual spans only around business operations you’d want to see in an incident.
  5. Use semantic convention names exactly. Custom names for standard things break every prebuilt dashboard.
  6. Review attributes for personal data before production, the same way you’d review a new analytics event. If platform engineering owns the Collector, that review belongs in the golden path.

FAQ

Is OpenTelemetry a replacement for Prometheus or Jaeger?

No. OTel produces and transports telemetry; Prometheus and Jaeger store and query it. The Collector can receive Prometheus and Jaeger formats and export to them.

What is OTLP?

The OpenTelemetry Protocol: the wire format for traces, metrics and logs over gRPC (port 4317) or HTTP (port 4318), with Protobuf payloads in binary or JSON.

Do I need the OpenTelemetry Collector?

Not to start. The docs say sending directly to a backend can be enough for small setups. In production I’d run one, because it moves retries, batching and redaction out of your application.

What is the difference between OpenTelemetry and OpenTracing?

OpenTracing was a tracing-only API. In 2019 it merged with OpenCensus to form OpenTelemetry, and both earlier projects were frozen.

Is OpenTelemetry production-ready?

Traces and metrics are Stable in most major languages, and the CNCF graduated the project in May 2026. Logs and profiles vary by language, so check the status page for yours.

Sources

Get new posts in your inbox

© 2026 Malhar Ujawane. Built with Astro.