Skip to content

Zero-code Agents and Automatic Instrumentation: OTCA practice questions

Zero-code instrumentation adds OpenTelemetry to an application without editing its source. It is usually installed as an agent or something agent-like, and the mechanism depends on the language: bytecode manipulation in Java, monkey patching in Python, and eBPF for some Go and polyglot setups.

By Ibrahim Yesilay · Published · Updated

Independent community practice, not affiliated with or endorsed by CNCF or The Linux Foundation.

What Zero-code Agents and Automatic Instrumentation covers in OTCA

Zero-code instrumentation adds OpenTelemetry to an application without editing its source. It is usually installed as an agent or something agent-like, and the mechanism depends on the language: bytecode manipulation in Java, monkey patching in Python, and eBPF for some Go and polyglot setups. Agents typically instrument the libraries an application uses, such as inbound requests, outbound HTTP calls, database clients and message queues. The application's own business logic is not instrumented automatically; for that you add code-based instrumentation on top.

Agents are configured mostly through the standard OTEL_ environment variables, plus language-specific options. A service name is the minimum useful setting, and exporters, propagators and resources can be configured the same way.

For Java, you download opentelemetry-javaagent.jar and add -javaagent:path/to/opentelemetry-javaagent.jar to the JVM arguments, either directly or through JAVA_TOOL_OPTIONS. Settings can be passed as system properties such as -Dotel.service.name or as environment variables. A single library is turned off with OTEL_INSTRUMENTATION_[NAME]_ENABLED=false, OTEL_INSTRUMENTATION_COMMON_DEFAULT_ENABLED=false turns off all default instrumentation, and OTEL_JAVAAGENT_ENABLED=false disables the agent entirely.

For Python, installing opentelemetry-distro brings the API, the SDK and two tools. The opentelemetry-bootstrap -a install command looks at installed packages and adds matching instrumentation libraries, and opentelemetry-instrument python myapp.py runs the app with the agent. Command-line flags map to environment variables by uppercasing them and adding the OTEL_ prefix. OTEL_PYTHON_DISABLED_INSTRUMENTATIONS lists entry point names to skip.

For Node.js, you install @opentelemetry/api and @opentelemetry/auto-instrumentations-node and start the app with node --require @opentelemetry/auto-instrumentations-node/register, or put that flag in NODE_OPTIONS. OTEL_NODE_ENABLED_INSTRUMENTATIONS and OTEL_NODE_DISABLED_INSTRUMENTATIONS narrow the set; the enabled list is applied first and the disabled list is then removed from it.

The .NET automatic instrumentation is installed with a script or PowerShell module. On .NET Framework it must run as a CLR profiler; on modern .NET the profiler is only needed for bytecode instrumentation, and DOTNET_STARTUP_HOOKS is required without it. Individual libraries are switched off with OTEL_DOTNET_AUTO_[SIGNAL]_[NAME]_INSTRUMENTATION_ENABLED=false.

Go offers two official approaches. OpenTelemetry eBPF Instrumentation (OBI) observes processes from outside, works across many languages, and needs Linux, BTF and elevated privileges. Go compile-time instrumentation (otelc) weaves instrumentation in during go build and needs no special runtime privileges.

On Kubernetes, the OpenTelemetry Operator injects agents for .NET, Java, Node.js, Python and Go. You create an Instrumentation resource with the exporter endpoint, propagators and sampler, then opt workloads in with annotations such as instrumentation.opentelemetry.io/inject-java: "true" in the pod template. The Instrumentation resource must exist before the pods are created, and Go additionally needs the target executable path and a privileged eBPF sidecar.

Key points

  • Zero-code agents instrument libraries at the edges of an application, not its own business logic.
  • The Java agent is attached with -javaagent:path/to/opentelemetry-javaagent.jar and configured with system properties or OTEL_ variables.
  • Python uses opentelemetry-bootstrap -a install to add instrumentations and opentelemetry-instrument to run the app.
  • Node.js loads @opentelemetry/auto-instrumentations-node/register through --require or NODE_OPTIONS.
  • The Operator injects agents based on pod-template annotations that point to an Instrumentation resource created beforehand.

Three sample questions

21 OTCA questions on Zero-code Agents and Automatic Instrumentation, 21 with explanations. How practice works

Question 1

You have integrated OpenTelemetry SDK into your application and notice that your logs are automatically being correlated with active traces and spans. Which feature of OpenTelemetry is responsible for this correlation?
  1. A.Transform Processors in the OpenTelemetry Collector
  2. B.Exporters configured for trace data
  3. C.Log Receivers in the OpenTelemetry Collector
  4. D.Autoinstrumentation and OpenTelemetry SDK

