0

The documented way to add Azure Monitor OpenTelemetry to Java application is by downloading applicationinsights-agent-3.2.11.jar and using the following: -javaagent:path/to/applicationinsights-agent-3.2.11.jar.

So in Spring Boot, the way it could possibly be run:

java -javaagent:path/to/applicationinsights-agent-3.2.11.jar -jar <jar-file.jar>.

But what happens if this path varies?

The problem is depending on the system it is running, and using maven (pom.xml) to get the artifact, how do we enable opentelemetry with applicationinsights-agent-3.2.11.jar since the location Maven stores the artifact changes from user accounts and computer?

Additionally, how do I specify a relative path to applicationinsights.json file for configuration (as Azure looks for this file inside the applicationinsights-agent-3.2.11.jar directory)?

If you specify a relative path, it will be resolved relative to the directory where applicationinsights-agent-3.2.11.jar is located.

UPDATE Regarding suggestions, How to define a relative path in java and this other suggested question I am not looking to read files from relative paths. The spring boot application needs to be invoked with a specific argument where it needs to be made aware of the location where maven downloads the the appinsights jar file. Then when the app starts, the appinsights autoconfigure based on applicationinsights.json file, which once again, may vary by location.

sbsatter
  • 523
  • 2
  • 20
  • Does this answer your question? [How to define a relative path in java](https://stackoverflow.com/questions/14209085/how-to-define-a-relative-path-in-java) – DeepDave-MT May 27 '22 at 04:31
  • [Where do I have to put a json file to be available in Java?](https://stackoverflow.com/questions/59822055/where-do-i-have-to-put-a-json-file-to-be-available-in-java) – DeepDave-MT May 27 '22 at 04:32
  • No @DeepDave-MT, the java agent argument is going to contain the location of a jar file which will vary by computer and env. In addition, when maven downloads the jar file, we can only check the dir and go in there manually to add the applicationinsights.json file. However, it needs to be done for all the different env this is run in and also in deployments/prod. This is the problem I am trying to overcome. Hope this makes sense. – sbsatter May 27 '22 at 04:48

0 Answers0