|
| 1 | +# sentry-opentelemetry-agentless-spring |
| 2 | + |
| 3 | +*NOTE: Our OpenTelemetry modules are still experimental. Any feedback is welcome.* |
| 4 | + |
| 5 | +## How to use it |
| 6 | + |
| 7 | +Add the latest `sentry-opentelemetry-agentless-spring` module as a dependency and add a `sentry.properties` |
| 8 | +configuration file to your project that could look like this: |
| 9 | + |
| 10 | +```properties |
| 11 | +# NOTE: Replace the test DSN below with YOUR OWN DSN to see the events from this app in your Sentry project/dashboard |
| 12 | +dsn=https://502f25099c204a2fbf4cb16edc5975d1@o447951.ingest.sentry.io/5428563 |
| 13 | +traces-sample-rate=1.0 |
| 14 | +``` |
| 15 | + |
| 16 | +For more details on configuring Sentry via `sentry.properties` please see the |
| 17 | +[docs page](https://docs.sentry.io/platforms/java/configuration/). |
| 18 | + |
| 19 | +As an alternative to the `SENTRY_PROPERTIES_FILE` environment variable you can provide individual |
| 20 | +settings as environment variables (e.g. `SENTRY_DSN=...`) or you may initialize `Sentry` inside |
| 21 | +your target application. If you do so, please make sure to apply OpenTelemetry specific options, e.g. |
| 22 | +like this: |
| 23 | + |
| 24 | +``` |
| 25 | +Sentry.init( |
| 26 | + options -> { |
| 27 | + options.setDsn("..."); |
| 28 | + ... |
| 29 | + OpenTelemetryUtil.applyOpenTelemetryOptions(options, false); |
| 30 | + } |
| 31 | +) |
| 32 | +``` |
| 33 | + |
| 34 | +## Getting rid of exporter error messages |
| 35 | + |
| 36 | +In case you are using this module without needing to use any OpenTelemetry exporters you can add |
| 37 | +the following environment variables to turn off exporters and stop seeing error messages about |
| 38 | +servers not being reachable in the logs. |
| 39 | + |
| 40 | +Example log message: |
| 41 | +``` |
| 42 | +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 |
| 43 | +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 |
| 44 | +``` |
| 45 | + |
| 46 | +### Traces |
| 47 | + |
| 48 | +To turn off exporting of traces you can set `OTEL_TRACES_EXPORTER=none` |
| 49 | +see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters) |
| 50 | + |
| 51 | +### Metrics |
| 52 | + |
| 53 | +To turn off exporting of metrics you can set `OTEL_METRICS_EXPORTER=none` |
| 54 | +see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters) |
0 commit comments