What the OpenTelemetry Java agent setup for production covers and when teams need it
A platform or SRE team running many JVM services often needs traces, metrics and logs from every service without rewriting each application. The OpenTelemetry Java agent addresses that situation: it is attached to a JVM at startup and instruments supported libraries and frameworks automatically, so the work moves from editing code in each service to planning one rollout that every service follows. Before rollout, confirm which libraries, application servers and frameworks your services use are covered by the current instrumentation list, and check the stability of each signal you intend to collect, since coverage and maturity change between releases.
OpenTelemetry generates and exports telemetry, but it does not store or visualize it. Traces, metrics and logs leave the JVM through OTLP and must land in a backend that you choose and operate separately, so the agent setup and the backend decision should be made as two distinct choices. Teams should also decide where the agent sends data. In a small estate, the agent can export straight to a backend. In a larger one, the agent usually sends to a Collector running as a gateway, which centralizes processing, credentials and routing. The OpenTelemetry Collector documentation explains the agent and gateway patterns that this decision depends on.
Confirm three things before committing: the Java runtime versions your services run, the libraries and frameworks in use across the estate, and the network path from every JVM host to the Collector or backend. Those answers determine whether the agent can be applied uniformly or whether some services need separate handling. The rest of this page covers attaching the agent, suppressing noisy instrumentation, extending it with the API and annotations, and checking overhead.
Agent configuration options and when each one fits
This table compares the main configuration choices for the OpenTelemetry Java agent in production: how it is attached, where telemetry is sent, which instrumentation is enabled and how much data is sampled. Read each row for when the option fits, what it costs to run, and what to confirm in the agent documentation for the version you deploy. The main takeaway is that most production risk sits in the instrumentation scope and export path, not in the attach method.
| Choice | Option and when it fits | Operating cost and what to confirm |
|---|---|---|
| Attach method | JVM flag on the application command line fits teams that deploy VMs or bare-metal services and want the agent version managed separately from the app build. | Each service start command changes on upgrade. Confirm the flag syntax and the agent JAR path for your exact agent version. |
| Attach method | Baking the agent into the container image fits Kubernetes teams that want immutable, reproducible images tied to a known agent version. | Agent upgrades require an image rebuild and redeploy. Confirm the agent file location and permissions inside your base image. |
| Export destination | Exporting directly from the agent to a backend fits small estates with one backend and few services, where fewer moving parts matter more than central control. | Every service holds backend endpoints and credentials, so rotation touches all services. Confirm the exporter settings and retry behavior in the agent docs. |
| Export destination | Exporting through a Collector fits most production estates, since the Collector can receive, process and export telemetry for many sources and be changed without touching applications. | You run and scale the Collector tier and monitor it. Confirm the endpoint and protocol the agent uses to reach the Collector for your version. |
| Instrumentation scope | Enabling all instrumentation fits short evaluations or discovery work where you need to learn which libraries appear in traffic. | Noisy spans and attributes increase volume, storage and backend cost, and can capture data you did not intend to export. Confirm the default enabled set. |
| Instrumentation scope | An allowlist of named instrumentations fits production, where only libraries you have reviewed produce telemetry. | Someone must review the list at each upgrade and when frameworks change. Confirm how the agent names instrumentations and how to disable the rest. |
| Sampling | Parent-based or ratio sampling in the agent fits services where volume must be capped at the source. | Sampling at the agent cannot see whole traces, so error traces may be dropped. Confirm the sampler options and whether tail sampling is done in the Collector. |
| Sampling | Keeping the agent at full sampling and sampling in the Collector fits teams that need complete traces for errors and slow requests. | The Collector carries more load and memory. Confirm which sampling and processing components your Collector build includes. |
How the Java agent sends telemetry from JVM services to the Collector
The flow starts inside the JVM, where the Java agent attaches to the service process and emits traces, metrics and logs without changes to application code. Telemetry leaves the service over the network to an OpenTelemetry Collector, which runs either beside the service as an agent or as a shared gateway. An optional processing step, such as the redaction processor, removes sensitive attributes before export. The separate backend is chosen by your organization. Check the trust boundary: the localhost default on the Collector should be changed only deliberately, and the path across the boundary should use encryption and authentication.
Java agent telemetry crosses a trust boundary to the Collector before reaching the backend.
Which attachment method fits each deployment environment
On virtual machines or bare metal, the usual pattern is to place the agent JAR in a versioned directory managed by configuration management and add it to the JVM startup with -javaagent. The agent is loaded before your application code, so every supported library call made after startup can be instrumented. Changes live in the playbook or role that renders the service's systemd unit or startup script, not in the application repository.
- Pin the agent file: Store the JAR under a versioned path such as
/opt/otel/<version>/so rollbacks change one variable, not the file in place. - Set the flag in one place: Render
-javaagent:and the OpenTelemetry settings into the unit file orJAVA_TOOL_OPTIONSfrom the same template, so no host drifts. - Configure through environment: Keep the service name, exporter endpoint and resource attributes in an environment file managed alongside the unit.
- Restart on change: Make the agent version a handler trigger so a new JAR always produces a service restart.
- Verify the attach: Check the application log for the agent's startup banner and confirm spans arrive at the Collector for a test request.
The most common failure is a path or permission error on the JAR, which the JVM may report only at startup and which a process supervisor can hide by restarting in a loop. Confirm the service user can read the file and that the log shows the agent started.
When services run from images, the agent should be part of the build or delivered through a shared volume, so every running container carries the same agent version that was tested. The team decides whether the JAR is copied into a derived image layer or mounted from an init container or shared volume, and that choice determines how upgrades reach running workloads. The startup command, usually set in the Dockerfile entrypoint or the orchestrator manifest, must include the agent flag.
- Bake or mount deliberately: Copying the JAR into the image makes each build reproducible, while a shared volume lets you swap the agent without rebuilding applications.
- Use the environment for settings: Pass
OTEL_SERVICE_NAME,OTEL_EXPORTER_OTLP_ENDPOINTand resource attributes through the manifest, not the image. - Scan the agent artifact: Add the agent JAR to the image scanning and software bill of materials process your organization already runs.
- Keep the flag out of multiple places: Avoid setting
-javaagentin both the Dockerfile and the manifest, since duplicate flags can attach the agent twice or mask a removed one. - Verify per pod: Check the container log for the agent banner and query telemetry by pod or container resource attributes.
The most common failure is an entrypoint that replaces the one the image was built with, such as a wrapper script that drops JAVA_TOOL_OPTIONS or the agent flag. Compare the running process command line with the image definition to confirm the agent is present.
Where another team controls the startup arguments, such as a managed application server, a vendor platform or a shared hosting tier, you usually cannot add -javaagent directly. The available routes are the platform's own mechanism for JVM options or extension points, or a settings file the operator exposes. Before you plan a rollout, ask the platform owner what they will permit, who changes the settings, and how a change is reviewed and rolled back.
- Confirm the supported mechanism: Ask the platform owner which JVM option or deployment hook they accept, and get the answer in writing.
- Confirm version support: Do not assume a given application server version works with the agent. Ask the platform owner and the agent maintainers to confirm the combination you run.
- Agree on change control: Record who edits the startup configuration, the review step, and the rollback path.
- Check for a second agent: Find out whether the platform already attaches a monitoring agent, since two agents on one JVM can conflict.
- Verify on a staging instance first: Confirm the agent loads and exports spans before changing production.
The most common failure is a setting that the platform silently ignores or overrides at deploy time, so the agent appears configured but never attaches. Check the effective JVM arguments on a running instance, not the configuration you submitted.
Setting up the OpenTelemetry Java agent in production, step by step
This sequence moves the Java agent from a single trial service to a fleet of JVM services in controlled waves, with a check at each stage so that every wave starts from a known, measured baseline.
Confirm JVM version and library inventory
The platform team, with the owners of each Java service, lists every JVM version, application server, framework and major client library in use, then checks them against the supported libraries and runtimes in the Java agent documentation. Record any service that uses a library outside that list, a custom classloader, or a bytecode tool that may conflict with the agent. Done when every service has a row in the inventory marked supported, unsupported or needs review, and each review item has a named owner.
Deploy a tested Collector release
The platform team deploys the OpenTelemetry Collector using a release that has been tested in a non-production environment, pulled from the official releases page and verified with the published checksums and signatures. Configure the receiver to bind to an address the agents can reach, and confirm the endpoint is not exposed beyond the networks that need it. Done when a test span sent with a simple OTLP client shows up in the Collector debug output or in the backend.
Attach the agent to one non-critical service
An engineer on the owning team adds the agent to the JVM startup arguments of a single low-risk service in a non-production environment, sets the service name and the Collector endpoint through environment variables, and restarts the service. Keep the agent version pinned and record it in the change ticket. Done when the application starts normally and the startup log shows the agent loading with its version, which confirms the agent is attached.
Verify spans and metrics arrive with expected names
The engineer generates representative traffic against the test service and opens the backend or Collector debug output. Check that spans appear for inbound requests and outbound calls to databases and HTTP clients, that the service name matches the agreed naming convention, and that JVM metrics such as heap and garbage collection arrive. Done when a trace can be followed from the entry point through a downstream call and the service name is exactly as planned.
Add resource attributes for ownership and environment
The platform team sets resource attributes such as deployment environment, service version, team or owner, and cluster or host identifiers, using the agent's environment-variable configuration or the Collector's resource processor. Confirm the attributes are applied consistently across the test service by filtering telemetry on each one. Done when every span and metric from the test service carries the agreed attributes and no attribute is missing or misspelled.
Suppress noisy instrumentation and check for sensitive data
Review the test service's telemetry for high-volume spans and attributes that carry request bodies, query parameters or credentials, then disable the specific instrumentations that add noise and configure redaction where needed. Confirm the change in the same way as before. Done when the remaining spans are useful for investigation and a sample of exported attributes contains no secrets or personal data.
Record a baseline before each wave
Before enabling the agent on the next group of services, the owners measure response time, CPU use, memory use, garbage collection pauses and error rates for each service under normal load, with the agent off and then on in a comparable environment. Store the results with the agent version and configuration. Done when each service in the wave has a baseline document that the team can compare against after rollout.
Widen to more services in waves
The platform team enables the agent for the next wave of services in production, using the same pinned version and configuration, then compares live telemetry and the recorded baseline. Expand to the next wave only after the previous one shows the expected service names, attributes and overhead, and roll back any service that breaks. Done when every service in scope either reports telemetry as planned or has a documented exception with an owner.
Suppressing noisy instrumentation and extending with the API and annotations
The Java agent instruments a lot by default, and some of that output is noise while some of the most useful context, such as business meaning, only exists where your code adds it. The four cards below cover what to turn off, what to filter, what to add by hand, and where annotations fit, with a check to run after each change.
Disable instrumentation that floods traces
Some library instrumentations create many short spans for calls that add little diagnostic value, such as high-frequency cache reads or connection pool checks. Turning one off with its per-instrumentation switch in the agent configuration reduces that noise, but you lose the spans and any latency visibility for that library. Decide library by library, and record which ones you disabled so later troubleshooting does not start from a false assumption that the call never happened. After the change, confirm that the remaining spans still connect to the parent request and that error spans for the affected library are still produced where you need them.
Java agent docsFilter health checks and static resources
Load balancer probes, readiness endpoints and requests for static assets often make up a large share of inbound spans without telling you much about user traffic. Excluding them through the agent's URL-based filtering settings keeps those spans out of your backend, but any outage that begins with a failing probe becomes invisible in traces. Keep a metric or a separate sampled signal for probe results so health remains observable. After the change, send a test request to an excluded path, confirm no span is exported, and confirm a real endpoint with the same prefix still produces one.
Add business spans and attributes with the API
The agent cannot know that a request belongs to a specific order type, tenant or payment route, so add those meanings yourself through the OpenTelemetry API. Obtain the current span, set attributes with stable, documented names, and create child spans around significant business steps. The trade-off is ownership: every added attribute is code you maintain, and high-cardinality values such as raw customer IDs can raise backend cost and expose personal data. Verify in a non-production environment that attribute names follow your naming convention and that no regulated values reach the exported span.
Use annotations for method-level spans
The @WithSpan annotation creates a span around a method without writing tracing calls in the method body, which suits service-layer methods you want to see in a trace. Parameters can be captured as attributes with @SpanAttribute, and that is where data exposure risk appears, because method arguments often contain personal or account data. Annotated methods also add a span for every call, so apply them to a small set of meaningful boundaries. After deployment, check that captured parameters are limited to the fields you intend and that the agent's annotation support is enabled in the runtime you deploy.
Measuring agent overhead before production traffic reaches every service
Run overhead checks on a canary service before the agent reaches the rest of the fleet. Pick one representative JVM service, then run it twice under the same load: once without the OpenTelemetry Java agent and once with it attached. Compare CPU use, heap usage and garbage collection behavior, request latency at the percentiles your service-level objectives use, and throughput at the point where latency starts to climb. Keep the JVM flags, container limits, heap size and load generator identical between the two runs, so that any difference can be attributed to the agent and its settings rather than to a changed environment.
Repeat the same test after every change to instrumentation settings, not only when the agent version changes. Disabling an instrumentation module, changing sampling, adding span attributes, or enabling a new library instrumentation can each shift the numbers, and the effect can be larger than expected on high-volume endpoints. While each run is in progress, watch the Collector's own resource use and its dropped data counters, since a Collector that is refusing or dropping spans will make the application look cheaper than it is in production. Record the Collector's memory, CPU and queue behavior alongside the application figures so that the two can be read together.
Treat any published overhead figure as a starting hypothesis only. Results depend on the workload shape, JVM version and garbage collector, heap sizing, number of threads, database and downstream call patterns, and the volume of telemetry each request produces. Ask your team to confirm the exact agent version and the supported JVM versions against the agent documentation before testing, and use the OpenTelemetry Collector documentation to confirm how your chosen deployment pattern handles backpressure. The result you need is a measurement from your own service under your own traffic, written down with the settings that produced it, so that the next rollout can be compared against it.
Securing the agent's data path and configuration
Java agent telemetry leaves each JVM and travels to a Collector, then onward to a back end, and each hop can expose data. The four cards below cover the configuration, transport, content and network exposure decisions that determine whether that path is safe to run in production.
Store Collector configuration securely
The Collector configuration defines receivers, exporters and credentials, so it is sensitive infrastructure in its own right. Keep the file in a secrets store or a protected configuration repository, inject tokens through environment variables or secret references rather than plain text, and restrict who can read or change it. Confirm with your security team where Collector configuration files are kept today and who can edit them during an incident.
Collector security practicesEncrypt and authenticate agent traffic
Agents export spans, metrics and logs over OTLP, and unencrypted or unauthenticated links let anyone on the path read or inject telemetry. Enable TLS between each JVM and the Collector, and between the Collector and the back end, and use the Collector's authenticator extensions for incoming and outgoing requests where your identity provider supports them. Confirm which certificate authority issues these certificates and how rotation is handled.
Redact sensitive attributes in the Collector
Java agent instrumentation can capture full SQL text, HTTP query strings, headers and message payloads by default, and these can contain personal, financial or health data. Use the redaction processor to remove or mask sensitive attributes before export, and test the rules against real captured spans in a non-production environment. Confirm the attribute list against your data classification, because a rule that misses one field leaves that data in your back end.
Bind the Collector to a restricted interface
Since Collector v0.110.0, server components bind to localhost by default rather than all interfaces, so a fresh install does not accept remote connections on every address. Keep that default where the agent runs on the same host, and bind to a named internal interface or sit behind a network policy when agents on other hosts send data to a gateway. Confirm the bind addresses in every deployment file, because overrides in Helm values or container arguments can reopen exposure.
Security best practicesWhich libraries and signals to confirm before go-live
Library coverage for the Java agent is documented per library and per version, so the supported list you read must match the exact agent release you deploy. Start by building a library inventory from the dependency trees of every JVM service in scope: HTTP servers and clients, database drivers, messaging clients, caches, RPC frameworks and any internal wrappers around them. Record each library with its version, then compare that list against the agent's supported libraries page for the version you intend to roll out. Mark each entry as covered, covered only in part, not covered, or covered but disabled by default, because each category leads to a different remediation.
Signal maturity is the second check. Per the OpenTelemetry status page, trace APIs and SDKs are stable in Java, but log SDK maturity varies more across languages, and core Collector components have mixed stability levels documented in each component's README. Confirm which signals you need at go-live, whether traces, metrics or logs, and check the stability status of each one for your Java version and your chosen Collector build. Treat any signal still in development as a planned risk, not a launch dependency. Gaps in the inventory should be written down as a register with three columns: the missing library, the owner, and the chosen fallback, such as manual spans, a different instrumentation approach or accepting the gap. This check is the most common source of surprises, and the status page and agent documentation change between releases, so confirm every entry against current documentation on the day you freeze the version.
Limits to confirm in your environment before rollout
The Java agent covers a broad set of libraries, but its coverage depends on your exact library versions, JVM setup, Collector release and the traffic paths your services use. Confirm each of the four areas below in a test environment that matches production before you widen the rollout.
Library and framework versions
The agent instruments libraries through version-specific rules, so a framework or client version outside the supported list may produce no spans, partial spans or incorrect attributes. Build an inventory of the HTTP servers, database drivers, messaging clients and HTTP clients in each service, then compare those exact versions with the supported list in the agent documentation. Run a trace from every service in staging and confirm that each dependency call appears with the expected span name.
OpenTelemetry overviewJVM and runtime restrictions
Some runtimes limit how an agent attaches to a JVM, including container images with restricted startup options, application servers that manage their own class loading, and hardened hosts that block agent JARs from being read. Ask the platform team whether the -javaagent flag can be set in every deployment path, including batch jobs and scheduled tasks. Also confirm how the agent behaves under your JVM vendor and version, and whether your security policy allows loading the agent file from the image.
Collector release and component stability
The agent exports to a Collector, and the Collector's components have mixed stability levels documented in each component's README. Choose the Collector distribution, pin a release, and confirm that every receiver, processor and exporter in your pipeline is stable enough for production use. Check the release notes before each upgrade, because component renames and removed options can stop telemetry without an obvious error. Ask the vendor or the project which signals each component supports.
OpenTelemetry status pageBoundary of what the agent sees
The agent wraps the libraries it knows about, so custom wire protocols, in-house frameworks, reflection-heavy code and some asynchronous hand-offs may appear as gaps in a trace. Map the request paths that matter most for your business, such as payment flows or batch jobs, and check whether each hop produces a span and propagates context. Plan manual spans or API calls for paths the agent does not reach, and record those gaps so that the operations team does not treat them as outages.
How much effort and cost does OpenTelemetry Java agent setup take?
What drives the effort and cost of a production OpenTelemetry Java agent rollout?
The main drivers are how many JVM services you run, how varied their frameworks and libraries are, how much of your telemetry must be scrubbed or routed before it leaves your network, and how many teams must agree on naming and ownership. A rollout with a small, uniform fleet and one Collector path is far less work than one spanning legacy application servers, batch jobs and services with custom HTTP clients. Attaching the agent is quick. The bulk of the effort goes into compatibility checks, suppressing noisy instrumentation, deciding which attributes to keep, testing overhead under load and writing the runbook your operations team will use after handover.
How long does a production OpenTelemetry Java rollout take?
Duration depends on the scope agreed before work starts, so no fixed figure applies across environments. Ask for a phased timeline that separates design, a pilot on a small set of services, the fleet rollout and handover, and check that each phase has a clear exit condition such as agreed span names, an overhead result you accept and a documented rollback. Be cautious with any timeline that does not name the number of services, the Collector topology or the testing environments it assumes, because those are the inputs that move the schedule most.
What does the work require from our own teams?
Expect to supply several people for short periods rather than one person full time. You need owners for the JVM services and their build and deployment pipelines, someone who can approve changes to container images or startup arguments, a platform or operations contact for the Collector and backend, and a security contact to review what telemetry leaves the network. Application teams must confirm which endpoints and business fields are sensitive and must test their own services after the pilot. Ask the implementation partner to list these roles and the hours each one is expected to give, in writing.
Can our internal team set up the OpenTelemetry Java agent alone?
A capable internal platform team can attach the agent to a few services without outside help, because the basic setup is a JVM argument and a few environment variables. The harder parts are proving that overhead stays acceptable, suppressing instrumentation that floods the backend, keeping sensitive data out of spans, pinning agent versions and upgrading them safely, and handling services that share libraries or run on application servers. If your team has no recent JVM performance or security testing experience, or if the fleet is large, weigh the cost of learning those steps against the cost of a fixed-scope engagement that delivers them with documentation.
How does the number of services change the scope and cost?
Scope grows with the number of distinct configurations, not only the raw service count. Ten services built from one template need one pilot, one set of exclusions and one rollout pattern. Ten services built from four frameworks, two application servers and several Java versions need separate compatibility checks and separate test plans. Ask the partner to group your services by framework, runtime and data sensitivity, then price each group. Recurring work also rises with service count, since every agent upgrade and every new service must be tested against the same checks.
What should a fixed-scope quote for this work include?
A fixed-scope quote should list the services in scope, the library and framework inventory used to check compatibility, the Collector and backend assumptions, and the deliverables in writing: a configuration baseline, suppression rules, attribute and redaction decisions, an overhead test report, a rollback procedure, and handover documentation. It should separate one-time work (design, pilot, rollout, testing and handover) from recurring work such as agent upgrades, retesting and any ongoing retainer. Ask who performs each activity, which environments are used for testing, what happens if a scope change is requested mid-project, and what acceptance criteria close each phase. DeployOpen does not publish a price list, and a quote follows from the written scope.
What recurring costs follow the initial rollout?
Recurring costs come from keeping the agent current and the fleet verified. Each agent release may change instrumentation behavior, so teams need a regression pass on representative services, a review of new or renamed instrumentation, and a staged deployment. Operations also needs time to monitor the Collector, respond to dropped data and review new services as they appear. Some organizations cover this internally, while others buy a retainer for upgrades, continuous testing and support. Ask for the recurring scope, the response expectations and the price basis in writing so you can compare internal and external options on the same terms.
How DeployOpen scopes, delivers and supports Java agent rollouts
DeployOpen plans and implements OpenTelemetry Java agent rollouts inside your own infrastructure, starting with a written scope that covers which services, backends and noisy instrumentation are in play. The work moves from a pilot on representative JVM services to a documented, supported standard your platform and application teams can run.
How we scope
- Inventory JVM services, frameworks, application servers and existing monitoring agents before agreeing which services receive the agent.
- Agree in writing which libraries, suppressed instrumentations and custom spans are in scope for OpenTelemetry Java agent setup for production.
- Engagements are fixed-scope, so deliverables and timelines are confirmed in writing before any rollout work begins.
How we build
- Attach the agent to a pilot service, then validate traces, metrics and logs against the agreed attribute and naming conventions.
- Tune instrumentation by disabling noisy libraries and adding API and annotation spans where business context is missing.
- Measure startup time, memory and CPU overhead against a baseline before expanding the rollout to more JVM services.
How we hand over
- Deliver agent versions, startup configuration, Collector endpoints and rollout runbooks in your own repositories and infrastructure.
- Document the instrumentation decisions, suppressed libraries and custom spans so your teams can extend the setup safely.
- Walk your platform and application engineers through verification steps, upgrade procedure and troubleshooting checks.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers once the rollout is in production.
- Retainers can cover agent upgrades, configuration changes for new JVM services and periodic overhead reviews.
- Confirm with your team the support boundaries, response expectations and change control before the retainer starts.

