Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Observability instrumentation

15 min read
Improve this page

Instrumentation is the first step of the observability pipeline: it is the code that generates the signals (metrics, logs, traces) inside your applications themselves. A backend can only display what instrumentation has emitted: a trace without service.name stays anonymous whatever dashboard sits behind it.

But "instrumenting" is not a single tool. It is a stack of layers that goes from your code to the backend (the tool that stores and displays the signals). This page explains how these building blocks fit together.

Two terms come up everywhere. A span is a timed operation (an HTTP call, an SQL query); a trace is the set of spans of one request, from service to service.

The instrumentation layers

Overview

Read the diagram from top to bottom, in the direction the signals flow. Each layer has its own configuration point, and that is what matters to you: a service naming problem is fixed in the SDK, a volume problem in sampling, a sensitive data problem in the Collector. Knowing which layer a symptom belongs to saves you from changing application code for a setting that lives elsewhere.

In the application, your code calls the API, the SDK handles batching, sampling and propagation, then the OTLP exporter sends over gRPC or HTTP to the infrastructure Collector, which routes, masks and enriches before delivering to Tempo, Mimir and Loki.Inside the applicationInfrastructureYour codeAPI / facadetracer, meter, loggerSDKbatching, sampling, propagationOTLP exportergRPC or HTTPCollectorrouting, redaction, enrichmentBackendsTempotracesMimirmetricsLokilogsOTLP
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

The further down the pipeline you go, the more centralized the configuration is and therefore the easier to govern, but the more business context you lose: the Collector sees spans go by, it does not know that one of them is an abandoned cart.

1. API / Facade: the interface the code calls

The API provides a stable interface in the code: tracer, meter, logger. Your code calls these primitives without knowing which backend will store the data.

ToolWhat it does
OpenTelemetry APIStandard interface for traces, metrics, logs (multi-language)
Micrometer (Java)"Metrics-first" facade widely used in the Spring ecosystem

In the code, it looks like this:

# Create a span (trace)
with tracer.start_as_current_span("checkout.process") as span:
span.set_attribute("cart.items", 3)
# ... business logic
// Increment a counter (metric)
counter.add(1, Attributes.of(stringKey("status"), "success"));

2. SDK: the implementation that collects and exports

The SDK turns what the API produces into usable telemetry:

ResponsibilityWhat it does
Buffering / BatchGroups signals before export (saves network)
RetryRetries after a network failure
Head samplingDecides, as soon as the trace is created, which one to keep (ratio, parent-based...); tail sampling belongs to the Collector
PropagationInjects/extracts the context (trace-id) between services
ExportSends the signals to OTLP (or another format)

The SDK is where you configure:

Terminal window
# Service identity
OTEL_SERVICE_NAME=checkout-api
OTEL_RESOURCE_ATTRIBUTES=service.version=1.2.3,deployment.environment=production
# OTLP export to the Collector
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# Sampling (10% of traces)
OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=0.1

Sampling keeps only a share of the traces to limit cost. Here parentbased_traceidratio keeps 10% of traces, and respects the decision already made by the calling service. Because this decision is made when the trace is created, before its outcome is known, the SDK cannot target traces in error: the tail sampling of the Collector (in French) does that, and the trace fundamentals (in French) compare the two approaches.

3. Auto-instrumentation: the "zero code" approach

Auto-instrumentation automatically intercepts calls to frameworks and libraries (HTTP, DB, messaging) without changing your code.

LanguageHow it works
JavaJVM agent: -javaagent:opentelemetry-javaagent.jar
PythonWrapper: opentelemetry-instrument python app.py
Node.jsRequire: --require @opentelemetry/auto-instrumentations-node/register
.NETRuntime hooks (variable CORECLR_ENABLE_PROFILING)
GoNo agent as in Java: eBPF instrumentation (OBI, OpenTelemetry eBPF Instrumentation) or instrumentation libraries (otelhttp...) added to the code
PHPPHP extension: opentelemetry.so

These launchers read the OTEL_* variables of the block in the SDK section, including OTEL_EXPORTER_OTLP_PROTOCOL=grpc. Without it, the Java 2.x agent, Node.js auto-instrumentation and .NET auto-instrumentation send in http/protobuf: with the endpoint on port 4317, nothing reaches the Collector.

When to use it?

  • To quickly cover the essential technical spans (inbound/outbound HTTP, SQL, Redis, Kafka...)
  • On legacy code that you do not want to touch
  • As a complement to manual spans for business logic

