You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/java/common/migration/7.x-to-8.0.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,7 +109,7 @@ If you've been using the previous version of `sentry-opentelemetry-agent`, simpl
109
109
If you've not been using the Sentry OpenTelemetry agent before, you can add `sentry-opentelemetry-agent` to your setup by downloading the latest release and using it when starting up your application
- Please use `sentry.properties` or environment variables to configure the SDK as the agent is now in charge of initializing the SDK and options coming from things like logging integrations or our Spring Boot integration will not take effect.
112
-
- You may find the [docs page](https://docs.sentry.io/platforms/java/tracing/instrumentation/opentelemetry/#using-sentry-opentelemetry-agent-with-auto-initialization) useful.
112
+
- You may find the <PlatformLinkto="/opentelemetry/setup/agent/auto-init/">docs page</PlatformLink> useful.
113
113
114
114
If you want to skip auto initialization of the SDK performed by the agent, please follow the steps above and set the environment variable `SENTRY_AUTO_INIT` to `false`, then use `Sentry.init` as usual.
[OpenTelemetry](https://opentelemetry.io/) enhances Sentry by providing support for more frameworks and libraries that:
9
+
10
+
- Let you create more spans, for example around requests.
11
+
- Provide `Context` propagation that also takes care of propagating Sentry `Scopes`, ensuring things like tags and other information end up on the correct event.
12
+
- Extract tracing information from incoming requests and consumed messages.
13
+
- Inject tracing information into outgoing requests and produced messages.
14
+
15
+
Please take a look at the [OpenTelemetry GitHub repository](https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation) for a full list of available instrumentations.
16
+
17
+
In some cases there is instrumentation available by both OpenTelemetry and Sentry. In this case we automatically configure the Sentry instrumentation to not create spans and instead let OpenTelemetry take over.
18
+
19
+
You may use OpenTelemetry API or Sentry API to manually instrument your application. Both will end up in Sentry. If you are already using Sentry API, you can keep using it when switching over to our OpenTelemetry integration. If you already have OpenTelemetry instrumentation in place you can have the resulting spans sent to Sentry.
description: "Using OpenTelemetry with sentry-opentelemetry-agent and AUTO_INIT enabled."
5
+
sidebar_order: 100
6
+
---
7
+
8
+
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`.
When using `sentry-opentelemetry-agent` you can choose whether the Agent should call `Sentry.init`.
11
+
By default the Agent will initialize Sentry for you. If you prefer to manually initialize Sentry or have another integration perform the init you can disable this behaviour.
description: "Using OpenTelemetry with sentry-opentelemetry-agent and AUTO_INIT disabled."
5
+
sidebar_order: 200
6
+
---
7
+
8
+
You may also disable automatic initialization of Sentry in `sentry-opentelemetry-agent` by setting `SENTRY_AUTO_INIT=false` as an environment variable. Doing this will mean you'll either have to use another Sentry integration that performs initialization, (for example Spring Boot), or initialize Sentry manually.
description: "Using OpenTelemetry with sentry-opentelemetry-agentless."
5
+
sidebar_order: 200
6
+
---
7
+
8
+
If our recommended <PlatformLinkto="/opentelemetry/agent">Java Agent approach</PlatformLink> isn't for you, we have a separate dependency for this use case.
description: "Setting up Sentry with OpenTelemetry."
5
+
sidebar_order: 160
6
+
---
7
+
8
+
There are multiple ways to configure our OpenTelemetry integration. You may chose between using our Java Agent or using one of our agentless dependencies.
For a guide on how to set up `sentry-opentelemetry-agent`, please have a look at <PlatformLinkto="/opentelemetry/setup/agent">the detailed Agent docs</PlatformLink>.
For a guide on how to set up agentless, please have a look at <PlatformLinkto="/opentelemetry/setup/agentless">the detailed Agentless docs</PlatformLink>.
With Sentry’s OpenTelemetry SDK, an OpenTelemetry `Span` becomes a Sentry `Transaction` or `Span`. The first `Span` sent through the Sentry `SpanProcessor` is a `Transaction`, and any child `Span` gets attached to the first `Transaction` upon checking the parent `Span` context. This is true for the OpenTelemetry root `Span` and any top level `Span` in the system. For example, a request sent from frontend to backend will create an OpenTelemetry root `Span` with a corresponding Sentry `Transaction`. The backend request will create a new Sentry `Transaction` for the OpenTelemetry `Span`. The Sentry `Transaction` and `Span` are linked as a trace for navigation and error tracking purposes.
11
+
12
+
### Manual Instrumentation with OpenTelemetry
13
+
14
+
If you have the OpenTelemetry SDK in you classpath, you can also instrument your code manually using the OpenTelemetry API as documented [in the OpenTelemetry docs](https://opentelemetry.io/docs/languages/java/api/#span).
15
+
16
+
A manually created span for HTTP requests needs to declare its `SpanKind` as well as the `HttpAttributes.HTTP_REQUEST_METHOD` attribute, so that `Sentry` can correctly process these:
17
+
18
+
```java {tabTitle:Java}
19
+
Span span = tracer.spanBuilder("myspan")
20
+
.setAttribute(HTTP_REQUEST_METHOD, "GET")
21
+
.setSpanKind(SpanKind.SERVER)
22
+
.startSpan();
23
+
```
24
+
```kotlin {tabTitle:Kotlin}
25
+
val span = tracer.spanBuilder("myspan")
26
+
.setAttribute(HTTP_REQUEST_METHOD, "GET")
27
+
.setSpanKind(SpanKind.SERVER)
28
+
.startSpan()
29
+
```
30
+
31
+
### Capturing HTTP Headers
32
+
33
+
By default OpenTelemetry does not capture any HTTP headers. This, however, can be configured using system properties or environment variables as per OpenTelemetry's configuration documentation [here](https://opentelemetry.io/docs/zero-code/java/agent/instrumentation/http/#capturing-http-request-and-response-headers). Each variable is a comma-separated list of HTTP header names that should be captured.
If you need more fine grained control over Sentry, take a look at the <PlatformLinkto="/configuration/">Configuration page</PlatformLink>. In case you'd like to filter out transactions before sending them to Sentry (to get rid of health checks, for example), you may find the <PlatformLinkto="/configuration/filtering/#filtering-transaction-events">Filtering page</PlatformLink> helpful.
If you're unsure whether to use the Java Agent, please have a look at [what the OpenTelemetry SDK has to say about this](https://opentelemetry.io/docs/zero-code/java/spring-boot-starter/).
12
-
</PlatformSection>
13
-
14
-
## Using `sentry-opentelemetry-agent` With Auto Initialization
15
-
16
-
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`.
## Using `sentry-opentelemetry-agent` Without Auto-Initialization
35
-
36
-
You may also disable automatic initialization of Sentry in `sentry-opentelemetry-agent` by setting `SENTRY_AUTO_INIT=false` as an environment variable. Doing this will mean you'll either have to use another Sentry integration that performs initialization, (for example Spring Boot), or initialize Sentry manually.
With Sentry’s OpenTelemetry SDK, an OpenTelemetry `Span` becomes a Sentry `Transaction` or `Span`. The first `Span` sent through the Sentry `SpanProcessor` is a `Transaction`, and any child `Span` gets attached to the first `Transaction` upon checking the parent `Span` context. This is true for the OpenTelemetry root `Span` and any top level `Span` in the system. For example, a request sent from frontend to backend will create an OpenTelemetry root `Span` with a corresponding Sentry `Transaction`. The backend request will create a new Sentry `Transaction` for the OpenTelemetry `Span`. The Sentry `Transaction` and `Span` are linked as a trace for navigation and error tracking purposes.
71
-
72
-
### Manual Instrumentation with OpenTelemetry
73
-
74
-
If you have the OpenTelemetry SDK in you classpath, you can also instrument your code manually using the OpenTelemetry API as documented [in the OpenTelemetry docs](https://opentelemetry.io/docs/languages/java/api/#span).
75
-
76
-
A manually created span for HTTP requests needs to declare its `SpanKind` as well as the `HttpAttributes.HTTP_REQUEST_METHOD` attribute, so that `Sentry` can correctly process these:
77
-
78
-
```java {tabTitle:Java}
79
-
Span span = tracer.spanBuilder("myspan")
80
-
.setAttribute(HTTP_REQUEST_METHOD, "GET")
81
-
.setSpanKind(SpanKind.SERVER)
82
-
.startSpan();
83
-
```
84
-
```kotlin {tabTitle:Kotlin}
85
-
val span = tracer.spanBuilder("myspan")
86
-
.setAttribute(HTTP_REQUEST_METHOD, "GET")
87
-
.setSpanKind(SpanKind.SERVER)
88
-
.startSpan()
89
-
```
90
-
91
-
### Capturing HTTP Headers
92
-
93
-
By default OpenTelemetry does not capture any HTTP headers. This, however, can be configured using system properties or environment variables as per OpenTelemetry's configuration documentation [here](https://opentelemetry.io/docs/zero-code/java/agent/instrumentation/http/#capturing-http-request-and-response-headers). Each variable is a comma-separated list of HTTP header names that should be captured.
If you need more fine grained control over Sentry, take a look at the <PlatformLinkto="/configuration/">Configuration page</PlatformLink>. In case you'd like to filter out transactions before sending them to Sentry (to get rid of health checks, for example), you may find the <PlatformLinkto="/configuration/filtering/#filtering-transaction-events">Filtering page</PlatformLink> helpful.
8
+
This page has moved to <PlatformLinkto="/opentelemetry">a top level page</PlatformLink>.
For Spring Boot we recommend disabling the Agents `AUTO_INIT` and instead letting our Spring Boot integration take care of initializing the SDK as this allows for a more convenient configuration of Sentry using `application.properties`/`application.yml` and Spring beans.
0 commit comments