Correct answer: D

The Logs concepts page says "When you add autoinstrumentation or activate an SDK, OpenTelemetry will automatically correlate your existing logs with any active trace and span, wrapping the log body with their IDs." The zero-code page explains that this kind of instrumentation adds the API and SDK to the application as an agent. Why the other options are wrong. "Transform Processors in the OpenTelemetry Collecto…": the transform processor changes data that has already been exported; the trace and span IDs are attached in the application. "Exporters configured for trace data": exporters only send data; they do not attach active trace context to log records. "Log Receivers in the OpenTelemetry Collector": log receivers ingest logs in the Collector; at that point the active span of the request is no longer known.

Sources: OpenTelemetry docs: Logs, OpenTelemetry docs: Zero-code instrumentation

Question 2

Which JVM command line attaches the OpenTelemetry Java agent to an application?
  1. A.java -jar opentelemetry-javaagent.jar -jar myapp.jar
  2. B.java -javaagent:path/to/opentelemetry-javaagent.jar -jar myapp.jar
  3. C.java -cp path/to/opentelemetry-javaagent.jar -Dotel.service.name=svc -jar myapp.jar
  4. D.java -Dotel.javaagent.enabled=true -Dotel.service.name=svc -jar myapp.jar

Correct answer: B

The getting-started guide says to download opentelemetry-javaagent.jar from the opentelemetry-java-instrumentation releases and add -javaagent:path/to/opentelemetry-javaagent.jar to the JVM startup arguments, either on the command line or via JAVA_TOOL_OPTIONS. The agent JAR works with Java 8+ applications and injects bytecode dynamically. Why the other options are wrong. "java -jar opentelemetry-javaagent.jar -jar myapp.j…": Running the agent JAR as the main JAR does not attach it as an agent to myapp.jar. "java -cp path/to/opentelemetry-javaagent.jar -Dote…": Putting the JAR on the classpath does not load it as a Java agent, and -cp is ignored when -jar is used. "java -Dotel.javaagent.enabled=true -Dotel.service.…": otel.javaagent.enabled only switches an already attached agent on or off (false disables it entirely); without -javaagent no agent is loaded.

Sources: OpenTelemetry docs: Java agent getting started, OpenTelemetry docs: Java agent

Question 3

A Java service runs with the OpenTelemetry Java agent. The team wants to keep every other instrumentation but stop the agent from instrumenting Apache Kafka. Which setting does that?
  1. A.OTEL_JAVAAGENT_ENABLED=false
  2. B.OTEL_INSTRUMENTATION_COMMON_DEFAULT_ENABLED=false
  3. C.OTEL_INSTRUMENTATION_KAFKA_ENABLED=false
  4. D.OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=kafka

Correct answer: C

The Java agent docs suppress a specific library with otel.instrumentation.[name].enabled / OTEL_INSTRUMENTATION_[NAME]_ENABLED set to false, where [name] is the instrumentation name from the table; Apache Kafka is listed as kafka. The Operator docs use the same OTEL_INSTRUMENTATION_[NAME]_ENABLED=false pattern for Java. Why the other options are wrong. "OTEL_JAVAAGENT_ENABLED=false": This disables the agent entirely, removing all instrumentation. "OTEL_INSTRUMENTATION_COMMON_DEFAULT_ENABLED=false": This disables all default instrumentation; it is used to then re-enable selected ones individually, the opposite of what is wanted. "OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=kafka": This is the Python agent's variable and has no effect on the Java agent.

Sources: OpenTelemetry docs: Java agent, suppressing specific instrumentation, OpenTelemetry docs: Operator, injecting auto-instrumentation

Practice this topic

Focus mode keeps every question on Zero-code Agents and Automatic Instrumentation until you leave it. 10 free guest answers, then a free account; no credit card.

Or open OTCA practice across all topics.

Sources

The explanation above was checked against these official documents.

Frequently asked questions

Can I still add custom spans when using an agent?

Yes. Agents cover library calls, and you can use the OpenTelemetry API in your own code to add spans and metrics; for Go eBPF setups, the Auto SDK connects manual spans to the eBPF spans.

Why did the Operator not instrument my pods?

Check that the Instrumentation resource existed before the pods started, that the annotation matches the language, and that it sits in spec.template.metadata.annotations of the Deployment.