Skip to content

Search

Articles, tools, solutions and knowledge base guides

Start typing to search across articles, tools and apps.

OpenTelemetry from the ground up: traces, metrics and logs in one observability architecture

OpenTelemetry is not a dashboarding product or another monitoring backend. It is a vendor-neutral set of APIs, SDKs, protocols and components for generating, processing and exporting telemetry. Its real value appears when traces, metrics and logs describe the same request with the same context, so an operator can move from an alert to a trace and from that trace to correlated logs and service metadata.

Published Written by Reading time 23 min read
On this page Contents: quick navigation between sections

What OpenTelemetry actually is

OpenTelemetry is designed to generate, collect, process and export telemetry independently of a specific backend. It supports traces, metrics, logs and baggage. [1]

It is not itself the observability backend. Telemetry can be sent to a Collector and then forwarded to one or more analysis systems. [9][10]

That separation helps reduce vendor lock-in at the application-instrumentation layer.

Trace and span: seeing an entire request

A trace represents the path of a request through a system, while a span represents one unit of work such as an HTTP request, database query or downstream service call. [2]

A span can include a name, trace ID, span ID, parent span ID, timestamps, attributes, events, links and status. [2]

Parent-child relationships let you reconstruct the execution tree and identify where time was spent.

Example trace across three services

Example trace with correctly shaped identifiers

POST /api/orders            trace_id=4bf92f3577b34da6a3ce929d0e0e4736
└─ POST /orders             span_id=00f067aa0ba902b7
   ├─ db.insert order       span_id=7a1f5c3d8e2b4a60
   └─ POST /payments        span_id=b7ad6b7169203331
      └─ POST bank-api      span_id=3f6b5c4d2a1e9087

Consider a POST /orders request. Frontend creates the root span, the orders service calls payments, and payments calls a bank API. All spans share the same trace ID but have different span IDs. [2][5]

The identifiers below use valid shapes: a Trace ID has 32 hexadecimal characters and a Span ID has 16. The example assumes the first server span is created at the API layer and trace context is then propagated downstream. [2][5]

Context propagation connects services

Context propagation carries trace context across process and service boundaries. OpenTelemetry documents propagation of Trace ID and Parent ID through headers such as traceparent. [5]

A receiving service extracts the context, creates a child span and injects updated context into the next outbound request. [5]

Without correct propagation, each service would create a separate trace and distributed tracing would lose most of its value.

Metrics: Counter, Gauge and Histogram

OpenTelemetry defines multiple metric instruments. Counter accumulates upward values, UpDownCounter can increase and decrease, Gauge represents a current value, and Histogram aggregates distributions such as request latency. [3]

Request count fits Counter, active work items fit UpDownCounter or Gauge, and latency fits Histogram. [3]

Metrics are ideal for dashboards, alerts and trends, but they do not by themselves reveal the full path of one request.

Logs and trace correlation

Example application JSON log with trace context

{
  "timestamp": "2026-11-18T14:20:31.234Z",
  "severity": "ERROR",
  "body": "Payment timeout",
  "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
  "span_id": "b7ad6b7169203331"
}

The OpenTelemetry log model allows LogRecords to carry TraceId and SpanId, making it possible to navigate from a log entry directly to the related trace. [4]

This is an example of a normal structured JSON log using correlation-field naming recommended for non-OTLP log formats. In the logical OpenTelemetry model these correspond to TraceId and SpanId, while service.name belongs to the Resource and should be set separately. [4][6]

Resources: where telemetry comes from

A Resource describes the entity producing telemetry, for example a service, process, container, Kubernetes pod or host. [6]

One of the most important attributes is service.name. SDKs may default to unknown_service, so setting it explicitly through code or OTEL_SERVICE_NAME is recommended. [6]

Consistent resources make filtering by service, version, environment, region and instance far easier.

Semantic Conventions: a shared telemetry language

OpenTelemetry Semantic Conventions define standard names for common operations and attributes, including HTTP, databases, messaging and resource metadata. [7]

They allow services written in different languages to emit semantically comparable telemetry. [7]

Before inventing custom attribute names, check whether an appropriate semantic convention already exists.

OTLP: a common export protocol

OTLP defines the encoding, transport and delivery of telemetry between sources, Collectors and backends. It is stable for traces, metrics and logs. [9]

The specification defines OTLP/gRPC and OTLP/HTTP with Protocol Buffers payloads. Default ports are 4317 for gRPC and 4318 for HTTP. [9]

OTLP/HTTP uses paths such as /v1/traces, /v1/metrics and /v1/logs. [9]

OTLP/HTTP can carry Protobuf payloads in either binary form or the JSON mapping. The default paths are /v1/traces, /v1/metrics and /v1/logs. [9]

Collector: receiver, processor and exporter

A Collector pipeline is built from receivers, processors and exporters. Receivers ingest data, processors transform or filter it, and exporters send it to destinations. [10]

Separate pipelines can handle traces, metrics and logs. [10]

The Collector moves telemetry logic outside application code, including routing, batching, filtering and sampling.

Collector configuration example

Minimal collector.yaml for local testing

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 127.0.0.1:4317
      http:
        endpoint: 127.0.0.1:4318

processors:
  batch:

exporters:
  debug:
    verbosity: basic

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [debug]
    metrics:
      receivers: [otlp]
      processors: [batch]
      exporters: [debug]
    logs:
      receivers: [otlp]
      processors: [batch]
      exporters: [debug]

