From 6e3c15c74d0525f9082d81d7745dafb9a7b7911e Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Thu, 15 Dec 2022 13:35:24 +0100 Subject: [PATCH 1/4] Add docs for OTEL Java --- .../with-java-agent/java.mdx | 1 + .../without-java-agent/java.mdx | 5 ++ .../exporter-messages/java.mdx | 19 ++++++ .../with-auto-init/debugging/java.mdx | 4 ++ .../with-java-agent/with-auto-init/java.mdx | 12 ++++ .../without-auto-init/debugging/java.mdx | 4 ++ .../debugging/java.spring-boot.mdx | 4 ++ .../without-auto-init/java.mdx | 14 +++++ .../without-auto-init/java.spring-boot.mdx | 31 +++++++++ .../without-java-agent/java.mdx | 38 +++++++++++ .../without-java-agent/java.spring-boot.mdx | 54 ++++++++++++++++ .../instrumentation/opentelemetry.mdx | 63 +++++++++++++++++++ 12 files changed, 249 insertions(+) create mode 100644 src/platform-includes/performance/opentelemetry-install/with-java-agent/java.mdx create mode 100644 src/platform-includes/performance/opentelemetry-install/without-java-agent/java.mdx create mode 100644 src/platform-includes/performance/opentelemetry-setup/with-java-agent/exporter-messages/java.mdx create mode 100644 src/platform-includes/performance/opentelemetry-setup/with-java-agent/with-auto-init/debugging/java.mdx create mode 100644 src/platform-includes/performance/opentelemetry-setup/with-java-agent/with-auto-init/java.mdx create mode 100644 src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.mdx create mode 100644 src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.spring-boot.mdx create mode 100644 src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.mdx create mode 100644 src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.spring-boot.mdx create mode 100644 src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.mdx create mode 100644 src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.spring-boot.mdx create mode 100644 src/platforms/java/common/performance/instrumentation/opentelemetry.mdx diff --git a/src/platform-includes/performance/opentelemetry-install/with-java-agent/java.mdx b/src/platform-includes/performance/opentelemetry-install/with-java-agent/java.mdx new file mode 100644 index 00000000000000..563efff6bcaf45 --- /dev/null +++ b/src/platform-includes/performance/opentelemetry-install/with-java-agent/java.mdx @@ -0,0 +1 @@ +You can download the latest version of the `sentry-opentelemetry-agent-{{ packages.version('sentry.java.opentelemetry-agent') }}.zip` from [GitHub](https://github.com/getsentry/sentry-java/releases/) which contains the `JAR` file used in this docs page. diff --git a/src/platform-includes/performance/opentelemetry-install/without-java-agent/java.mdx b/src/platform-includes/performance/opentelemetry-install/without-java-agent/java.mdx new file mode 100644 index 00000000000000..3bd304a9ca31a4 --- /dev/null +++ b/src/platform-includes/performance/opentelemetry-install/without-java-agent/java.mdx @@ -0,0 +1,5 @@ +In addition to OpenTelemetry dependencies and your typical Sentry dependencies, you will need to add `sentry-opentelemetry-core` as a dependency: + +```groovy {tabTitle:Gradle} +implementation 'io.sentry:sentry-opentelemetry-core::{{ packages.version('sentry.java.opentelemetry-agent', '6.9.2') }}' +``` diff --git a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/exporter-messages/java.mdx b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/exporter-messages/java.mdx new file mode 100644 index 00000000000000..f9a0b653cc478d --- /dev/null +++ b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/exporter-messages/java.mdx @@ -0,0 +1,19 @@ +In case you are using `sentry-opentelemetry-agent` without needing to use any OpenTelemetry exporters you can add +the following environment variables to turn off exporters and stop seeing error messages about +servers not being reachable in the logs. + +Example log message: +``` +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 +``` + +#### Traces + +To turn off exporting of traces you can set `OTEL_TRACES_EXPORTER=none` as environment variable +see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters). + +#### Metrics + +To turn off exporting of metrics you can set `OTEL_METRICS_EXPORTER=none` as environment variable +see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters). diff --git a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/with-auto-init/debugging/java.mdx b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/with-auto-init/debugging/java.mdx new file mode 100644 index 00000000000000..21eb7592864861 --- /dev/null +++ b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/with-auto-init/debugging/java.mdx @@ -0,0 +1,4 @@ +To enable debug logging for Sentry, please provide `SENTRY_DEBUG=true` as environment variable or +add `debug=true` to your `sentry.properties`. + +To also show debug output for OpenTelemetry please add `-Dotel.javaagent.debug=true` to the `java` command. diff --git a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/with-auto-init/java.mdx b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/with-auto-init/java.mdx new file mode 100644 index 00000000000000..bb8fbf48bf616d --- /dev/null +++ b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/with-auto-init/java.mdx @@ -0,0 +1,12 @@ +This `java` command shows how to run your application using `sentry-opentelemetry-agent`: + +```bash +SENTRY_PROPERTIES_FILE=sentry.properties java -javaagent:sentry-opentelemetry-agent-{{ packages.version('sentry.java.opentelemetry-agent') }}.jar -jar your-application.jar +``` + +Here's the `sentry.properties` file that goes with it: + +```properties {filename:sentry.properties} +dsn=___DSN___ +traces-sample-rate=1.0 +``` diff --git a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.mdx b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.mdx new file mode 100644 index 00000000000000..21eb7592864861 --- /dev/null +++ b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.mdx @@ -0,0 +1,4 @@ +To enable debug logging for Sentry, please provide `SENTRY_DEBUG=true` as environment variable or +add `debug=true` to your `sentry.properties`. + +To also show debug output for OpenTelemetry please add `-Dotel.javaagent.debug=true` to the `java` command. diff --git a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.spring-boot.mdx b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.spring-boot.mdx new file mode 100644 index 00000000000000..2b6c9812ffe039 --- /dev/null +++ b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.spring-boot.mdx @@ -0,0 +1,4 @@ +To enable debug logging for Sentry, please provide `SENTRY_DEBUG=true` as environment variable or +add `sentry.debug=true` to your `application.properties`. + +To also show debug output for OpenTelemetry please add `-Dotel.javaagent.debug=true` to the command. diff --git a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.mdx b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.mdx new file mode 100644 index 00000000000000..47cd223cef54f5 --- /dev/null +++ b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.mdx @@ -0,0 +1,14 @@ +If you are not using the auto initialization provided by `sentry-opentelemetry-agent` (`SENTRY_AUTO_INIT=false`) you have to set the `instrumenter` option to `otel`. This disables all Sentry instrumentation and relies on the chosen OpenTelemetry tracers for creating spans. You also have to add the `OpenTelemetryLinkErrorEventProcessor` to ensure errors are properly linked to transactions that were created by the OpenTelemetry integration: + +```java {tabTitle: Java} +import io.sentry.Instrumenter; +import io.sentry.Sentry; +import io.sentry.opentelemetry.OpenTelemetryLinkErrorEventProcessor; + +Sentry.init(options -> { + options.setDsn("___PUBLIC_DSN___"); + options.setTracesSampleRate(1.0); + options.setInstrumenter(Instrumenter.OTEL); + options.addEventProcessor(new OpenTelemetryLinkErrorEventProcessor()); +}); +``` diff --git a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.spring-boot.mdx b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.spring-boot.mdx new file mode 100644 index 00000000000000..38719b0e9e1843 --- /dev/null +++ b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.spring-boot.mdx @@ -0,0 +1,31 @@ +If you are not using the auto initialization provided by `sentry-opentelemetry-agent` (`SENTRY_AUTO_INIT=false`) you have to +set the `instrumenter` option to `otel`. This disables all Sentry instrumentation and relies on the chosen OpenTelemetry tracers for creating spans. + +```properties {filename:application.properties} +sentry.dsn=___DSN___ +sentry.traces-sample-rate=1.0 +# enable this to see more logs +sentry.debug=false +# set the instrumenter to use OpenTelemetry instead of Sentry +sentry.instrumenter=otel +``` + +You also have to manually provide the `OpenTelemetryLinkErrorEventProcessor` bean to ensure errors are properly linked to transactions that were created by the OpenTelemetry integration: + +```java {filename:SentryDemoApplication.java} +import io.sentry.opentelemetry.OpenTelemetryLinkErrorEventProcessor; + +@SpringBootApplication +public class SentryDemoApplication { + public static void main(String[] args) { + SpringApplication.run(SentryDemoApplication.class, args); + } + + ... + + @Bean + OpenTelemetryLinkErrorEventProcessor otelLinkEventProcessor() { + return new OpenTelemetryLinkErrorEventProcessor(); + } +} +``` diff --git a/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.mdx b/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.mdx new file mode 100644 index 00000000000000..4efb4b046d44ac --- /dev/null +++ b/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.mdx @@ -0,0 +1,38 @@ +#### Initializing OpenTelemetry + +```Java +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.context.propagation.ContextPropagators; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import io.opentelemetry.sdk.trace.SdkTracerProvider; + +import io.sentry.opentelemetry.SentryPropagator; +import io.sentry.opentelemetry.SentrySpanProcessor; + + +SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder() + .addSpanProcessor(new SentrySpanProcessor()) + .build(); + +OpenTelemetry openTelemetry = OpenTelemetrySdk.builder() + .setTracerProvider(sdkTracerProvider) + .setPropagators(ContextPropagators.create(new SentryPropagator())) + .buildAndRegisterGlobal(); +``` + +#### Initializing Sentry + +You have to set the `instrumenter` option to `otel`. This disables all Sentry instrumentation and relies on the chosen OpenTelemetry tracers for creating spans. You also have to add the `OpenTelemetryLinkErrorEventProcessor` to ensure errors are properly linked to transactions that were created by the OpenTelemetry integration: + +```java {tabTitle: Java} +import io.sentry.Instrumenter; +import io.sentry.Sentry; +import io.sentry.opentelemetry.OpenTelemetryLinkErrorEventProcessor; + +Sentry.init(options -> { + options.setDsn("___PUBLIC_DSN___"); + options.setTracesSampleRate(1.0); + options.setInstrumenter(Instrumenter.OTEL); + options.addEventProcessor(new OpenTelemetryLinkErrorEventProcessor()); +}); +``` diff --git a/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.spring-boot.mdx b/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.spring-boot.mdx new file mode 100644 index 00000000000000..cdcffd44513486 --- /dev/null +++ b/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.spring-boot.mdx @@ -0,0 +1,54 @@ +#### Initializing OpenTelemetry + +```Java +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.context.propagation.ContextPropagators; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import io.opentelemetry.sdk.trace.SdkTracerProvider; + +import io.sentry.opentelemetry.SentryPropagator; +import io.sentry.opentelemetry.SentrySpanProcessor; + + +SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder() + .addSpanProcessor(new SentrySpanProcessor()) + .build(); + +OpenTelemetry openTelemetry = OpenTelemetrySdk.builder() + .setTracerProvider(sdkTracerProvider) + .setPropagators(ContextPropagators.create(new SentryPropagator())) + .buildAndRegisterGlobal(); +``` + +#### Initializing Sentry + +You have to set the `instrumenter` option to `otel`. This disables all Sentry instrumentation and relies on the chosen OpenTelemetry tracers for creating spans. + +```properties {filename:application.properties} +sentry.dsn=___DSN___ +sentry.traces-sample-rate=1.0 +# enable this to see more logs +sentry.debug=false +# set the instrumenter to use OpenTelemetry instead of Sentry +sentry.instrumenter=otel +``` + +You also have to manually provide the `OpenTelemetryLinkErrorEventProcessor` bean to ensure errors are properly linked to transactions that were created by the OpenTelemetry integration: + +```java {filename:SentryDemoApplication.java} +import io.sentry.opentelemetry.OpenTelemetryLinkErrorEventProcessor; + +@SpringBootApplication +public class SentryDemoApplication { + public static void main(String[] args) { + SpringApplication.run(SentryDemoApplication.class, args); + } + + ... + + @Bean + OpenTelemetryLinkErrorEventProcessor otelLinkEventProcessor() { + return new OpenTelemetryLinkErrorEventProcessor(); + } +} +``` diff --git a/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx b/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx new file mode 100644 index 00000000000000..4f835993844557 --- /dev/null +++ b/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx @@ -0,0 +1,63 @@ +--- +title: OpenTelemetry Support +sidebar_order: 20 +description: "Using OpenTelemetry with Sentry Performance." +--- + + + +You can configure your [OpenTelemetry SDK](https://opentelemetry.io/) to send traces and spans to Sentry. + +There are multiple ways of combining OpenTelemetry and Sentry. + +## Using `sentry-opentelemetry-agent` with auto initialization + +By default, if you use `sentry-opentelemetry-agent`, it will look for `SENTRY_DSN` and `SENTRY_PROPERTIES_FILE` environment variables to be defined. If either of those is set, `sentry-opentelemetry-agent` will initialize Sentry automatically and you don't have to perform any setup work besides configuring your `DSN` and `tracesSampleRate`. + +### Install + + + +### Usage + + + +### Debugging + + + +### Getting rid of exporter error messages + + + +## Using `sentry-opentelemetry-agent` without auto initialization + +You may also disable automatic initialization of Sentry in `sentry-opentelemetry-agent` by setting `SENTRY_AUTO_INIT=false` as environment variable. This means you will either have to use another Sentry integration that performs initialization, for example Spring Boot, or initialize Sentry manually. + +### Install + + + +### Usage + + + +### Debugging + + + +### Getting rid of exporter error messages + + + +## Using OpenTelemetry without any Java Agent + +When manually initializing OpenTelemetry you have to register a few Sentry classes. + +### Install + + + +### Usage + + From cda847e7feb02d17a392e9afc7fcbc038be29de4 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Mon, 19 Dec 2022 14:16:01 +0100 Subject: [PATCH 2/4] Update src/platforms/java/common/performance/instrumentation/opentelemetry.mdx Co-authored-by: Liza Mock --- .../java/common/performance/instrumentation/opentelemetry.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx b/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx index 4f835993844557..a639bf22831638 100644 --- a/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx +++ b/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx @@ -6,9 +6,9 @@ description: "Using OpenTelemetry with Sentry Performance." -You can configure your [OpenTelemetry SDK](https://opentelemetry.io/) to send traces and spans to Sentry. +There are multiple ways of configuring your [OpenTelemetry SDK](https://opentelemetry.io/) to send traces and spans to Sentry. + -There are multiple ways of combining OpenTelemetry and Sentry. ## Using `sentry-opentelemetry-agent` with auto initialization From 9825b5283e273590963de48fda486c0086a7d973 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Mon, 19 Dec 2022 14:20:38 +0100 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Liza Mock --- .../with-java-agent/exporter-messages/java.mdx | 10 ++++------ .../with-auto-init/debugging/java.mdx | 4 ++-- .../without-auto-init/debugging/java.mdx | 4 ++-- .../without-auto-init/debugging/java.spring-boot.mdx | 4 ++-- .../with-java-agent/without-auto-init/java.mdx | 2 +- .../without-auto-init/java.spring-boot.mdx | 4 ++-- .../opentelemetry-setup/without-java-agent/java.mdx | 4 +++- .../without-java-agent/java.spring-boot.mdx | 2 +- .../performance/instrumentation/opentelemetry.mdx | 12 ++++++------ 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/exporter-messages/java.mdx b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/exporter-messages/java.mdx index f9a0b653cc478d..b775f44e6fd03d 100644 --- a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/exporter-messages/java.mdx +++ b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/exporter-messages/java.mdx @@ -1,5 +1,5 @@ -In case you are using `sentry-opentelemetry-agent` without needing to use any OpenTelemetry exporters you can add -the following environment variables to turn off exporters and stop seeing error messages about +If you're using `sentry-opentelemetry-agent` but don't need to use OpenTelemetry exporters, 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: @@ -10,10 +10,8 @@ ERROR io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter - Failed to exp #### Traces -To turn off exporting of traces you can set `OTEL_TRACES_EXPORTER=none` as environment variable -see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters). +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 -To turn off exporting of metrics you can set `OTEL_METRICS_EXPORTER=none` as environment variable -see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters). +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). diff --git a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/with-auto-init/debugging/java.mdx b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/with-auto-init/debugging/java.mdx index 21eb7592864861..049fab21a4177f 100644 --- a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/with-auto-init/debugging/java.mdx +++ b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/with-auto-init/debugging/java.mdx @@ -1,4 +1,4 @@ -To enable debug logging for Sentry, please provide `SENTRY_DEBUG=true` as environment variable or +To enable debug logging in Sentry, set `SENTRY_DEBUG=true` as an environment variable or add `debug=true` to your `sentry.properties`. -To also show debug output for OpenTelemetry please add `-Dotel.javaagent.debug=true` to the `java` command. +To show debug output for OpenTelemetry, add `-Dotel.javaagent.debug=true` to the `java` command. diff --git a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.mdx b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.mdx index 21eb7592864861..049fab21a4177f 100644 --- a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.mdx +++ b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.mdx @@ -1,4 +1,4 @@ -To enable debug logging for Sentry, please provide `SENTRY_DEBUG=true` as environment variable or +To enable debug logging in Sentry, set `SENTRY_DEBUG=true` as an environment variable or add `debug=true` to your `sentry.properties`. -To also show debug output for OpenTelemetry please add `-Dotel.javaagent.debug=true` to the `java` command. +To show debug output for OpenTelemetry, add `-Dotel.javaagent.debug=true` to the `java` command. diff --git a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.spring-boot.mdx b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.spring-boot.mdx index 2b6c9812ffe039..f38646dfced849 100644 --- a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.spring-boot.mdx +++ b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/debugging/java.spring-boot.mdx @@ -1,4 +1,4 @@ -To enable debug logging for Sentry, please provide `SENTRY_DEBUG=true` as environment variable or +To enable debug logging for Sentry, set `SENTRY_DEBUG=true` as an environment variable or add `sentry.debug=true` to your `application.properties`. -To also show debug output for OpenTelemetry please add `-Dotel.javaagent.debug=true` to the command. +To show debug output for OpenTelemetry, add `-Dotel.javaagent.debug=true` to the command. diff --git a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.mdx b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.mdx index 47cd223cef54f5..ee9f1e402d7375 100644 --- a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.mdx +++ b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.mdx @@ -1,4 +1,4 @@ -If you are not using the auto initialization provided by `sentry-opentelemetry-agent` (`SENTRY_AUTO_INIT=false`) you have to set the `instrumenter` option to `otel`. This disables all Sentry instrumentation and relies on the chosen OpenTelemetry tracers for creating spans. You also have to add the `OpenTelemetryLinkErrorEventProcessor` to ensure errors are properly linked to transactions that were created by the OpenTelemetry integration: +If you're not using the auto initialization provided by `sentry-opentelemetry-agent` (`SENTRY_AUTO_INIT=false`), you have to set the `instrumenter` option to `otel`. This disables all Sentry instrumentation and uses the chosen OpenTelemetry tracers for creating spans instead. To ensure errors are properly linked to transactions that were created by the OpenTelemetry integration, add the `OpenTelemetryLinkErrorEventProcessor`: ```java {tabTitle: Java} import io.sentry.Instrumenter; diff --git a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.spring-boot.mdx b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.spring-boot.mdx index 38719b0e9e1843..8f649401c9db5f 100644 --- a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.spring-boot.mdx +++ b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.spring-boot.mdx @@ -1,5 +1,5 @@ -If you are not using the auto initialization provided by `sentry-opentelemetry-agent` (`SENTRY_AUTO_INIT=false`) you have to -set the `instrumenter` option to `otel`. This disables all Sentry instrumentation and relies on the chosen OpenTelemetry tracers for creating spans. +If you're not using the auto initialization provided by `sentry-opentelemetry-agent` (`SENTRY_AUTO_INIT=false`), you have to +set the `instrumenter` option to `otel`. This disables all Sentry instrumentation and uses the chosen OpenTelemetry tracers for creating spans instead: ```properties {filename:application.properties} sentry.dsn=___DSN___ diff --git a/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.mdx b/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.mdx index 4efb4b046d44ac..fe537966792587 100644 --- a/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.mdx +++ b/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.mdx @@ -22,7 +22,9 @@ OpenTelemetry openTelemetry = OpenTelemetrySdk.builder() #### Initializing Sentry -You have to set the `instrumenter` option to `otel`. This disables all Sentry instrumentation and relies on the chosen OpenTelemetry tracers for creating spans. You also have to add the `OpenTelemetryLinkErrorEventProcessor` to ensure errors are properly linked to transactions that were created by the OpenTelemetry integration: +You have to set the `instrumenter` option to `otel`. This disables all Sentry instrumentation and uses the chosen OpenTelemetry tracers for creating spans. + +To ensure errors are properly linked to transactions that were created by the OpenTelemetry integration, add the `OpenTelemetryLinkErrorEventProcessor`: ```java {tabTitle: Java} import io.sentry.Instrumenter; diff --git a/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.spring-boot.mdx b/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.spring-boot.mdx index cdcffd44513486..3ed4deac47658f 100644 --- a/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.spring-boot.mdx +++ b/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.spring-boot.mdx @@ -22,7 +22,7 @@ OpenTelemetry openTelemetry = OpenTelemetrySdk.builder() #### Initializing Sentry -You have to set the `instrumenter` option to `otel`. This disables all Sentry instrumentation and relies on the chosen OpenTelemetry tracers for creating spans. +You have to set the `instrumenter` option to `otel`. This disables all Sentry instrumentation and uses the chosen OpenTelemetry tracers for creating spans instead. ```properties {filename:application.properties} sentry.dsn=___DSN___ diff --git a/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx b/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx index a639bf22831638..b82880d07172d8 100644 --- a/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx +++ b/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx @@ -10,9 +10,9 @@ There are multiple ways of configuring your [OpenTelemetry SDK](https://opentele -## Using `sentry-opentelemetry-agent` with auto initialization +## Using `sentry-opentelemetry-agent` With Auto Initialization -By default, if you use `sentry-opentelemetry-agent`, it will look for `SENTRY_DSN` and `SENTRY_PROPERTIES_FILE` environment variables to be defined. If either of those is set, `sentry-opentelemetry-agent` will initialize Sentry automatically and you don't have to perform any setup work besides configuring your `DSN` and `tracesSampleRate`. +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. Only your `DSN` and `tracesSampleRate` need to be configured. ### Install @@ -26,11 +26,11 @@ By default, if you use `sentry-opentelemetry-agent`, it will look for `SENTRY_DS -### Getting rid of exporter error messages +### Turn Off Exporter Error Messages -## Using `sentry-opentelemetry-agent` without auto initialization +## Using `sentry-opentelemetry-agent` Without Auto Initialization You may also disable automatic initialization of Sentry in `sentry-opentelemetry-agent` by setting `SENTRY_AUTO_INIT=false` as environment variable. This means you will either have to use another Sentry integration that performs initialization, for example Spring Boot, or initialize Sentry manually. @@ -46,11 +46,11 @@ You may also disable automatic initialization of Sentry in `sentry-opentelemetry -### Getting rid of exporter error messages +### Turn Off Exporter Error Messages -## Using OpenTelemetry without any Java Agent +## Using OpenTelemetry Without Any Java Agent When manually initializing OpenTelemetry you have to register a few Sentry classes. From 8cf6bb56b386b4895b0e116f6d75c5715d257cdf Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Mon, 19 Dec 2022 15:17:03 +0100 Subject: [PATCH 4/4] Update according to feedback; fix dependency docs; remove bean config for spring boot --- .../{ => with-auto-init}/java.mdx | 0 .../without-auto-init/java.mdx | 7 +++++++ .../without-java-agent/java.mdx | 2 +- .../without-auto-init/java.spring-boot.mdx | 20 ------------------- .../without-java-agent/java.mdx | 4 +++- .../without-java-agent/java.spring-boot.mdx | 2 ++ .../instrumentation/opentelemetry.mdx | 10 +++++----- 7 files changed, 18 insertions(+), 27 deletions(-) rename src/platform-includes/performance/opentelemetry-install/with-java-agent/{ => with-auto-init}/java.mdx (100%) create mode 100644 src/platform-includes/performance/opentelemetry-install/with-java-agent/without-auto-init/java.mdx diff --git a/src/platform-includes/performance/opentelemetry-install/with-java-agent/java.mdx b/src/platform-includes/performance/opentelemetry-install/with-java-agent/with-auto-init/java.mdx similarity index 100% rename from src/platform-includes/performance/opentelemetry-install/with-java-agent/java.mdx rename to src/platform-includes/performance/opentelemetry-install/with-java-agent/with-auto-init/java.mdx diff --git a/src/platform-includes/performance/opentelemetry-install/with-java-agent/without-auto-init/java.mdx b/src/platform-includes/performance/opentelemetry-install/with-java-agent/without-auto-init/java.mdx new file mode 100644 index 00000000000000..100c6a9186146a --- /dev/null +++ b/src/platform-includes/performance/opentelemetry-install/with-java-agent/without-auto-init/java.mdx @@ -0,0 +1,7 @@ +You can download the latest version of the `sentry-opentelemetry-agent-{{ packages.version('sentry.java.opentelemetry-agent') }}.zip` from [GitHub](https://github.com/getsentry/sentry-java/releases/) which contains the `JAR` file used in this docs page. + +To ensure errors are properly linked to transactions that were created by the OpenTelemetry integration, you need an additional dependency: + +```groovy {tabTitle:Gradle} +implementation 'io.sentry:sentry-opentelemetry-core:{{ packages.version('sentry.java.opentelemetry-core', '6.9.2') }}' +``` diff --git a/src/platform-includes/performance/opentelemetry-install/without-java-agent/java.mdx b/src/platform-includes/performance/opentelemetry-install/without-java-agent/java.mdx index 3bd304a9ca31a4..b5046d319ebb37 100644 --- a/src/platform-includes/performance/opentelemetry-install/without-java-agent/java.mdx +++ b/src/platform-includes/performance/opentelemetry-install/without-java-agent/java.mdx @@ -1,5 +1,5 @@ In addition to OpenTelemetry dependencies and your typical Sentry dependencies, you will need to add `sentry-opentelemetry-core` as a dependency: ```groovy {tabTitle:Gradle} -implementation 'io.sentry:sentry-opentelemetry-core::{{ packages.version('sentry.java.opentelemetry-agent', '6.9.2') }}' +implementation 'io.sentry:sentry-opentelemetry-core:{{ packages.version('sentry.java.opentelemetry-core', '6.9.2') }}' ``` diff --git a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.spring-boot.mdx b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.spring-boot.mdx index 8f649401c9db5f..ca94eb7863d64f 100644 --- a/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.spring-boot.mdx +++ b/src/platform-includes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.spring-boot.mdx @@ -9,23 +9,3 @@ sentry.debug=false # set the instrumenter to use OpenTelemetry instead of Sentry sentry.instrumenter=otel ``` - -You also have to manually provide the `OpenTelemetryLinkErrorEventProcessor` bean to ensure errors are properly linked to transactions that were created by the OpenTelemetry integration: - -```java {filename:SentryDemoApplication.java} -import io.sentry.opentelemetry.OpenTelemetryLinkErrorEventProcessor; - -@SpringBootApplication -public class SentryDemoApplication { - public static void main(String[] args) { - SpringApplication.run(SentryDemoApplication.class, args); - } - - ... - - @Bean - OpenTelemetryLinkErrorEventProcessor otelLinkEventProcessor() { - return new OpenTelemetryLinkErrorEventProcessor(); - } -} -``` diff --git a/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.mdx b/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.mdx index fe537966792587..e1273a068ef69a 100644 --- a/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.mdx +++ b/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.mdx @@ -1,5 +1,7 @@ #### Initializing OpenTelemetry +When manually initializing OpenTelemetry you have to add `SentrySpanProcessor` and `SentryPropagator` to your configuration. + ```Java import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.context.propagation.ContextPropagators; @@ -22,7 +24,7 @@ OpenTelemetry openTelemetry = OpenTelemetrySdk.builder() #### Initializing Sentry -You have to set the `instrumenter` option to `otel`. This disables all Sentry instrumentation and uses the chosen OpenTelemetry tracers for creating spans. +You have to set the `instrumenter` option to `otel`. This disables all Sentry instrumentation and uses the chosen OpenTelemetry tracers for creating spans. To ensure errors are properly linked to transactions that were created by the OpenTelemetry integration, add the `OpenTelemetryLinkErrorEventProcessor`: diff --git a/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.spring-boot.mdx b/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.spring-boot.mdx index 3ed4deac47658f..a7f11c222f91d7 100644 --- a/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.spring-boot.mdx +++ b/src/platform-includes/performance/opentelemetry-setup/without-java-agent/java.spring-boot.mdx @@ -1,5 +1,7 @@ #### Initializing OpenTelemetry +When manually initializing OpenTelemetry you have to add `SentrySpanProcessor` and `SentryPropagator` to your configuration. + ```Java import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.context.propagation.ContextPropagators; diff --git a/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx b/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx index b82880d07172d8..be12cd71804efd 100644 --- a/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx +++ b/src/platforms/java/common/performance/instrumentation/opentelemetry.mdx @@ -8,15 +8,13 @@ description: "Using OpenTelemetry with Sentry Performance." There are multiple ways of configuring your [OpenTelemetry SDK](https://opentelemetry.io/) to send traces and spans to Sentry. - - ## Using `sentry-opentelemetry-agent` With Auto Initialization 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. Only your `DSN` and `tracesSampleRate` need to be configured. ### Install - + ### Usage @@ -36,7 +34,7 @@ You may also disable automatic initialization of Sentry in `sentry-opentelemetry ### Install - + ### Usage @@ -52,7 +50,7 @@ You may also disable automatic initialization of Sentry in `sentry-opentelemetry ## Using OpenTelemetry Without Any Java Agent -When manually initializing OpenTelemetry you have to register a few Sentry classes. +If the Java Agent approach is not for you, you may also manually initialize OpenTelemetry. We have a separate dependency for this use case that allows you to reuse classes used by `sentry-opentelemetry-agent`. ### Install @@ -60,4 +58,6 @@ When manually initializing OpenTelemetry you have to register a few Sentry class ### Usage +You will have to configure both OpenTelemetry and Sentry to see transactions in Sentry and have errors linked to transactions created by OpenTelemetry. +