OpenTelemetry Agentless
Using OpenTelemetry with sentry-opentelemetry-agentless.
If you do not want to use our recommended Java Agent, we also offer a dependency that allows you to use OpenTelemetry with Sentry.
In addition to your typical Sentry dependencies, you will need to add sentry-opentelemetry-agentless as a dependency:
implementation 'io.sentry:sentry-opentelemetry-agentless:8.52.0'
implementation 'io.sentry:sentry-opentelemetry-agentless:8.52.0'
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-opentelemetry-agentless</artifactId>
<version>8.52.0</version>
</dependency>
Please note, if you're using Spring Boot, there's a separate sentry-opentelemetry-agentless-spring dependency. You can find out more here.
Sentry's Java OpenTelemetry integrations are tested with a specific OpenTelemetry dependency set. If your application also imports a BOM that manages OpenTelemetry versions, such as Spring Boot dependency management, it can override transitive OpenTelemetry dependencies and create a mixed OpenTelemetry classpath.
Import io.sentry:sentry-opentelemetry-bom manually when another BOM manages OpenTelemetry versions in your application.
build.gradledependencies {
implementation platform('io.sentry:sentry-opentelemetry-bom:8.52.0')
}
dependencies {
implementation platform('io.sentry:sentry-opentelemetry-bom:8.52.0')
}
<dependencyManagement>
<dependencies>
<!-- If another Maven BOM also manages OpenTelemetry versions, import Sentry's OpenTelemetry BOM before that BOM. -->
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-opentelemetry-bom</artifactId>
<version>8.52.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
You'll have to configure both OpenTelemetry and Sentry to see transactions in Sentry and have errors linked to transactions created by OpenTelemetry.
Our sentry-opentelemetry-agentless dependency also adds opentelemetry-sdk-extension-autoconfigure which takes care of configuring OpenTelemetry to work with Sentry. You can configure it using AutoConfiguredOpenTelemetrySdk:
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
AutoConfiguredOpenTelemetrySdk.builder()
.setResultAsGlobal()
.addPropertiesSupplier(() -> {
final Map<String, String> properties = new HashMap<>();
properties.put("otel.logs.exporter", "none");
properties.put("otel.metrics.exporter", "none");
properties.put("otel.traces.exporter", "none");
return properties;
})
.build();
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
AutoConfiguredOpenTelemetrySdk.builder()
.setResultAsGlobal()
.addPropertiesSupplier(() -> {
final Map<String, String> properties = new HashMap<>();
properties.put("otel.logs.exporter", "none");
properties.put("otel.metrics.exporter", "none");
properties.put("otel.traces.exporter", "none");
return properties;
})
.build();
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk
AutoConfiguredOpenTelemetrySdk.builder()
.setResultAsGlobal()
.addPropertiesSupplier{
return mapOf(
"otel.logs.exporter" to "none",
"otel.metrics.exporter" to "none",
"otel.traces.exporter" to "none"
)
}
.build()
You can initialize Sentry as usual, fore example, by calling Sentry.init:
import io.sentry.Sentry;
Sentry.init(options -> {
options.setDsn("___PUBLIC_DSN___");
options.setTracesSampleRate(1.0);
});
import io.sentry.Sentry;
Sentry.init(options -> {
options.setDsn("___PUBLIC_DSN___");
options.setTracesSampleRate(1.0);
});
import io.sentry.Sentry
Sentry.init { options ->
options.dsn = "___PUBLIC_DSN___"
options.tracesSampleRate = 1.0
}
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").