Skip to content

Commit 5e35096

Browse files
authored
Merge branch '8.x.x' into feat/breadcrumb-level-from-http-status
2 parents 8a3c851 + 8c90f98 commit 5e35096

File tree

50 files changed

+1843
-473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1843
-473
lines changed

.craft.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ targets:
4747
maven:io.sentry:sentry-apollo:
4848
maven:io.sentry:sentry-jdbc:
4949
maven:io.sentry:sentry-graphql:
50+
# maven:io.sentry:sentry-graphql-core:
51+
# maven:io.sentry:sentry-graphql-22:
5052
maven:io.sentry:sentry-quartz:
5153
maven:io.sentry:sentry-okhttp:
5254
maven:io.sentry:sentry-android-navigation:

.github/ISSUE_TEMPLATE/bug_report_java.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ body:
2727
- sentry-logback
2828
- sentry-log4j2
2929
- sentry-graphql
30+
- sentry-graphql-22
3031
- sentry-quartz
3132
- sentry-openfeign
3233
- sentry-apache-http-client-5

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
- Attach request body for `application/x-www-form-urlencoded` requests in Spring ([#3731](https://github.com/getsentry/sentry-java/pull/3731))
2525
- Previously request body was only attached for `application/json` requests
2626
- Set breadcrumb level based on http status ([#3771](https://github.com/getsentry/sentry-java/pull/3771))
27+
- Support `graphql-java` v22 via a new module `sentry-graphql-22` ([#3740](https://github.com/getsentry/sentry-java/pull/3740))
28+
- If you are using `graphql-java` v21 or earlier, you can use the `sentry-graphql` module
29+
- For `graphql-java` v22 and newer please use the `sentry-graphql-22` module
30+
- We now provide a `SentryInstrumenter` bean directly for Spring (Boot) if there is none yet instead of using `GraphQlSourceBuilderCustomizer` to add the instrumentation ([#3744](https://github.com/getsentry/sentry-java/pull/3744))
31+
- It is now also possible to provide a bean of type `SentryGraphqlInstrumentation.BeforeSpanCallback` which is then used by `SentryInstrumenter`
2732

2833
### Fixes
2934

@@ -53,6 +58,8 @@
5358
- Transactions are dropped if trace context is missing
5459
- Remove internal annotation on `SpanOptions` ([#3722](https://github.com/getsentry/sentry-java/pull/3722))
5560
- `SentryLogbackInitializer` is now public ([#3723](https://github.com/getsentry/sentry-java/pull/3723))
61+
- Fix order of calling `close` on previous Sentry instance when re-initializing ([#3750](https://github.com/getsentry/sentry-java/pull/3750))
62+
- Previously some parts of Sentry were immediately closed after re-init that should have stayed open and some parts of the previous init were never closed
5663

5764
### Behavioural Changes
5865

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Sentry SDK for Java and Android
4848
| sentry-log4j2 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-log4j2/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-log4j2) |
4949
| sentry-bom | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-bom/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-bom) |
5050
| sentry-graphql | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-graphql/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-graphql) |
51+
| sentry-graphql-core | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-graphql-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-graphql-core) |
52+
| sentry-graphql-22 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-graphql-22/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-graphql-22) |
5153
| sentry-quartz | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-quartz/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-quartz) |
5254
| sentry-openfeign | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-openfeign/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-openfeign) |
5355
| sentry-opentelemetry-agent | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-opentelemetry-agent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-opentelemetry-agent) |

buildSrc/src/main/java/Config.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ object Config {
133133
val p6spy = "p6spy:p6spy:3.9.1"
134134

135135
val graphQlJava = "com.graphql-java:graphql-java:17.3"
136+
val graphQlJava22 = "com.graphql-java:graphql-java:22.1"
136137

137138
val quartz = "org.quartz-scheduler:quartz:2.3.0"
138139

@@ -240,6 +241,7 @@ object Config {
240241
val SENTRY_APOLLO3_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.apollo3"
241242
val SENTRY_APOLLO_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.apollo"
242243
val SENTRY_GRAPHQL_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.graphql"
244+
val SENTRY_GRAPHQL22_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.graphql22"
243245
val SENTRY_QUARTZ_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.quartz"
244246
val SENTRY_JDBC_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.jdbc"
245247
val SENTRY_SERVLET_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.servlet"

sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/SdkInitTests.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import io.sentry.android.core.SentryAndroidOptions
1010
import io.sentry.assertEnvelopeTransaction
1111
import io.sentry.protocol.SentryTransaction
1212
import org.junit.runner.RunWith
13-
import kotlin.test.Ignore
1413
import kotlin.test.Test
1514
import kotlin.test.assertEquals
1615
import kotlin.test.assertTrue
@@ -36,7 +35,6 @@ class SdkInitTests : BaseUiTest() {
3635
transaction2.finish()
3736
}
3837

39-
@Ignore("not working since re-init changes related to POTel")
4038
@Test
4139
fun doubleInitWithSameOptionsDoesNotThrow() {
4240
val options = SentryAndroidOptions()
@@ -95,7 +93,6 @@ class SdkInitTests : BaseUiTest() {
9593
}
9694
}
9795

98-
@Ignore("not working since re-init changes related to POTel")
9996
@Test
10097
fun doubleInitDoesNotWait() {
10198
relayIdlingResource.increment()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
public final class io/sentry/graphql22/BuildConfig {
2+
public static final field SENTRY_GRAPHQL22_SDK_NAME Ljava/lang/String;
3+
public static final field VERSION_NAME Ljava/lang/String;
4+
}
5+
6+
public final class io/sentry/graphql22/SentryInstrumentation : graphql/execution/instrumentation/SimpleInstrumentation {
7+
public static final field SENTRY_EXCEPTIONS_CONTEXT_KEY Ljava/lang/String;
8+
public static final field SENTRY_SCOPES_CONTEXT_KEY Ljava/lang/String;
9+
public fun <init> (Lio/sentry/graphql/SentryGraphqlInstrumentation$BeforeSpanCallback;Lio/sentry/graphql/SentrySubscriptionHandler;Lio/sentry/graphql/ExceptionReporter;Ljava/util/List;)V
10+
public fun <init> (Lio/sentry/graphql/SentryGraphqlInstrumentation$BeforeSpanCallback;Lio/sentry/graphql/SentrySubscriptionHandler;Z)V
11+
public fun <init> (Lio/sentry/graphql/SentryGraphqlInstrumentation$BeforeSpanCallback;Lio/sentry/graphql/SentrySubscriptionHandler;ZLjava/util/List;)V
12+
public fun <init> (Lio/sentry/graphql/SentrySubscriptionHandler;Z)V
13+
public fun beginExecuteOperation (Lgraphql/execution/instrumentation/parameters/InstrumentationExecuteOperationParameters;Lgraphql/execution/instrumentation/InstrumentationState;)Lgraphql/execution/instrumentation/InstrumentationContext;
14+
public fun beginExecution (Lgraphql/execution/instrumentation/parameters/InstrumentationExecutionParameters;Lgraphql/execution/instrumentation/InstrumentationState;)Lgraphql/execution/instrumentation/InstrumentationContext;
15+
public fun createState (Lgraphql/execution/instrumentation/parameters/InstrumentationCreateStateParameters;)Lgraphql/execution/instrumentation/InstrumentationState;
16+
public fun instrumentDataFetcher (Lgraphql/schema/DataFetcher;Lgraphql/execution/instrumentation/parameters/InstrumentationFieldFetchParameters;Lgraphql/execution/instrumentation/InstrumentationState;)Lgraphql/schema/DataFetcher;
17+
public fun instrumentExecutionResult (Lgraphql/ExecutionResult;Lgraphql/execution/instrumentation/parameters/InstrumentationExecutionParameters;Lgraphql/execution/instrumentation/InstrumentationState;)Ljava/util/concurrent/CompletableFuture;
18+
}
19+
20+
public abstract interface class io/sentry/graphql22/SentryInstrumentation$BeforeSpanCallback : io/sentry/graphql/SentryGraphqlInstrumentation$BeforeSpanCallback {
21+
}
22+

sentry-graphql-22/build.gradle.kts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import net.ltgt.gradle.errorprone.errorprone
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
4+
plugins {
5+
`java-library`
6+
kotlin("jvm")
7+
jacoco
8+
id(Config.QualityPlugins.errorProne)
9+
id(Config.QualityPlugins.gradleVersions)
10+
id(Config.BuildPlugins.buildConfig) version Config.BuildPlugins.buildConfigVersion
11+
}
12+
13+
configure<JavaPluginExtension> {
14+
sourceCompatibility = JavaVersion.VERSION_1_8
15+
targetCompatibility = JavaVersion.VERSION_1_8
16+
}
17+
18+
tasks.withType<KotlinCompile>().configureEach {
19+
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
20+
kotlinOptions.languageVersion = Config.kotlinCompatibleLanguageVersion
21+
}
22+
23+
dependencies {
24+
api(projects.sentry)
25+
api(projects.sentryGraphqlCore)
26+
compileOnly(Config.Libs.graphQlJava22)
27+
28+
compileOnly(Config.CompileOnly.nopen)
29+
errorprone(Config.CompileOnly.nopenChecker)
30+
errorprone(Config.CompileOnly.errorprone)
31+
errorprone(Config.CompileOnly.errorProneNullAway)
32+
compileOnly(Config.CompileOnly.jetbrainsAnnotations)
33+
34+
// tests
35+
testImplementation(projects.sentry)
36+
testImplementation(projects.sentryTestSupport)
37+
testImplementation(kotlin(Config.kotlinStdLib))
38+
testImplementation(Config.TestLibs.kotlinTestJunit)
39+
testImplementation(Config.TestLibs.mockitoKotlin)
40+
testImplementation(Config.TestLibs.mockitoInline)
41+
testImplementation(Config.TestLibs.mockWebserver)
42+
testImplementation(Config.Libs.okhttp)
43+
testImplementation(Config.Libs.springBootStarterGraphql)
44+
testImplementation("com.netflix.graphql.dgs:graphql-error-types:4.9.2")
45+
testImplementation(Config.Libs.graphQlJava22)
46+
}
47+
48+
configure<SourceSetContainer> {
49+
test {
50+
java.srcDir("src/test/java")
51+
}
52+
}
53+
54+
jacoco {
55+
toolVersion = Config.QualityPlugins.Jacoco.version
56+
}
57+
58+
tasks.jacocoTestReport {
59+
reports {
60+
xml.required.set(true)
61+
html.required.set(false)
62+
}
63+
}
64+
65+
tasks {
66+
jacocoTestCoverageVerification {
67+
violationRules {
68+
rule { limit { minimum = Config.QualityPlugins.Jacoco.minimumCoverage } }
69+
}
70+
}
71+
check {
72+
dependsOn(jacocoTestCoverageVerification)
73+
dependsOn(jacocoTestReport)
74+
}
75+
}
76+
77+
tasks.withType<JavaCompile>().configureEach {
78+
options.errorprone {
79+
check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR)
80+
option("NullAway:AnnotatedPackages", "io.sentry")
81+
}
82+
}
83+
84+
buildConfig {
85+
useJavaOutput()
86+
packageName("io.sentry.graphql22")
87+
buildConfigField("String", "SENTRY_GRAPHQL22_SDK_NAME", "\"${Config.Sentry.SENTRY_GRAPHQL22_SDK_NAME}\"")
88+
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
89+
}
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
package io.sentry.graphql22;
2+
3+
import graphql.ExecutionResult;
4+
import graphql.execution.instrumentation.InstrumentationContext;
5+
import graphql.execution.instrumentation.InstrumentationState;
6+
import graphql.execution.instrumentation.parameters.InstrumentationCreateStateParameters;
7+
import graphql.execution.instrumentation.parameters.InstrumentationExecuteOperationParameters;
8+
import graphql.execution.instrumentation.parameters.InstrumentationExecutionParameters;
9+
import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchParameters;
10+
import graphql.schema.DataFetcher;
11+
import io.sentry.SentryIntegrationPackageStorage;
12+
import io.sentry.graphql.ExceptionReporter;
13+
import io.sentry.graphql.SentryGraphqlInstrumentation;
14+
import io.sentry.graphql.SentrySubscriptionHandler;
15+
import java.util.ArrayList;
16+
import java.util.List;
17+
import java.util.concurrent.CompletableFuture;
18+
import org.jetbrains.annotations.NotNull;
19+
import org.jetbrains.annotations.Nullable;
20+
import org.jetbrains.annotations.TestOnly;
21+
22+
@SuppressWarnings("deprecation")
23+
public final class SentryInstrumentation
24+
extends graphql.execution.instrumentation.SimpleInstrumentation {
25+
26+
/**
27+
* @deprecated please use {@link SentryGraphqlInstrumentation#SENTRY_SCOPES_CONTEXT_KEY}
28+
*/
29+
@Deprecated
30+
public static final @NotNull String SENTRY_SCOPES_CONTEXT_KEY =
31+
SentryGraphqlInstrumentation.SENTRY_SCOPES_CONTEXT_KEY;
32+
33+
/**
34+
* @deprecated please use {@link SentryGraphqlInstrumentation#SENTRY_EXCEPTIONS_CONTEXT_KEY}
35+
*/
36+
@Deprecated
37+
public static final @NotNull String SENTRY_EXCEPTIONS_CONTEXT_KEY =
38+
SentryGraphqlInstrumentation.SENTRY_EXCEPTIONS_CONTEXT_KEY;
39+
40+
private static final String TRACE_ORIGIN = "auto.graphql.graphql22";
41+
private final @NotNull SentryGraphqlInstrumentation instrumentation;
42+
43+
/**
44+
* @param beforeSpan callback when a span is created
45+
* @param subscriptionHandler can report subscription errors
46+
* @param captureRequestBodyForNonSubscriptions false if request bodies should not be captured by
47+
* this integration for query and mutation operations. This can be used to prevent unnecessary
48+
* work by not adding the request body when another integration will add it anyways, as is the
49+
* case with our spring integration for WebMVC.
50+
*/
51+
public SentryInstrumentation(
52+
final @Nullable SentryGraphqlInstrumentation.BeforeSpanCallback beforeSpan,
53+
final @NotNull SentrySubscriptionHandler subscriptionHandler,
54+
final boolean captureRequestBodyForNonSubscriptions) {
55+
this(
56+
beforeSpan,
57+
subscriptionHandler,
58+
new ExceptionReporter(captureRequestBodyForNonSubscriptions),
59+
new ArrayList<>());
60+
}
61+
62+
/**
63+
* @param beforeSpan callback when a span is created
64+
* @param subscriptionHandler can report subscription errors
65+
* @param captureRequestBodyForNonSubscriptions false if request bodies should not be captured by
66+
* this integration for query and mutation operations. This can be used to prevent unnecessary
67+
* work by not adding the request body when another integration will add it anyways, as is the
68+
* case with our spring integration for WebMVC.
69+
* @param ignoredErrorTypes list of error types that should not be captured and sent to Sentry
70+
*/
71+
public SentryInstrumentation(
72+
final @Nullable SentryGraphqlInstrumentation.BeforeSpanCallback beforeSpan,
73+
final @NotNull SentrySubscriptionHandler subscriptionHandler,
74+
final boolean captureRequestBodyForNonSubscriptions,
75+
final @NotNull List<String> ignoredErrorTypes) {
76+
this(
77+
beforeSpan,
78+
subscriptionHandler,
79+
new ExceptionReporter(captureRequestBodyForNonSubscriptions),
80+
ignoredErrorTypes);
81+
}
82+
83+
@TestOnly
84+
public SentryInstrumentation(
85+
final @Nullable SentryGraphqlInstrumentation.BeforeSpanCallback beforeSpan,
86+
final @NotNull SentrySubscriptionHandler subscriptionHandler,
87+
final @NotNull ExceptionReporter exceptionReporter,
88+
final @NotNull List<String> ignoredErrorTypes) {
89+
this.instrumentation =
90+
new SentryGraphqlInstrumentation(
91+
beforeSpan, subscriptionHandler, exceptionReporter, ignoredErrorTypes, TRACE_ORIGIN);
92+
SentryIntegrationPackageStorage.getInstance().addIntegration("GraphQL-v22");
93+
SentryIntegrationPackageStorage.getInstance()
94+
.addPackage("maven:io.sentry:sentry-graphql-22", BuildConfig.VERSION_NAME);
95+
}
96+
97+
/**
98+
* @param subscriptionHandler can report subscription errors
99+
* @param captureRequestBodyForNonSubscriptions false if request bodies should not be captured by
100+
* this integration for query and mutation operations. This can be used to prevent unnecessary
101+
* work by not adding the request body when another integration will add it anyways, as is the
102+
* case with our spring integration for WebMVC.
103+
*/
104+
public SentryInstrumentation(
105+
final @NotNull SentrySubscriptionHandler subscriptionHandler,
106+
final boolean captureRequestBodyForNonSubscriptions) {
107+
this(null, subscriptionHandler, captureRequestBodyForNonSubscriptions);
108+
}
109+
110+
@Override
111+
public @NotNull InstrumentationState createState(
112+
final @NotNull InstrumentationCreateStateParameters parameters) {
113+
return instrumentation.createState();
114+
}
115+
116+
@Override
117+
public @Nullable InstrumentationContext<ExecutionResult> beginExecution(
118+
final @NotNull InstrumentationExecutionParameters parameters,
119+
final @NotNull InstrumentationState state) {
120+
final SentryGraphqlInstrumentation.TracingState tracingState =
121+
InstrumentationState.ofState(state);
122+
instrumentation.beginExecution(parameters, tracingState);
123+
return super.beginExecution(parameters, state);
124+
}
125+
126+
@Override
127+
public @NotNull CompletableFuture<ExecutionResult> instrumentExecutionResult(
128+
final @NotNull ExecutionResult executionResult,
129+
final @NotNull InstrumentationExecutionParameters parameters,
130+
final @NotNull InstrumentationState state) {
131+
return super.instrumentExecutionResult(executionResult, parameters, state)
132+
.whenComplete(
133+
(result, exception) -> {
134+
instrumentation.instrumentExecutionResultComplete(parameters, result, exception);
135+
});
136+
}
137+
138+
@Override
139+
public @Nullable InstrumentationContext<ExecutionResult> beginExecuteOperation(
140+
final @NotNull InstrumentationExecuteOperationParameters parameters,
141+
final @NotNull InstrumentationState state) {
142+
instrumentation.beginExecuteOperation(parameters);
143+
return super.beginExecuteOperation(parameters, state);
144+
}
145+
146+
@Override
147+
@SuppressWarnings({"FutureReturnValueIgnored", "deprecation"})
148+
public @NotNull DataFetcher<?> instrumentDataFetcher(
149+
final @NotNull DataFetcher<?> dataFetcher,
150+
final @NotNull InstrumentationFieldFetchParameters parameters,
151+
final @NotNull InstrumentationState state) {
152+
final SentryGraphqlInstrumentation.TracingState tracingState =
153+
InstrumentationState.ofState(state);
154+
return instrumentation.instrumentDataFetcher(dataFetcher, parameters, tracingState);
155+
}
156+
157+
/**
158+
* @deprecated please use {@link SentryGraphqlInstrumentation.BeforeSpanCallback}
159+
*/
160+
@Deprecated
161+
@FunctionalInterface
162+
public interface BeforeSpanCallback extends SentryGraphqlInstrumentation.BeforeSpanCallback {}
163+
}

0 commit comments

Comments
 (0)