The configuration below is intended for local testing: the receiver listens only on 127.0.0.1, and the debug exporter prints telemetry instead of sending it to an external backend. In production, replace it with an appropriate OTLP exporter and configure TLS, authentication and the real endpoint. [10]

Auto-instrumentation and manual instrumentation

OpenTelemetry supports combining auto-instrumentation with manual instrumentation. Auto-instrumentation can create spans for frameworks and libraries automatically, while manual instrumentation adds business context that generic libraries cannot know. [11]

In Node.js, auto-instrumentation packages can be used while custom spans and metrics are added through the API. [11]

A practical approach is to start with auto-instrumentation and add manual spans only around important business operations.

Sampling: you do not always need 100% of traces

OpenTelemetry describes sampling as a way to reduce the number of traces processed and exported in high-volume systems. [8]

Head sampling decides early, while tail sampling can consider trace outcome such as an error or high latency before deciding whether to retain the trace. [8][12]

When tail sampling is used in a scaled gateway tier, spans from the same trace must be routed so the sampling decision sees the necessary trace data. [12]

Agent, gateway or both

The Collector can run as an agent near the application or as a centralized gateway. Larger environments often combine both models. [12]

Agents simplify local collection, while gateways centralize heavier processing, batching, sampling, routing and backend credentials. [12]

An agent-to-gateway design also allows the gateway tier to scale independently from application workloads.

How to introduce OpenTelemetry without chaos

Operational questionBest starting signalNext step
Is the system getting slower?MetricsOpen a trace for a slow request
Which service slows the request?TraceInspect the slow span and correlated logs
Why did this request fail?Trace + LogsInspect error span, logs and attributes
Does the issue affect one version?Resources + MetricsFilter by service.version

Start by defining a shared resource model and service naming. Then add traces for critical request paths, metrics for service-level indicators and logs correlated through trace context.

Once the telemetry model is stable, introduce the Collector, centralized OTLP, a sampling policy and semantic conventions. Do not start by instrumenting every function.

The goal is to answer operational questions: which service slows a request, where an error increase originates, and whether a problem affects one deployment or the whole system.

  • Set an explicit service.name for each service.
  • Propagate W3C trace context across every service boundary.
  • Use semantic conventions before inventing custom names.
  • Correlate logs with trace_id and span_id.
  • Use Histogram for latency rather than ad hoc log buckets.
  • Export through OTLP to a Collector instead of binding application code directly to one vendor.
  • Introduce sampling only after understanding volume and diagnostic goals.
  • Monitor the Collector itself because it is part of the telemetry path.

OpenTelemetry is best treated as a shared telemetry layer across the architecture rather than as a single product. Applications generate signals through SDKs or auto-instrumentation, context moves across service boundaries, Collectors receive and process the data, and observability backends store, analyze and visualize it. A consistent resource model, semantic conventions, sampling strategy and trace_id correlation make traces, metrics and logs work as one coherent operational view.

OpenTelemetry Observability Distributed Tracing Metrics Logs OTLP OpenTelemetry Collector Context Propagation Sampling Semantic Conventions Tracing Monitoring

Frequently asked questions

Is OpenTelemetry a monitoring system?

No. It generates, collects, processes and exports telemetry; storage and analysis are handled by a backend. [1][9][10]

Do I need traces, metrics and logs at once?

No. They can be introduced gradually, although correlation increases their value. [1][4]

What is a span?

A span is one unit of work in a trace with timing, attributes, events, status and span context. [2]

How do logs connect to traces?

A LogRecord can contain TraceId and SpanId, allowing a backend to link the log to a specific span. [4]

What is service.name?

It is a Resource attribute identifying the logical service name, and OpenTelemetry recommends setting it explicitly. [6]

Is OTLP stable?

Yes for traces, metrics and logs. Profiles are still in development. [9]

What is the difference between Counter and Histogram?

Counter accumulates a value, while Histogram aggregates a value distribution such as request latency. [3]

Is auto-instrumentation enough?

It is a strong starting point, but manual instrumentation adds business context that generic libraries cannot know. [11]

Why use the Collector?

It receives, processes and exports telemetry while centralizing batching, filtering, routing and sampling. [10]

Do I need to export 100% of traces?

No. Sampling can reduce volume, especially in high-throughput systems. [8]

What does agent-to-gateway provide?

It combines local collection with centralized processing and routing. [12]

Are semantic conventions mandatory?

Not every custom attribute must come from a standard, but using existing conventions improves consistency across services and languages. [7]

Sources and references

  1. OpenTelemetry, Signals↩1↩2↩3
  2. OpenTelemetry, Traces↩1↩2↩3↩4↩5
  3. OpenTelemetry, Metrics↩1↩2↩3
  4. OpenTelemetry Specification, Logs↩1↩2↩3↩4
  5. OpenTelemetry, Context propagation↩1↩2↩3↩4
  6. OpenTelemetry, Resources↩1↩2↩3↩4
  7. OpenTelemetry, Semantic Conventions↩1↩2↩3
  8. OpenTelemetry, Sampling↩1↩2↩3
  9. OpenTelemetry Protocol (OTLP) Specification↩1↩2↩3↩4↩5↩6↩7
  10. OpenTelemetry Collector, Configuration↩1↩2↩3↩4↩5↩6
  11. OpenTelemetry JavaScript, Instrumentation↩1↩2↩3
  12. OpenTelemetry Collector, Agent-to-gateway deployment pattern↩1↩2↩3↩4↩5

Was this helpful?

Get new articles by email

One short email per new Learning article. No spam, unsubscribe in one click.

We only use your email to send new articles. No third-party sharing.

Back to Learning