Zero‑Code Java Observability with Dynatrace OneAgent Auto‑Injection
Learn how Dynatrace OneAgent auto‑injection provides full‑stack Java metrics and distributed tracing without adding any code or dependencies.
06 Oct 2026, 08:34 UTC

The Problem: Manual Instrumentation Slows Java Teams
Engineering teams often spend valuable sprint time adding tracing libraries, configuring OpenTelemetry agents, and updating dependencies across dozens of microservices. A missed version or a misplaced annotation can create blind spots in distributed traces, leaving you without insight during an incident.
How OneAgent Auto‑Injection Works
Dynatrace OneAgent does not require a JAR attached to your application. At JVM startup a lightweight bootstrap library attaches to the process and, as classes are loaded, injects bytecode that records method entry/exit, asynchronous boundaries, and external calls. This happens at the class‑loading level, so frameworks such as Spring Boot, Jakarta EE, or Quarkus are instrumented automatically without any code changes.
Setting Up the Injector
- Install the OneAgent on the host (Linux kernel ≥ 3.10, glibc ≥ 2.17) or deploy it as a DaemonSet in Kubernetes.
- Enable the injector by setting the environment variable
DT_ONEAGENT_INJECTOR_ENABLED=trueor toggling it in the Dynatrace UI under Deployment status → OneAgent. - Restart the Java process so the JVM picks up the bootstrap library during startup.
Verification Steps
Run the following command on the host where the Java process runs (requires root or sudo):
./oneagentctl --injector-status
A successful execution returns exit code 0 and prints Injection enabled. You can also verify in the Dynatrace UI: the Injector column should show Active for each Java process, or check the custom metric dt.oneagent.injector.enabled (value 1.0 indicates active injection).
Worked Example: Spring Boot Service Calling Redis
Consider a Spring Boot 3.2 service that retrieves user sessions from a Redis cache via the Lettuce client. Without auto‑injection you would see only the HTTP request timing; the downstream Redis call would be invisible.
With OneAgent auto‑injection enabled, Dynatrace creates a PurePath that automatically maps:
- HTTP controller entry point
- Service layer business logic
- Lettuce client call to Redis
- Redis command execution time
If the Redis latency spikes from a typical 45 ms to over 120 ms, the Davis AI engine flags the anomaly and links it to the increased end‑to‑end response time, giving you an immediate root‑cause hint.
Trade‑offs and Limitations
- CPU overhead: expect an additional 2 %‑5 % on the host; negligible for most workloads but noticeable in ultra‑low‑latency trading systems.
- JVM must allow agent attachment; the flag
-XX:+DisableAttachMechanismblocks OneAgent from injecting bytecode. - Strict Java Security Managers can prevent class redefinition; you may need to grant specific permissions or use a side‑car injection mode instead.
Ensuring Continuous Observability
The biggest risk is a silent failure where a JVM restart or configuration change disables injection, leaving you without data. Mitigate this by monitoring the custom metric dt.oneagent.injector.enabled. Configure a Davis problem alert that triggers when the metric drops to 0, notifying the platform team to investigate and restart the affected service.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.