Skip to content

Search

Articles, tools, solutions and knowledge base guides

Start typing to search across articles, tools and apps.

OpenTelemetry basics: logs, metrics and traces in one observability architecture

OpenTelemetry standardizes how applications generate, describe, transport and process telemetry. It is not a database or dashboard product. It provides specifications, APIs, SDKs, OTLP, semantic conventions and the Collector so traces, metrics and logs can pass through a shared telemetry layer regardless of the observability backend.

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

What OpenTelemetry is and is not

OpenTelemetry is an open source, vendor- and tool-agnostic observability framework for generating, collecting and exporting telemetry such as traces, metrics and logs. It is not an observability backend. [1]

Storage, querying, dashboards and visualization are intentionally left to other tools, allowing the same instrumentation layer to work with different backends. [1]

Traces, metrics, logs and baggage answer different questions

SignalWhat it describesTypical question
TracesA request path across componentsWhere and why did this request slow down?
MetricsAggregated system measurementsIs latency or error rate increasing?
LogsDetailed event recordsWhat exactly happened at this moment?
BaggageContext propagated across processesHow can extra context travel with a request?

OpenTelemetry separates signals because each describes the system from a different angle. A trace follows a request, a metric is a runtime measurement and a log records an event. [2]

Baggage carries key-value context alongside execution context. It can be consumed downstream but is not an OTLP-exported signal like traces, metrics and logs. [2][16]

Trace, span and distributed request context

A distributed trace is built from spans representing units of work. Context propagation carries trace ID and parent information across services so new spans belong to the same trace. [3]

This is what lets a request crossing several services be analyzed as one causal flow rather than unrelated timings. [3]

Metrics: cheap numbers until cardinality explodes

Metrics represent measurements such as request counts, operation duration, request sizes, CPU usage or active operations. [12]

Cardinality is the number of unique attribute combinations. OpenTelemetry warns that values such as user IDs or raw URL paths can create high cardinality and memory pressure. The Metrics SDK has a cardinality limit and overflow is represented with otel.metric.overflow=true. [12]

Logs become more useful with trace ID and span ID

The OpenTelemetry log model can include TraceId and SpanId in LogRecord, allowing a backend to connect a log to the trace and span that produced it. [13]

LogRecords can also carry Resource information, giving logs the same source identity model used by traces and metrics. [13]

Context propagation and baggage: what crosses service boundaries

Context propagation carries correlation data such as trace ID, parent ID and trace flags between execution units. [3]

Baggage can propagate additional key-value data downstream and make it available to traces, metrics or logs. Because it crosses service boundaries, it should not be used casually for secrets or unnecessary sensitive data. [2][3]

Resources and Semantic Conventions create a shared telemetry language

A Resource describes the entity producing telemetry, such as a service, process, container, pod or cloud environment. OpenTelemetry recommends setting service.name explicitly because SDKs can otherwise use unknown_service. [8]

Semantic Conventions define common attribute and operation names for traces, metrics, logs, resources and other telemetry domains. [7]

Code-based and zero-code instrumentation complement each other

OpenTelemetry supports code-based instrumentation through APIs and SDKs and zero-code approaches. Depending on the language, zero-code may use agents, monkey patching, bytecode manipulation or eBPF. [9][10]

Zero-code is useful for common libraries and application boundaries such as HTTP, database or messaging. Custom business logic usually requires code-based instrumentation when business spans or custom metrics are needed. [9][10]

OTLP: a common telemetry transport protocol

OpenTelemetry Protocol defines encoding, transport and delivery between telemetry sources, Collectors and backends. OTLP is stable for traces, metrics and logs. [6]

OTLP defines gRPC and HTTP transports. OTLP/HTTP can carry binary Protobuf or JSON-mapped Protobuf, with standard paths including /v1/traces, /v1/metrics and /v1/logs. [6]

Collector: receiver -> processor -> exporter

ComponentRole
ReceiverReceives or scrapes telemetry.
ProcessorTransforms, filters, enriches, batches or samples data.
ExporterSends data to a backend or another Collector.
ConnectorBridges two pipelines as exporter and receiver.
ExtensionAdds capabilities outside the core data path.

The OpenTelemetry Collector can receive telemetry, process it and export it to one or more destinations. A pipeline has one or more receivers, optional processors and one or more exporters. [4]

Receivers ingest data, processors transform, filter or sample it, exporters send it onward, connectors bridge pipelines and extensions provide auxiliary capabilities such as health endpoints. [4][5]

Direct export, agent, gateway and agent-to-gateway

PatternWhen it fitsMain trade-off
SDK -> backendSmall system and simple start.Application owns export destination configuration.
SDK -> local agentTelemetry per host, pod or workload.More Collector instances to operate.
SDK -> central gatewayCentral processing and one OTLP endpoint.Gateway becomes critical infrastructure.
Agent -> gatewayLarger environments, sampling and multiple backends.More complexity but better separation of concerns.

A small application can export OTLP directly to a backend, but a Collector centralizes processing, routing and destination configuration. [1][4]

At larger scale, agents can run near workloads while gateways centralize heavier tasks such as sampling, batching and export. OpenTelemetry describes agent-to-gateway as a pattern for separation of concerns, cost control and stable egress. [15]

Sampling: fewer traces do not necessarily mean less insight

Sampling reduces the number of traces processed and exported. OpenTelemetry describes it as one way to lower observability cost while retaining representative data. [11]

