Skip to content

Java Agent ignoring environment variables and java parameters for service nameΒ #12820

@decimalst

Description

@decimalst

Describe the bug

Hi folks, I am trying to instrument my service with the Otel java agent. For some reason however, the agent appears to be ignoring specific parameters or environment variables, such as OTEL_SERVICE_NAME.

Steps to reproduce

This happens when invoking the app with

OTEL_SERVICE_NAME=validator_service java -javaagent:/path/to/otel-2.10.0.jar -DapplicationName=ValidatorService -Ddebug=true -Dlogback.debug=true -DworkingDir=/path/to/app/linux64/version -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -XX:+UseG1GC -XX:+PrintGCDetails -Xloggc:log/gc-2024-11-26.14.41.23.log -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCCause -XX:+PrintGCApplicationStoppedTime -Dotel.javaagent.enabled=true -Dotel.traces.exporter=otlp -Dotel.logs.exporter=otlp -Dotel.metrics.exporter=otlp -Dotel.exporter.otlp.endpoint=http://localhost:4318 -Dotel.java.enabled.resource.providers=io.opentelemetry.instrumentation.resources.HostResourceProvider,io.opentelemetry.instrumentation.resources.ProcessResourceProvider -Dotel.java.disabled.resource.providers=io.opentelemetry.contrib.gcp.resource.GCPResourceProvider,io.opentelemetry.contrib.aws.resource.Ec2ResourceProvider -Dotel.javaagent.logging=application -Dotel.instrumentation.common.default-enabled=true -Dotel.instrumentation.opentelemetry-api.enabled=true -Dotel.instrumentation.opentelemetry-instrumentation-annotations.enabled=true -Dotel.instrumentation.jetty.enabled=true -Dotel.instrumentation.jetty-httpclient.enabled=true -Dotel.instrumentation.vertx-http-client.enabled=true -Dotel.instrumentation.vertx-redis-client.enabled=false -Dotel.instrumentation.vertx-rx-java.enabled=true -Dotel.instrumentation.vertx-sql-client.enabled=true -Dotel.instrumentation.vertx-web.enabled=true -Dotel.instrumentation.jdbc.enabled=true -Dotel.instrumentation.http-url-connection.enabled=true -Dotel.instrumentation.jms.enabled=true -Dotel.instrumentation.apache-httpclient.enabled=false -classpath [class path libraries] path.to.my.ValidationService

Expected behavior

The otel service name to be validator_service in Datadog, and traces being produced

Actual behavior

Traces are produced, but only for unknown_service:java in Datadog. I can see the configuration parameters reflected in the telemetry as process args.

When I enable debug logs, I see the log line:

..., process.pid=, service.name="unknown_service:java", telemetry.sdk.language="java", telemetry.sdk.name="opentelemetry", telemetry.sdk.version="1.44.1"}}

So it seems the autoconfigured SDK builder is being created and picking up some attributes, but not all

Javaagent or library instrumentation version

2.10.0

Environment

JDK: jdk1.8.0_173
OS: RHEL7

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageNew issue that requires triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions