Pcornel
Browse topics
Options
Recent
Favorites
Observability · Technical reference

OpenTelemetry Auto-Instrumentation

Direct answer

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.

When to use this

Use it to get telemetry quickly from existing services.

First 30 seconds

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.

Operational verification

agent loaded → libraries patched → spans/metrics → exporter

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
OpenTelemetry / Prometheus / Grafana / common metrics-log-trace pipelines
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformOpenTelemetry / Prometheus / Grafana / common metrics-log-trace pipelines
Scope / prerequisiteUse it to get telemetry quickly from existing services.
What next?2 suggested next steps
Evidence0
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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.

Key points

Auto-instrumentation covers common libraries; add manual spans for business logic. Check agent version compatibility and overhead. Disable noisy instrumentations.

Key checks
  • java -javaagent:opentelemetry-javaagent.jar -jar app.jar — first check for this topic
  • curl -s localhost:9090/-/ready — Prometheus ready
  • curl -s 'localhost:9090/api/v1/query?query=up' — scrape targets up/down
  • promtool 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

LanguageHow
Java-javaagent:opentelemetry-javaagent.jar
.NETOpenTelemetry .NET automatic instrumentation
Pythonopentelemetry-instrument python app.py
Node.js--require @opentelemetry/auto-instrumentations-node/register
GoeBPF-based (OBI) or manual SDK
KubernetesOpenTelemetry 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 getYou still need to add
Spans for inbound HTTP/gRPC, outbound HTTP, database clients, messaging librariesSpans 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 librariesPropagation across unsupported libraries or custom protocols
Runtime metrics (GC, threads) in many languagesDomain 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.
Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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
Terminology layer

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.

Aliases that resolve here
opentelemetry auto-instrumentationopentelemetry auto instrumentationotel operator inject
Confirmation

Confirm action

Continue?