Skip to content

Commit

Permalink
POTEL 60 - Replace OTel ContextStorage wrapper with `ContextStorage…
Browse files Browse the repository at this point in the history
…Provider` (#3938)

* bump OTel to 2.10.0

* support DB_QUERY_TEXT

* changelog

* change bom version for otel

* Replace OTel ContextStorage wrapper with ContextStorageProvider

* changelog

* remove println
  • Loading branch information
adinauer authored Nov 29, 2024
1 parent 7345b18 commit 8a31bb4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
### Features

- Extract OpenTelemetry `URL_PATH` span attribute into description ([#3933](https://github.com/getsentry/sentry-java/pull/3933))
- Replace OpenTelemetry `ContextStorage` wrapper with `ContextStorageProvider` ([#3938](https://github.com/getsentry/sentry-java/pull/3938))
- The wrapper had to be put in place before any call to `Context` whereas `ContextStorageProvider` is automatically invoked at the correct time.

### Dependencies

- Bump OpenTelemetry to 1.44.1, OpenTelemetry Java Agent to 2.10.0 and Semantic Conventions to 1.28.0 ([#3935](https://github.com/getsentry/sentry-java/pull/3935))

### Dependencies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ public final class io/sentry/opentelemetry/SentryContextStorage : io/opentelemet
public fun current ()Lio/opentelemetry/context/Context;
}

public final class io/sentry/opentelemetry/SentryContextStorageProvider : io/opentelemetry/context/ContextStorageProvider {
public fun <init> ()V
public fun get ()Lio/opentelemetry/context/ContextStorage;
}

public final class io/sentry/opentelemetry/SentryContextWrapper : io/opentelemetry/context/Context {
public fun get (Lio/opentelemetry/context/ContextKey;)Ljava/lang/Object;
public fun toString ()Ljava/lang/String;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static io.sentry.opentelemetry.SentryOtelKeys.SENTRY_SCOPES_KEY;

import io.opentelemetry.context.Context;
import io.opentelemetry.context.ContextStorage;
import io.opentelemetry.context.Scope;
import io.sentry.IScopes;
import io.sentry.IScopesStorage;
Expand All @@ -27,8 +26,8 @@ public void init() {
* should try to use OTels StorageProvider mechanism instead.
*/
// ContextStorage.addWrapper((storage) -> new SentryContextStorage(storage));
ContextStorage.addWrapper(
(storage) -> new SentryContextStorage(new SentryOtelThreadLocalStorage()));
// ContextStorage.addWrapper(
// (storage) -> new SentryContextStorage(new SentryOtelThreadLocalStorage()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.sentry.opentelemetry;

import io.opentelemetry.context.ContextStorage;
import io.opentelemetry.context.ContextStorageProvider;

public final class SentryContextStorageProvider implements ContextStorageProvider {
@Override
public ContextStorage get() {
return new SentryContextStorage(new SentryOtelThreadLocalStorage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.sentry.opentelemetry.SentryContextStorageProvider

0 comments on commit 8a31bb4

Please sign in to comment.