-
-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
POC for changing the way hub is stored; otel-bootstrap module
- Loading branch information
Showing
20 changed files
with
870 additions
and
43 deletions.
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
37 changes: 37 additions & 0 deletions
37
sentry-opentelemetry/sentry-opentelemetry-bootstrap/api/sentry-opentelemetry-bootstrap.api
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,37 @@ | ||
public final class io/sentry/opentelemetry/OtelContextScopeStorage : io/sentry/ScopeStorage { | ||
public fun <init> ()V | ||
public fun close ()V | ||
public fun get ()Lio/sentry/IHub; | ||
public fun set (Lio/sentry/IHub;)Lio/sentry/SentryStorageToken; | ||
} | ||
|
||
public final class io/sentry/opentelemetry/SentryContextStorage : io/opentelemetry/context/ContextStorage { | ||
public static final field HUB_KEY Lio/opentelemetry/context/ContextKey; | ||
public fun <init> (Lio/opentelemetry/context/ContextStorage;)V | ||
public fun attach (Lio/opentelemetry/context/Context;)Lio/opentelemetry/context/Scope; | ||
public fun current ()Lio/opentelemetry/context/Context; | ||
} | ||
|
||
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; | ||
public fun with (Lio/opentelemetry/context/ContextKey;Ljava/lang/Object;)Lio/opentelemetry/context/Context; | ||
public static fun wrap (Lio/opentelemetry/context/Context;)Lio/sentry/opentelemetry/SentryContextWrapper; | ||
} | ||
|
||
public final class io/sentry/opentelemetry/SentryOtelKeys { | ||
public static final field SENTRY_BAGGAGE_KEY Lio/opentelemetry/context/ContextKey; | ||
public static final field SENTRY_HUB_KEY Lio/opentelemetry/context/ContextKey; | ||
public static final field SENTRY_SCOPES_KEY Lio/opentelemetry/context/ContextKey; | ||
public static final field SENTRY_TRACE_KEY Lio/opentelemetry/context/ContextKey; | ||
public fun <init> ()V | ||
} | ||
|
||
public final class io/sentry/opentelemetry/SentryWeakSpanStorage { | ||
public fun getHub (Lio/opentelemetry/api/trace/SpanContext;)Lio/sentry/IHub; | ||
public static fun getInstance ()Lio/sentry/opentelemetry/SentryWeakSpanStorage; | ||
public fun getScopes (Lio/opentelemetry/api/trace/SpanContext;)Lio/sentry/Scopes; | ||
public fun storeHub (Lio/opentelemetry/api/trace/SpanContext;Lio/sentry/IHub;)V | ||
public fun storeScopes (Lio/opentelemetry/api/trace/SpanContext;Lio/sentry/Scopes;)V | ||
} | ||
|
77 changes: 77 additions & 0 deletions
77
sentry-opentelemetry/sentry-opentelemetry-bootstrap/build.gradle.kts
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,77 @@ | ||
import net.ltgt.gradle.errorprone.errorprone | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
`java-library` | ||
kotlin("jvm") | ||
jacoco | ||
id(Config.QualityPlugins.errorProne) | ||
id(Config.QualityPlugins.gradleVersions) | ||
} | ||
|
||
configure<JavaPluginExtension> { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString() | ||
} | ||
|
||
dependencies { | ||
compileOnly(projects.sentry) | ||
|
||
compileOnly(Config.Libs.OpenTelemetry.otelSdk) | ||
|
||
compileOnly(Config.CompileOnly.nopen) | ||
errorprone(Config.CompileOnly.nopenChecker) | ||
errorprone(Config.CompileOnly.errorprone) | ||
compileOnly(Config.CompileOnly.jetbrainsAnnotations) | ||
errorprone(Config.CompileOnly.errorProneNullAway) | ||
|
||
// tests | ||
testImplementation(projects.sentryTestSupport) | ||
testImplementation(kotlin(Config.kotlinStdLib)) | ||
testImplementation(Config.TestLibs.kotlinTestJunit) | ||
testImplementation(Config.TestLibs.mockitoKotlin) | ||
testImplementation(Config.TestLibs.awaitility) | ||
|
||
testImplementation(Config.Libs.OpenTelemetry.otelSdk) | ||
testImplementation(Config.Libs.OpenTelemetry.otelSemconv) | ||
} | ||
|
||
configure<SourceSetContainer> { | ||
test { | ||
java.srcDir("src/test/java") | ||
} | ||
} | ||
|
||
jacoco { | ||
toolVersion = Config.QualityPlugins.Jacoco.version | ||
} | ||
|
||
tasks.jacocoTestReport { | ||
reports { | ||
xml.required.set(true) | ||
html.required.set(false) | ||
} | ||
} | ||
|
||
tasks { | ||
jacocoTestCoverageVerification { | ||
violationRules { | ||
rule { limit { minimum = Config.QualityPlugins.Jacoco.minimumCoverage } } | ||
} | ||
} | ||
check { | ||
dependsOn(jacocoTestCoverageVerification) | ||
dependsOn(jacocoTestReport) | ||
} | ||
} | ||
|
||
tasks.withType<JavaCompile>().configureEach { | ||
options.errorprone { | ||
check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR) | ||
option("NullAway:AnnotatedPackages", "io.sentry") | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...pentelemetry-bootstrap/src/main/java/io/sentry/opentelemetry/OtelContextScopeStorage.java
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,46 @@ | ||
package io.sentry.opentelemetry; | ||
|
||
import static io.sentry.opentelemetry.SentryOtelKeys.SENTRY_HUB_KEY; | ||
|
||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.context.Scope; | ||
import io.sentry.IHub; | ||
import io.sentry.ScopeStorage; | ||
import io.sentry.SentryStorageToken; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@SuppressWarnings("MustBeClosedChecker") | ||
public final class OtelContextScopeStorage implements ScopeStorage { | ||
|
||
@Override | ||
public SentryStorageToken set(@Nullable IHub hub) { | ||
// TODO use scopes key | ||
Scope otelScope = Context.current().with(SENTRY_HUB_KEY, hub).makeCurrent(); | ||
return new OtelContextScopeStorageToken(otelScope); | ||
} | ||
|
||
@Override | ||
public @Nullable IHub get() { | ||
return Context.current().get(SENTRY_HUB_KEY); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
// TODO can we do something here? | ||
} | ||
|
||
static final class OtelContextScopeStorageToken implements SentryStorageToken { | ||
|
||
private final @NotNull Scope otelScope; | ||
|
||
OtelContextScopeStorageToken(final @NotNull Scope otelScope) { | ||
this.otelScope = otelScope; | ||
} | ||
|
||
@Override | ||
public void close() { | ||
otelScope.close(); | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
Oops, something went wrong.