# OpenTelemetry Agent With Auto Init | Sentry for Logback

If you use `sentry-opentelemetry-agent`, it will look for `SENTRY_DSN` and `SENTRY_PROPERTIES_FILE` environment variables to be defined, and then initialize Sentry automatically. You'll just need to configure your `DSN` and `tracesSampleRate`.

We recommend letting the Java Agent take care of initializing Sentry as this way the SDK will be ready early in your applications lifecycle.

## [Install](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup/agent/auto-init.md#install)

You can download the latest version of the `sentry-opentelemetry-agent-8.25.0.jar` from [MavenCentral](https://search.maven.org/artifact/io.sentry/sentry-opentelemetry-agent). It's also available as a `ZIP` containing the `JAR` used on this page on [GitHub](https://github.com/getsentry/sentry-java/releases/).

## [Usage](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup/agent/auto-init.md#usage)

This `java` command shows how to run your application using `sentry-opentelemetry-agent`:

```bash
SENTRY_PROPERTIES_FILE=sentry.properties JAVA_TOOL_OPTIONS="-javaagent:sentry-opentelemetry-agent-8.25.0.jar" java -jar your-application.jar
```

Here's the `sentry.properties` file that goes with it:

`sentry.properties`

```properties
dsn=https://examplePublicKey@o0.ingest.sentry.io/0
traces-sample-rate=1.0
```

## [Debugging](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup/agent/auto-init.md#debugging)

To enable debug logging in Sentry, set `SENTRY_DEBUG=true` as an environment variable or add `debug=true` to your `sentry.properties`.

To show debug output for OpenTelemetry, add `-Dotel.javaagent.debug=true` to the `java` command.

## [Turn Off Exporter Error Messages](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup/agent/auto-init.md#turn-off-exporter-error-messages)

If you're not using any OpenTelemetry exporters besides Sentry, add the following environment variables to turn off exporters and stop receiving error messages about servers not being reachable in the logs.

Example log message:

```bash
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/[0:0:0:0:0:0:0:1]:4317
ERROR io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter - Failed to export metrics. The request could not be executed. Full error message: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:4317
ERROR io.opentelemetry.exporter.internal.http.HttpExporter - Failed to export logs. The request could not be executed. Full error message: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:4318
```

#### [Traces](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup/agent/auto-init.md#traces)

To turn off traces exporting, set `OTEL_TRACES_EXPORTER=none` as an environment variable per [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters).

#### [Metrics](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup/agent/auto-init.md#metrics)

To turn off metrics exporting, set `OTEL_METRICS_EXPORTER=none` as an environment variable per [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters).

#### [Logs](https://docs.sentry.io/platforms/java/guides/logback/opentelemetry/setup/agent/auto-init.md#logs)

To turn off log exporting, set `OTEL_LOGS_EXPORTER=none` as an environment variable per [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters).