4. Exporters: how signals leave the application

The exporter sends the signals to a destination. In 2026, the standard is:

App (SDK) → OTLP → Collector

Why OTLP to a Collector (and not directly to the backend)?

AdvantageExplanation
DecouplingYour app only "knows" one OTLP endpoint
FlexibilitySwitch backend (Jaeger → Tempo) without recoding
GovernanceFiltering, redaction, routing centralized
ResilienceThe Collector buffers if the backend is down

5. Collector: governance outside the code

The Collector is the central router of your telemetry. It receives OTLP signals and transforms/routes them to your backends.

What it does:

FunctionExample
NormalizeConvert several formats into one
EnrichAdd Kubernetes metadata (namespace, pod, node)
FilterExclude health checks, internal routes
RedactMask tokens, emails, sensitive data
RouteTraces → Tempo, Metrics → Mimir, Logs → Loki
BufferQueue + retry if the backend is unavailable

Summary: who does what?

The "Where it lives" column is the one to remember, because it tells you who has to act when a setting changes. Changing the API or the manual spans involves a developer and a redeployment. Changing the SDK is done through environment variables, so at the deployment level. Changing the Collector touches no application. This progression is exactly what makes the architecture with a Collector easier to sustain over time.

LayerExampleWhere it livesWhat it is for
API / FacadeOTel API, MicrometerIn the codeStable interface, app calls
SDKOTel SDK Java/Python/NodeIn the runtimeCollection, batching, sampling, export
Auto-instrumentationJava Agent, Python distroAround the appAutomatic spans/metrics without touching the code
ExporterOTLP exporterIn the appSignal output
CollectorOTel CollectorInfraGovernance, routing, resilience

3 typical architectures

Each environment has its constraints. Here are the three most common patterns, seen from the application. The details of the Collector deployment (gateway, agent, sidecar, high availability) are on the Collection & pipeline page (in French).

1. Quick start (POC, isolated service)

The application exports directly to the backend, with no intermediary. It is the shortest configuration to write, and the only debt it creates is the backend address written in the configuration of every service. With a single service, that is nothing. With fifteen, every backend change becomes a redeployment campaign.

  • Advantage: simple, quick to set up
  • Limit: coupled to the backend, hard to evolve
  • Limit: no centralized governance

When to use it: POC, standalone application, development environment.

All applications export to a central Collector that routes to the backends. Application configuration then boils down to a single OTLP address, identical for all services, and everything related to filtering, masking or routing leaves the code.

Three applications instrumented with the OpenTelemetry SDK send OTLP to a central Collector, which filters, samples, routes and masks before delivering to Tempo, Mimir and Loki.BackendsApplicationsOTLPOTLPOTLPApp 1OTel SDKApp 2OTel SDKApp 3OTel SDKOTel Collectorfiltering, sampling, routing, redactionTempotracesMimirmetricsLokilogs
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %
  • Advantage: decoupling between applications and backends
  • Advantage: centralized governance (filtering, masking, sampling)
  • Advantage: several backends without changing application code

When to use it: as soon as you have several services in production.

3. Kubernetes at scale (agent + gateway)

Each Kubernetes node runs an agent (a DaemonSet, that is one pod per node) that collects locally, then sends to a central gateway. This two-tier split meets two needs that a single Collector does not cover: the agent is best placed to read the node metadata and the logs of the containers running there, and it absorbs local spikes without saturating the network between nodes.

On each Kubernetes node, pods send OTLP to an agent deployed as a DaemonSet; the agents forward to a gateway replicated at least twice, which feeds Tempo, Mimir and Loki.BackendsNode 2Node 1OTLPOTLPOTLPOTLPOTLPOTLPPod APod BAgentDaemonSetPod CPod DAgentDaemonSetGatewayDeployment, 2+ replicasTempoMimirLoki
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %
  • Advantage: local collection, hence low network latency
  • Advantage: Kubernetes enrichment (namespace, pod, node)
  • Advantage: centralized routing and high availability through gateway replication

When to use it: production Kubernetes clusters, multi-tenant, platform teams.

Decision guide

This table is read by need, not by tool. Two rows almost always combine in production: auto-instrumentation covers the technical calls, manual spans add the business context that nothing automatic can guess. Choosing one against the other is a frequent mistake; they do not answer the same question.

