I'm currently facing an issue with the OpenTelemetry Java Agent not receiving the arguments I pass to it in my SBT build file. Here's a snippet from my build file:
val buildOpenTelemtryJavaAgent: JavaAgent.AgentModule = {
val attributes = "service.name=MY_SERVICE,environment=development"
val argsStr = s"""otel.exporter=otlp otel.exporter.otlp.endpoint=http://198.51.100.1:4317 otel.resource.attributes="$attributes""""
print(argsStr)
JavaAgent(
module = openTelemetryAgentPrefix % openTelemetryAgentModuleName % openTelemetryAgentVersion % "runtime",
name = openTelemetryAgentName,
scope = JavaAgent.AgentScope(true, true, true, true),
arguments = argsStr
)
}
I'm using the JavaAgent case class from the com.lightbend.sbt.javaagent (https://github.com/sbt/sbt-javaagent) package to attach the OpenTelemetry Java Agent to my application. I pass a string of arguments to the agent, but when I run my application, I get the following error:
[otel.javaagent 2023-05-16 06:45:58:127 +0000] [OkHttp http://localhost:4317/...] ERROR io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter - Failed to export spans. The request could not be executed. Full error message: Failed to connect to localhost/127.0.0.1:4317
This error message suggests that the agent isn't receiving the correct endpoint from my arguments and is instead trying to connect to localhost:4317. This occurs regardless of what IP address I set in my SBT build file.
However, when I manually run the agent using the following command, it works correctly:
-javaagent:/Users/[MY_USER]/dev/git/[MY_PROJECT]/target/scala-2.12/opentelemetry-javaagent.jar -Dotel.exporter=otlp -Dotel.exporter.otlp.endpoint=http://198.51.100.1:4317 -Dotel.resource.attributes="service.name=MY_SERVICE,environment=development"
I would appreciate any insights into what might be going wrong here. Is it a problem with how I'm passing the arguments in my SBT build file, or is it an issue with how the agent is interpreting them?
Thank you in advance for your help.