The Collector includes probabilistic and tail sampling processors. Tail sampling can decide after more of a trace is visible, but the architecture must route spans of the same trace consistently. [11][15]

Connecting metrics to traces with exemplars

An exemplar is an individual metric measurement associated with context and can include trace ID and span ID. One use is navigating from an aggregated metric to a representative trace. [14]

This can connect a latency spike in a histogram to a specific request, provided the pipeline and backend preserve and support exemplars. [14]

Common OpenTelemetry implementation mistakes

A common mistake is treating OpenTelemetry as a backend rather than a telemetry layer. Another is attaching high-cardinality attributes to metrics, which can increase SDK memory and backend cost. [1][12]

Other problems include inconsistent service.name, unstable attribute naming and uncontrolled sampling. Resources, Semantic Conventions and sampling exist to make those choices explicit. [7][8][11]

A minimal production architecture

A practical starting point is HTTP and dependency instrumentation, explicit service.name, trace-context propagation and OTLP export to a Collector. The Collector can then route traces, metrics and logs to chosen backends. [3][4][6][8]

Tail sampling, transformations, additional exporters and agent-to-gateway architecture can be added later. OpenTelemetry does not require every component on day one. [4][15]

  • Set a unique service.name for every logical service.
  • Use automatic instrumentation for common libraries and add custom instrumentation where business context matters.
  • Propagate trace context across every service boundary.
  • Use OTLP as the common transport where practical.
  • Keep separate Collector pipelines for traces, metrics and logs.
  • Control metric cardinality before high-volume production rollout.
  • Introduce sampling after measuring real telemetry volume and diagnostic needs.
  • Monitor the Collector itself and treat its configuration as production infrastructure.

OpenTelemetry is most useful when treated as a shared telemetry layer rather than another monitoring product. Traces show request flow, metrics describe aggregate system behavior, logs preserve event detail, and context propagation plus shared resource attributes make those signals correlatable. A good architecture starts with a small signal set, stable service naming, OTLP and a Collector, then adds sampling, transformations and additional backends only when needed.

OpenTelemetry Observability OTLP Traces Metrics Logs OpenTelemetry Collector Distributed Tracing Monitoring DevOps

Frequently asked questions

Does OpenTelemetry replace Prometheus, Grafana or Jaeger?

No. OpenTelemetry is not a storage or visualization backend. It can generate, collect and export telemetry to different backends. [1]

Must traces, metrics and logs be deployed together?

No. Signals are independent although they can share context propagation and resource identity. They can be adopted incrementally. [2][3]

Is OTLP stable?

Yes for traces, metrics and logs. Profiles remain under development. [6][16]

Is the Collector mandatory?

No. SDKs can export directly, but the Collector centralizes processing, routing and backend changes. [1][4]

What is the difference between a trace and a span?

A trace represents the end-to-end flow while a span represents one unit of work within it. Context propagation connects spans across services. [3]

How do I connect a log to a request?

A LogRecord can contain TraceId and SpanId, enabling the backend to associate it with the matching trace and span. [13]

Can OpenTelemetry be used without code changes?

Partly. Zero-code instrumentation can cover libraries and runtimes, while custom business logic generally needs code-based instrumentation. [9][10]

What is OTLP?

OpenTelemetry Protocol transports telemetry between sources, Collectors and backends over gRPC or HTTP. [6]

Why is service.name important?

The service.name resource attribute identifies a logical service. OpenTelemetry recommends setting it explicitly instead of relying on unknown_service. [8]

What is metric cardinality?

It is the number of unique metric attribute combinations. High cardinality increases Metrics SDK memory use and usually backend cost. [12]

How do head and tail sampling differ?

Head sampling decides early, while tail sampling requires more of the trace before deciding. The Collector supports probabilistic and tail sampling processors. [11][15]

Does OpenTelemetry eliminate vendor lock-in completely?

It is vendor- and tool-agnostic and reduces coupling in instrumentation, but backend-specific queries, dashboards and features can still create dependencies outside OpenTelemetry. [1]

Sources and references

  1. OpenTelemetry, What is OpenTelemetry?↩1↩2↩3↩4↩5↩6↩7
  2. OpenTelemetry, Signals↩1↩2↩3↩4
  3. OpenTelemetry, Context propagation↩1↩2↩3↩4↩5↩6↩7
  4. OpenTelemetry Collector, Architecture↩1↩2↩3↩4↩5↩6
  5. OpenTelemetry Collector, Components↩
  6. OpenTelemetry, OTLP Specification↩1↩2↩3↩4↩5
  7. OpenTelemetry, Semantic Conventions↩1↩2
  8. OpenTelemetry, Resources↩1↩2↩3↩4
  9. OpenTelemetry, Instrumentation↩1↩2↩3
  10. OpenTelemetry, Zero-code instrumentation↩1↩2↩3
  11. OpenTelemetry, Sampling↩1↩2↩3↩4
  12. OpenTelemetry, Metrics↩1↩2↩3↩4
  13. OpenTelemetry, Logging specification↩1↩2↩3
  14. OpenTelemetry, Metrics data model - Exemplars↩1↩2
  15. OpenTelemetry Collector, Agent-to-gateway deployment pattern↩1↩2↩3↩4
  16. OpenTelemetry, Specification Status Summary↩1↩2

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