OpenTelemetry Agent
Using OpenTelemetry with sentry-opentelemetry-agent.
This is our recommended way of setting up Sentry with OpenTelemetry as it offers the broadest support for frameworks and libraries.
The sentry-opentelemetry-agent makes use of the java command's -javaagent argument. This Java Agent will run some code before starting your application, configuring OpenTelemetry and Sentry and also dynamically injects bytecode into your application.
The injected code allows OpenTelemetry and by extension also Sentry to:
- Instrument your application by creating spans around things like HTTP requests, database queries, and many more.
- Propagate OpenTelemetry
Contextand SentryScopesthrough libraries - Extract tracing information from incoming requests and consumed messages
- Inject tracing information into outgoing requests and produced messages
The sentry-opentelemetry-agent is packaged as a JAR file and is separate from your applications JAR / WAR file. This means you will have to manage the version on your server and upgrade it whenever you upgrade the Sentry SDK dependency in your application should you have it.
✨ Note
Sentry Java SDK dependencies as well as sentry-opentelemetry-agent version must always be aligned. Mixing them is very likely to cause crashes and as of version 8.6.0 the Java SDK will throw an exception on init in this case to help catch the issue during development.
If you're unsure whether to use the Java Agent, please have a look at OpenTelemetry documentation.
Since sentry-opentelemetry-agent is based on opentelemetry-agent, you may also find OpenTelmetry docs helpful.
When using sentry-opentelemetry-agent you can choose whether the Agent should call Sentry.init. By default the Agent will initialize Sentry for you. If you prefer to manually initialize Sentry or have another integration perform the init you can disable this behaviour.
For Spring Boot we recommend disabling the Agents AUTO_INIT and instead letting our Spring Boot integration take care of initializing the SDK as this allows for a more convenient configuration of Sentry using application.properties/application.yml and Spring beans.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").