You want...Solution
Zero codeAuto-instrumentation + OTLP → Collector
Business contextManual spans via API + SDK
Decouple from the backendOTLP exporter to Collector
Standardize across languagesOpenTelemetry everywhere
Just JVM metricsMicrometer (but OTel remains compatible)
Migrate from legacyOTel Shim for OpenTracing/OpenCensus

Minimum Viable Instrumentation

Before tracing everything, instrument the essentials:

Checklist

The six steps are ordered by dependency, not by importance. The first two condition everything else: without a service identity, your traces reach the backend anonymous, and without W3C propagation, each service creates its own trace instead of continuing the caller's, which gives traces cut into pieces that nothing links together.

StepWhat to do
1. IdentityOTEL_SERVICE_NAME, service.version, deployment.environment
2. PropagationW3C Trace Context (traceparent) enabled
3. Business spans3-5 key operations (checkout, payment, PDF generation)
4. RED metricsRate (requests per second), Errors, Duration (p50/p95/p99 percentiles)
5. RedactionMask tokens, emails, personal data (PII) before export
6. SamplingIndicative starting ratio (10 to 20%), refined afterwards

Minimal configuration

These variables are standardized by the OpenTelemetry specification: they have the same name whatever the language, which lets you inject them uniformly from a Kubernetes manifest or a docker compose file. Port 4317 corresponds to the gRPC transport; if you export over HTTP, switch to 4318 and set OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf.

The minimal configuration is the variable block of the SDK section above: the service identity (OTEL_SERVICE_NAME, OTEL_RESOURCE_ATTRIBUTES), the OTLP export to the Collector (OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_PROTOCOL) and sampling (OTEL_TRACES_SAMPLER and OTEL_TRACES_SAMPLER_ARG), to adjust according to the trace volume. Business spans, RED metrics and redaction, for their part, need code or a Collector configuration.

Mistakes to avoid

The first row of the table weighs directly on the bill. Putting a unique identifier (order ID, email address, session ID) in a metric label creates a distinct time series per value: a few thousand orders are enough to blow up the cardinality and saturate the backend. Identifiers belong in span attributes, not in metrics.

Anti-patternConsequenceSolution
Unique IDs in tags/labelsCardinality explosion, costsUse categories (status, region)
Tracing everything without samplingPerformance overhead, storage costsA starting ratio (10 to 20%, indicative) then tail sampling in the Collector
Overly verbose spansNoise, hard to use5-10 attributes max per span
No local validationBugs found in prodExport to console/debug in dev
Ignoring service.nameAnonymous, unusable tracesAlways define the identity
Exporting directly to the backendCoupling, no governanceGo through the Collector

Which guide for which instrumentation tool?

This page describes how the layers assemble and is not something you practice: the hands-on work happens in the tool guides. Each tool family points to its own.

Standards and SDKs

OpenTelemetry covers the three signals (traces, metrics, logs) with a common API and shared naming conventions. Start with the OpenTelemetry guide: the other pages of this section assume its vocabulary. If the data model (signal, context, propagation) is not yet clear, the OpenTelemetry fundamentals (in French) explain it without any tool, and signal correlation (in French) shows how to link logs, metrics and traces.

Auto-instrumentation

Each language has its own injection mechanism, summarized in the table above: JVM agent for Java, wrapper executable for Python, module loading at startup for Node.js. The OpenTelemetry guide cited above covers the concepts common to all languages, including the Java agent and the Python wrapper.

Facades and alternatives

Micrometer predates OpenTelemetry in the Spring ecosystem and is still very present in existing Java applications. It is above all a metrics facade (tracing belongs to Micrometer Tracing, a separate module), and it can export metrics over OTLP, which lets you keep it in the code while unifying the output with the rest of your telemetry. The Micrometer guide (in French) installs it on a Spring Boot application.

And after the application?

Once instrumentation works and you want to filter, enrich and route what it produces, the baton passes to the OpenTelemetry Collector. The external references to keep at hand are the list of OpenTelemetry languages and SDKs, the SDK configuration through environment variables, the Collector documentation and the Micrometer documentation.

Key takeaways

  • Direct export suits a POC, the central Collector as soon as there are several services in production, agent + gateway on Kubernetes at scale
  • Applications only know an OTLP endpoint: filtering, masking and routing live in the Collector
  • Auto-instrumentation and manual spans combine: one covers the pipes, the other the business context
  • Start with the service identity and W3C propagation, then business spans, RED metrics and sampling
  • No unique identifier in a metric label: it goes in span attributes