---
title: "OpenTelemetry Setup"
description: "Setting up Sentry with OpenTelemetry."
url: https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup/
---

# OpenTelemetry Setup | Sentry for Logback

There are multiple ways to configure our OpenTelemetry integration. You may chose between using our Java Agent or using one of our agentless dependencies.

## [Java Agent](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup.md#java-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](https://docs.oracle.com/en/java/javase/17/docs/api/java.instrument/java/lang/instrument/package-summary.html). 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 `Context` and Sentry `Scopes` through 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.

Since `sentry-opentelemetry-agent` is based on `opentelemetry-agent`, you may also find [OpenTelmetry docs](https://opentelemetry.io/docs/zero-code/java/agent/) helpful.

For a guide on how to set up `sentry-opentelemetry-agent`, please have a look at [the detailed Agent docs](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup/agent.md).

## [Agentless](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup.md#agentless)

We also offer a way of using Sentry with OpenTelemetry that does not require a Java Agent but instead makes use of a dependency that can be packaged with your application.

The `sentry-opentelemetry-agentless` dependency combines all modules and dependencies needed to use Sentry with OpenTelemetry.

For a guide on how to set up agentless, please have a look at [the detailed Agentless docs](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup/agentless.md).

## [OTLP](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup.md#otlp)

If you want OpenTelemetry to handle tracing and export spans via OTLP directly to Sentry, while Sentry handles errors, logs, and metrics, you can use the `sentry-opentelemetry-otlp` module. This is a lightweight integration where Sentry only reads the trace and span IDs from the OpenTelemetry `Context` to correlate its events with OpenTelemetry traces. Unlike the Agent and Agentless integrations above, it does not use OpenTelemetry for scope storage or span creation within the Sentry SDK.

For a guide on how to set up OTLP, please have a look at [the detailed OTLP docs](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup/otlp.md).

## Pages in this section

- [OpenTelemetry Agent](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup/agent.md)
- [OpenTelemetry Agentless](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup/agentless.md)
- [OpenTelemetry OTLP](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup/otlp.md)
