-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update OpenTelemetry dosc for Java v8 #12209
Open
adinauer
wants to merge
1
commit into
feat/java-v8-changes
Choose a base branch
from
feat/java-v8-otel
base: feat/java-v8-changes
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
...es/performance/opentelemetry-install/with-java-agent/without-auto-init/java.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
You can download the latest version of the `sentry-opentelemetry-agent-{{@inject packages.version('sentry.java.opentelemetry-agent') }}.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/). | ||
|
||
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:{{@inject packages.version('sentry.java.opentelemetry-core', '6.9.2') }}' | ||
``` |
13 changes: 11 additions & 2 deletions
13
platform-includes/performance/opentelemetry-install/without-java-agent/java.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
In addition to OpenTelemetry dependencies and your typical Sentry dependencies, you will need to add `sentry-opentelemetry-core` as a dependency: | ||
In addition to your typical Sentry dependencies, you will need to add `sentry-opentelemetry-agentless` as a dependency: | ||
|
||
```groovy {tabTitle:Gradle} | ||
implementation 'io.sentry:sentry-opentelemetry-core:{{@inject packages.version('sentry.java.opentelemetry-core', '6.9.2') }}' | ||
implementation 'io.sentry:sentry-opentelemetry-agentless:{{@inject packages.version('sentry.java.opentelemetry-agentless', '8.0.0') }}' | ||
``` | ||
```xml {tabTitle:Maven} | ||
<dependency> | ||
<groupId>io.sentry</groupId> | ||
<artifactId>sentry-opentelemetry-agentless</artifactId> | ||
<version>{{@inject packages.version('sentry.java.opentelemetry-agentless', '8.0.0') }}</version> | ||
</dependency> | ||
``` | ||
|
||
Please note, if you're using Spring Boot, there's a separate `sentry-opentelemetry-agentless-spring` dependency. You can <PlatformLink to="/guides/spring-boot/tracing/instrumentation/opentelemetry/">find out more here</PlatformLink>. |
12 changes: 12 additions & 0 deletions
12
...ludes/performance/opentelemetry-install/without-java-agent/java.spring-boot.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
In addition to the Sentry Spring Boot SDK, you will need to add `sentry-opentelemetry-agentless-spring` as a dependency: | ||
|
||
```groovy {tabTitle:Gradle} | ||
implementation 'io.sentry:sentry-opentelemetry-agentless-spring:{{@inject packages.version('sentry.java.opentelemetry-agentless-spring', '8.0.0') }}' | ||
``` | ||
```xml {tabTitle:Maven} | ||
<dependency> | ||
<groupId>io.sentry</groupId> | ||
<artifactId>sentry-opentelemetry-agentless-spring</artifactId> | ||
<version>{{@inject packages.version('sentry.java.opentelemetry-agentless-spring', '8.0.0') }}</version> | ||
</dependency> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...elemetry-setup/with-java-agent/without-auto-init/debugging/java.spring-boot.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
To enable debug logging for Sentry, set `SENTRY_DEBUG=true` as an environment variable or | ||
add `sentry.debug=true` to your `application.properties`. | ||
|
||
To show debug output for OpenTelemetry, add `-Dotel.javaagent.debug=true` to the command. | ||
To show debug output for OpenTelemetry, add `-Dotel.javaagent.debug=true` to the `java` command. |
16 changes: 7 additions & 9 deletions
16
...udes/performance/opentelemetry-setup/with-java-agent/without-auto-init/java.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,26 @@ | ||
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`: | ||
This `java` command shows how to run your application using `sentry-opentelemetry-agent`: | ||
|
||
|
||
```bash | ||
SENTRY_AUTO_INIT=false java -javaagent:sentry-opentelemetry-agent-{{@inject packages.version('sentry.java.opentelemetry-agent') }}.jar -jar your-application.jar | ||
``` | ||
|
||
You can combine this with a Sentry integration, that performs the initialization for you or call `Sentry.init` manually: | ||
|
||
```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()); | ||
}); | ||
``` | ||
|
||
```kotlin {tabTitle: Kotlin} | ||
import io.sentry.Instrumenter | ||
import io.sentry.Sentry | ||
import io.sentry.opentelemetry.OpenTelemetryLinkErrorEventProcessor | ||
|
||
Sentry.init { options -> | ||
options.dsn = "___PUBLIC_DSN___" | ||
options.tracesSampleRate = 1.0 | ||
options.instrumenter = Instrumenter.OTEL | ||
options.addEventProcessor(OpenTelemetryLinkErrorEventProcessor()) | ||
} | ||
``` |
21 changes: 14 additions & 7 deletions
21
...ance/opentelemetry-setup/with-java-agent/without-auto-init/java.spring-boot.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
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: | ||
This `java` command shows how to run your application using `sentry-opentelemetry-agent`: | ||
|
||
|
||
```properties {filename:application.properties} | ||
```bash | ||
SENTRY_AUTO_INIT=false java -javaagent:sentry-opentelemetry-agent-{{@inject packages.version('sentry.java.opentelemetry-agent') }}.jar -jar your-application.jar | ||
``` | ||
|
||
The Spring Boot Sentry SDK will take care of initializing Sentry, just make sure a `tracesSampleRate` has been set: | ||
|
||
```properties {tabTitle: application.properties} | ||
sentry.dsn=___PUBLIC_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 | ||
``` | ||
|
||
```yaml {tabTitle: application.yml} | ||
sentry: | ||
dsn: ___PUBLIC_DSN___ | ||
traces-sample-rate: 1.0 | ||
``` |
74 changes: 30 additions & 44 deletions
74
platform-includes/performance/opentelemetry-setup/without-java-agent/java.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,75 +1,61 @@ | ||||||
#### Initializing OpenTelemetry | ||||||
|
||||||
When manually initializing OpenTelemetry you have to add `SentrySpanProcessor` and `SentryPropagator` to your configuration. | ||||||
Our `sentry-opentelemetry-agentless` dependency also adds `opentelemetry-sdk-extension-autoconfigure` which takes care of configuring OpenTelemetry to work with Sentry. There's two ways to trigger it. | ||||||
|
||||||
```java {tabTitle: 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; | ||||||
1. Using a property on startup | ||||||
|
||||||
Add `-Dotel.java.global-autoconfigure.enabled=true` to the `java` command when starting your application. | ||||||
|
||||||
SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder() | ||||||
.addSpanProcessor(new SentrySpanProcessor()) | ||||||
.build(); | ||||||
2. Using `AutoConfiguredOpenTelemetrySdk` | ||||||
|
||||||
OpenTelemetry openTelemetry = OpenTelemetrySdk.builder() | ||||||
.setTracerProvider(sdkTracerProvider) | ||||||
.setPropagators(ContextPropagators.create(new SentryPropagator())) | ||||||
.buildAndRegisterGlobal(); | ||||||
```java {tabTitle: Java} | ||||||
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(); | ||||||
``` | ||||||
|
||||||
```kotlin {tabTitle: Kotlin} | ||||||
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 | ||||||
|
||||||
val sdkTracerProvider = SdkTracerProvider.builder() | ||||||
.addSpanProcessor(SentrySpanProcessor()) | ||||||
.build() | ||||||
|
||||||
val openTelemetry = OpenTelemetrySdk.builder() | ||||||
.setTracerProvider(sdkTracerProvider) | ||||||
.setPropagators(ContextPropagators.create(SentryPropagator())) | ||||||
.buildAndRegisterGlobal() | ||||||
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() | ||||||
``` | ||||||
|
||||||
#### 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. | ||||||
|
||||||
To ensure errors are properly linked to transactions that were created by the OpenTelemetry integration, add the `OpenTelemetryLinkErrorEventProcessor`: | ||||||
|
||||||
You can initialize Sentry as usual, e.g. by calling `Sentry.init`: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
```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()); | ||||||
}); | ||||||
``` | ||||||
|
||||||
```kotlin {tabTitle: Kotlin} | ||||||
import io.sentry.Instrumenter | ||||||
import io.sentry.Sentry | ||||||
import io.sentry.opentelemetry.OpenTelemetryLinkErrorEventProcessor | ||||||
|
||||||
Sentry.init { options -> | ||||||
options.dsn = "___PUBLIC_DSN___" | ||||||
options.tracesSampleRate = 1.0 | ||||||
options.instrumenter = Instrumenter.OTEL | ||||||
options.addEventProcessor(OpenTelemetryLinkErrorEventProcessor()) | ||||||
} | ||||||
``` |
93 changes: 12 additions & 81 deletions
93
...ncludes/performance/opentelemetry-setup/without-java-agent/java.spring-boot.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,23 @@ | ||
#### Initializing OpenTelemetry | ||
|
||
When manually initializing OpenTelemetry you have to add `SentrySpanProcessor` and `SentryPropagator` to your configuration. | ||
Our `sentry-opentelemetry-agentless-spring` dependency also adds `opentelemetry-spring-boot-starter` which takes care of configuring OpenTelemetry to work with Sentry. | ||
|
||
```java {tabTitle: 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; | ||
Enable the Sentry propagator for OpenTelemetry by adding the following to your Spring configuration: | ||
|
||
|
||
SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder() | ||
.addSpanProcessor(new SentrySpanProcessor()) | ||
.build(); | ||
|
||
OpenTelemetry openTelemetry = OpenTelemetrySdk.builder() | ||
.setTracerProvider(sdkTracerProvider) | ||
.setPropagators(ContextPropagators.create(new SentryPropagator())) | ||
.buildAndRegisterGlobal(); | ||
``` | ||
|
||
```kotlin {tabTitle: Kotlin} | ||
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 | ||
|
||
val sdkTracerProvider = SdkTracerProvider.builder() | ||
.addSpanProcessor(SentrySpanProcessor()) | ||
.build() | ||
|
||
val openTelemetry = OpenTelemetrySdk.builder() | ||
.setTracerProvider(sdkTracerProvider) | ||
.setPropagators(ContextPropagators.create(SentryPropagator())) | ||
.buildAndRegisterGlobal() | ||
``` | ||
|
||
#### 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 instead. | ||
|
||
|
||
```properties {filename:application.properties} | ||
```properties {tabTitle: application.properties} | ||
sentry.dsn=___PUBLIC_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 | ||
otel.propagators=sentry | ||
``` | ||
|
||
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(); | ||
} | ||
} | ||
```yaml {tabTitle: application.yml} | ||
sentry: | ||
dsn: ___PUBLIC_DSN___ | ||
traces-sample-rate: 1.0 | ||
otel: | ||
propagators: | ||
- sentry | ||
``` | ||
|
||
```kotlin {filename:SentryDemoApplication.kt} | ||
import io.sentry.opentelemetry.OpenTelemetryLinkErrorEventProcessor | ||
|
||
@SpringBootApplication | ||
public class SentryDemoApplication { | ||
fun main(args: Array<String>) { | ||
SpringApplication.run(SentryDemoApplication.class, args); | ||
} | ||
|
||
@Bean | ||
fun otelLinkEventProcessor(): OpenTelemetryLinkErrorEventProcessor { | ||
return OpenTelemetryLinkErrorEventProcessor() | ||
} | ||
} | ||
``` | ||
The Sentry Spring Boot SDK will take care of the rest. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.