Use it to get telemetry quickly from existing services.
OpenTelemetry Auto-Instrumentation
OpenTelemetry auto-instrumentation adds tracing and metrics to applications without code changes using language agents (Java agent, Python/Node/.NET instrumentation) or the Kubernetes Operator.
1. Java: java -javaagent:opentelemetry-javaagent.jar -jar app.jar with OTEL_* variables.
2. Python: opentelemetry-instrument python app.py.
3. K8s: Instrumentation CR and pod annotation instrumentation.opentelemetry.io/inject-java.
4. Spans visible for HTTP/DB calls.
5. Overhead measured.
agent loaded → libraries patched → spans/metrics → exporter
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 How to verify Verify boundary
Compare the services and operations seen in traces with what the application actually calls. Add manual spans for important internal steps.
Step 2 Common failures Narrow the fault
Unsupported library versions produce no spans. Two agents (for example a vendor APM and OpenTelemetry) on one process conflict. Injection only happens when the Pod is created, so existing Pods need a restart.
Auto-instrumentation covers common libraries; add manual spans for business logic. Check agent version compatibility and overhead. Disable noisy instrumentations.
java -javaagent:opentelemetry-javaagent.jar -jar app.jar— first check for this topiccurl -s localhost:9090/-/ready— Prometheus readycurl -s 'localhost:9090/api/v1/query?query=up'— scrape targets up/downpromtool check config prometheus.yml— config valid
ReferenceWhat it is1 section · depth on demand
How it works
Agents patch supported libraries at load time to create spans and metrics. The operator mutates the Pod spec to add the agent and OTEL_ environment variables.
ReferenceImportant terms & boundaries3 sections · depth on demand
Auto-instrumentation by language
| Language | How |
|---|---|
| Java | -javaagent:opentelemetry-javaagent.jar |
| .NET | OpenTelemetry .NET automatic instrumentation |
| Python | opentelemetry-instrument python app.py |
| Node.js | --require @opentelemetry/auto-instrumentations-node/register |
| Go | eBPF-based (OBI) or manual SDK |
| Kubernetes | OpenTelemetry Operator Instrumentation resource + Pod annotation |
Add manual spans for business operations auto-instrumentation cannot see.
In depth
What zero-code instrumentation gives you — and what it does not
| You get | You still need to add |
|---|---|
| Spans for inbound HTTP/gRPC, outbound HTTP, database clients, messaging libraries | Spans for important business steps inside your code |
| Standard attributes (method, route, status, db.system) | Business attributes (order type, tenant, feature flag) |
| Context propagation across supported libraries | Propagation across unsupported libraries or custom protocols |
| Runtime metrics (GC, threads) in many languages | Domain metrics (orders placed, payments failed) |
Kubernetes: the OpenTelemetry Operator
apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata: { name: default, namespace: shop }
spec:
exporter: { endpoint: http://otel-collector.observability:4318 }
propagators: [tracecontext, baggage]
sampler: { type: parentbased_traceidratio, argument: "0.2" }
Then annotate the workload's Pod template, for example instrumentation.opentelemetry.io/inject-java: "true" (or -python, -nodejs, -dotnet, -go). The operator adds an init container with the agent and the environment variables. Pods must be restarted to pick it up, and the annotation must be on the Pod template, not on the Deployment's own metadata.
Checking it works
kubectl get pod api-7f… -o jsonpath='{.spec.initContainers[*].name}' # opentelemetry-auto-instrumentation-…
kubectl exec api-7f… -- env | grep OTEL_
Risks to manage
- Start-up time and memory rise (noticeably for the Java agent); include it in resource requests and startup probes.
- Two agents (a vendor APM plus OpenTelemetry) on one process can conflict or double-instrument; use one.
- Library versions outside the agent's supported range produce no spans silently; check the agent's supported-libraries list after upgrades.
- eBPF-based instrumentation (OBI) works without touching the process but sees less application context.
Common mistakes
- Auto-instrumentation adding overhead without sampling.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.