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.
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.
| Tool | What it does |
|---|---|
| OpenTelemetry API | Standard 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:
| Responsibility | What it does |
|---|---|
| Buffering / Batch | Groups signals before export (saves network) |
| Retry | Retries after a network failure |
| Head sampling | Decides, as soon as the trace is created, which one to keep (ratio, parent-based...); tail sampling belongs to the Collector |
| Propagation | Injects/extracts the context (trace-id) between services |
| Export | Sends the signals to OTLP (or another format) |
The SDK is where you configure:
# Service identityOTEL_SERVICE_NAME=checkout-apiOTEL_RESOURCE_ATTRIBUTES=service.version=1.2.3,deployment.environment=production
# OTLP export to the CollectorOTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# Sampling (10% of traces)OTEL_TRACES_SAMPLER=parentbased_traceidratioOTEL_TRACES_SAMPLER_ARG=0.1Sampling 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.
| Language | How it works |
|---|---|
| Java | JVM agent: -javaagent:opentelemetry-javaagent.jar |
| Python | Wrapper: opentelemetry-instrument python app.py |
| Node.js | Require: --require @opentelemetry/auto-instrumentations-node/register |
| .NET | Runtime hooks (variable CORECLR_ENABLE_PROFILING) |
| Go | No agent as in Java: eBPF instrumentation (OBI, OpenTelemetry eBPF Instrumentation) or instrumentation libraries (otelhttp...) added to the code |
| PHP | PHP 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 → CollectorWhy OTLP to a Collector (and not directly to the backend)?
| Advantage | Explanation |
|---|---|
| Decoupling | Your app only "knows" one OTLP endpoint |
| Flexibility | Switch backend (Jaeger → Tempo) without recoding |
| Governance | Filtering, redaction, routing centralized |
| Resilience | The 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:
| Function | Example |
|---|---|
| Normalize | Convert several formats into one |
| Enrich | Add Kubernetes metadata (namespace, pod, node) |
| Filter | Exclude health checks, internal routes |
| Redact | Mask tokens, emails, sensitive data |
| Route | Traces → Tempo, Metrics → Mimir, Logs → Loki |
| Buffer | Queue + 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.
| Layer | Example | Where it lives | What it is for |
|---|---|---|---|
| API / Facade | OTel API, Micrometer | In the code | Stable interface, app calls |
| SDK | OTel SDK Java/Python/Node | In the runtime | Collection, batching, sampling, export |
| Auto-instrumentation | Java Agent, Python distro | Around the app | Automatic spans/metrics without touching the code |
| Exporter | OTLP exporter | In the app | Signal output |
| Collector | OTel Collector | Infra | Governance, 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.
2. Modern standard (recommended)
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.
- 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.
- 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 code | Auto-instrumentation + OTLP → Collector |
| Business context | Manual spans via API + SDK |
| Decouple from the backend | OTLP exporter to Collector |
| Standardize across languages | OpenTelemetry everywhere |
| Just JVM metrics | Micrometer (but OTel remains compatible) |
| Migrate from legacy | OTel 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.
| Step | What to do |
|---|---|
| 1. Identity | OTEL_SERVICE_NAME, service.version, deployment.environment |
| 2. Propagation | W3C Trace Context (traceparent) enabled |
| 3. Business spans | 3-5 key operations (checkout, payment, PDF generation) |
| 4. RED metrics | Rate (requests per second), Errors, Duration (p50/p95/p99 percentiles) |
| 5. Redaction | Mask tokens, emails, personal data (PII) before export |
| 6. Sampling | Indicative 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-pattern | Consequence | Solution |
|---|---|---|
| Unique IDs in tags/labels | Cardinality explosion, costs | Use categories (status, region) |
| Tracing everything without sampling | Performance overhead, storage costs | A starting ratio (10 to 20%, indicative) then tail sampling in the Collector |
| Overly verbose spans | Noise, hard to use | 5-10 attributes max per span |
| No local validation | Bugs found in prod | Export to console/debug in dev |
Ignoring service.name | Anonymous, unusable traces | Always define the identity |
| Exporting directly to the backend | Coupling, no governance | Go 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