From 29f4570e663034517b51c1a92ed37dec7664897d Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Fri, 10 Jun 2022 12:01:06 +0200 Subject: [PATCH 01/10] add local scope doc to Android Platform, adapt LocalScope doc for Java to include the new callback. align old code example and leave as alternative --- .../scopes/with-scope/java.mdx | 87 +++++++++++++++++-- .../common/enriching-events/scopes.mdx | 2 +- 2 files changed, 80 insertions(+), 9 deletions(-) diff --git a/src/includes/enriching-events/scopes/with-scope/java.mdx b/src/includes/enriching-events/scopes/with-scope/java.mdx index ec4ee2755e634..e3190e4119357 100644 --- a/src/includes/enriching-events/scopes/with-scope/java.mdx +++ b/src/includes/enriching-events/scopes/with-scope/java.mdx @@ -1,25 +1,96 @@ + + +```java {tabTitle: Java} +import io.sentry.Sentry; +import io.sentry.SentryLevel; + +// will be tagged with my-tag="my value" +Sentry.captureException(new Exception("my error"), scope -> { + scope.setTag("my-tag", "my value"); + scope.setLevel(SentryLevel.WARNING); +}); + +// will not be tagged with my-tag +Sentry.captureException(new Exception("my error")); +``` + +```kotlin {tabTitle: Kotlin} +import io.sentry.Sentry +import io.sentry.SentryLevel + +// will be tagged with my-tag="my value" +Sentry.captureException(Exception("my error")) { scope -> + scope.setTag("my-tag", "my value") + scope.level = SentryLevel.WARNING +} + +// will not be tagged with my-tag +Sentry.captureException(Exception("my error")) +``` + + + + + +The JavaSDK provides two alternative ways of configuring a local scope. + ```java {tabTitle: Java} import io.sentry.Sentry; import io.sentry.SentryLevel; +// will be tagged with my-tag="my value" +Sentry.captureException(new Exception("my error"), scope -> { + scope.setTag("my-tag", "my value"); + scope.setLevel(SentryLevel.WARNING); +}); + +// will not be tagged with my-tag +Sentry.captureException(new Exception("my error")); +``` + +```java {tabTitle: Java-Alternative} +import io.sentry.Sentry; +import io.sentry.SentryLevel; + Sentry.withScope(scope -> { - scope.setLevel(SentryLevel.FATAL); - scope.setTransaction("main"); + scope.setTag("my-tag", "my value"); + scope.setLevel(SentryLevel.WARNING); - // This message includes the dataset to the scope in this block: - Sentry.captureMessage("Fatal message!"); + // will be tagged with my-tag="my value" + Sentry.captureException(new Exception("my error")); }); + +// will not be tagged with my-tag +Sentry.captureException(new Exception("my error")); ``` ```kotlin {tabTitle: Kotlin} import io.sentry.Sentry import io.sentry.SentryLevel +// will be tagged with my-tag="my value" +Sentry.captureException(Exception("my error")) { scope -> + scope.setTag("my-tag", "my value") + scope.level = SentryLevel.WARNING +} + +// will not be tagged with my-tag +Sentry.captureException(Exception("my error")) +``` + +```kotlin {tabTitle: Kotlin-Alternative} +import io.sentry.Sentry +import io.sentry.SentryLevel + Sentry.withScope { scope -> - scope.level = SentryLevel.FATAL - scope.setTransaction("main") + scope.setTag("my-tag", "my value") + scope.level = SentryLevel.WARNING - // This message includes the dataset to the scope in this block: - Sentry.captureMessage("Fatal message!") + // will be tagged with my-tag="my value" + Sentry.captureException(Exception("my error")) } + +// will not be tagged with my-tag +Sentry.captureException(Exception("my error")) ``` + diff --git a/src/platforms/common/enriching-events/scopes.mdx b/src/platforms/common/enriching-events/scopes.mdx index 2cb93bcaddbcc..f291476903535 100644 --- a/src/platforms/common/enriching-events/scopes.mdx +++ b/src/platforms/common/enriching-events/scopes.mdx @@ -93,7 +93,7 @@ You can also apply this configuration when unsetting a user at logout: To learn what useful information can be associated with scopes see [the context documentation](../context/). - + ## Local Scopes From 5f8f0d2dc342944c987b4b962058014269aa74b8 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Thu, 16 Jun 2022 11:33:06 +0200 Subject: [PATCH 02/10] Update local scope documentation. Differentiate between withScope/pushScope and scope callback parameter of capture methods --- .../apple.mdx | 0 .../dart.mdx | 0 .../dotnet.mdx | 0 .../scopes/scope-callback-param/java.mdx | 27 ++++++++ .../unreal.mdx | 0 .../scopes/with-scope/java.mdx | 69 ++----------------- .../common/enriching-events/scopes.mdx | 34 +++++++-- 7 files changed, 64 insertions(+), 66 deletions(-) rename src/includes/enriching-events/scopes/{with-scope => scope-callback-param}/apple.mdx (100%) rename src/includes/enriching-events/scopes/{with-scope => scope-callback-param}/dart.mdx (100%) rename src/includes/enriching-events/scopes/{with-scope => scope-callback-param}/dotnet.mdx (100%) create mode 100644 src/includes/enriching-events/scopes/scope-callback-param/java.mdx rename src/includes/enriching-events/scopes/{with-scope => scope-callback-param}/unreal.mdx (100%) diff --git a/src/includes/enriching-events/scopes/with-scope/apple.mdx b/src/includes/enriching-events/scopes/scope-callback-param/apple.mdx similarity index 100% rename from src/includes/enriching-events/scopes/with-scope/apple.mdx rename to src/includes/enriching-events/scopes/scope-callback-param/apple.mdx diff --git a/src/includes/enriching-events/scopes/with-scope/dart.mdx b/src/includes/enriching-events/scopes/scope-callback-param/dart.mdx similarity index 100% rename from src/includes/enriching-events/scopes/with-scope/dart.mdx rename to src/includes/enriching-events/scopes/scope-callback-param/dart.mdx diff --git a/src/includes/enriching-events/scopes/with-scope/dotnet.mdx b/src/includes/enriching-events/scopes/scope-callback-param/dotnet.mdx similarity index 100% rename from src/includes/enriching-events/scopes/with-scope/dotnet.mdx rename to src/includes/enriching-events/scopes/scope-callback-param/dotnet.mdx diff --git a/src/includes/enriching-events/scopes/scope-callback-param/java.mdx b/src/includes/enriching-events/scopes/scope-callback-param/java.mdx new file mode 100644 index 0000000000000..e7dbe6e8eafd4 --- /dev/null +++ b/src/includes/enriching-events/scopes/scope-callback-param/java.mdx @@ -0,0 +1,27 @@ +```java {tabTitle: Java} +import io.sentry.Sentry; +import io.sentry.SentryLevel; + +// will be tagged with my-tag="my value" +Sentry.captureException(new Exception("my error"), scope -> { + scope.setTag("my-tag", "my value"); + scope.setLevel(SentryLevel.WARNING); +}); + +// will not be tagged with my-tag +Sentry.captureException(new Exception("my error")); +``` + +```kotlin {tabTitle: Kotlin} +import io.sentry.Sentry +import io.sentry.SentryLevel + +// will be tagged with my-tag="my value" +Sentry.captureException(Exception("my error")) { scope -> + scope.setTag("my-tag", "my value") + scope.level = SentryLevel.WARNING +} + +// will not be tagged with my-tag +Sentry.captureException(Exception("my error")) +``` diff --git a/src/includes/enriching-events/scopes/with-scope/unreal.mdx b/src/includes/enriching-events/scopes/scope-callback-param/unreal.mdx similarity index 100% rename from src/includes/enriching-events/scopes/with-scope/unreal.mdx rename to src/includes/enriching-events/scopes/scope-callback-param/unreal.mdx diff --git a/src/includes/enriching-events/scopes/with-scope/java.mdx b/src/includes/enriching-events/scopes/with-scope/java.mdx index e3190e4119357..6ee220a969f2e 100644 --- a/src/includes/enriching-events/scopes/with-scope/java.mdx +++ b/src/includes/enriching-events/scopes/with-scope/java.mdx @@ -1,57 +1,9 @@ - - -```java {tabTitle: Java} -import io.sentry.Sentry; -import io.sentry.SentryLevel; - -// will be tagged with my-tag="my value" -Sentry.captureException(new Exception("my error"), scope -> { - scope.setTag("my-tag", "my value"); - scope.setLevel(SentryLevel.WARNING); -}); - -// will not be tagged with my-tag -Sentry.captureException(new Exception("my error")); -``` - -```kotlin {tabTitle: Kotlin} -import io.sentry.Sentry -import io.sentry.SentryLevel - -// will be tagged with my-tag="my value" -Sentry.captureException(Exception("my error")) { scope -> - scope.setTag("my-tag", "my value") - scope.level = SentryLevel.WARNING -} - -// will not be tagged with my-tag -Sentry.captureException(Exception("my error")) -``` - - - -The JavaSDK provides two alternative ways of configuring a local scope. - ```java {tabTitle: Java} import io.sentry.Sentry; import io.sentry.SentryLevel; -// will be tagged with my-tag="my value" -Sentry.captureException(new Exception("my error"), scope -> { - scope.setTag("my-tag", "my value"); - scope.setLevel(SentryLevel.WARNING); -}); - -// will not be tagged with my-tag -Sentry.captureException(new Exception("my error")); -``` - -```java {tabTitle: Java-Alternative} -import io.sentry.Sentry; -import io.sentry.SentryLevel; - Sentry.withScope(scope -> { scope.setTag("my-tag", "my value"); scope.setLevel(SentryLevel.WARNING); @@ -68,20 +20,6 @@ Sentry.captureException(new Exception("my error")); import io.sentry.Sentry import io.sentry.SentryLevel -// will be tagged with my-tag="my value" -Sentry.captureException(Exception("my error")) { scope -> - scope.setTag("my-tag", "my value") - scope.level = SentryLevel.WARNING -} - -// will not be tagged with my-tag -Sentry.captureException(Exception("my error")) -``` - -```kotlin {tabTitle: Kotlin-Alternative} -import io.sentry.Sentry -import io.sentry.SentryLevel - Sentry.withScope { scope -> scope.setTag("my-tag", "my value") scope.level = SentryLevel.WARNING @@ -93,4 +31,11 @@ Sentry.withScope { scope -> // will not be tagged with my-tag Sentry.captureException(Exception("my error")) ``` + + + +In the Java SDK `with-scope` does **not** work reliably in `globalHubMode` as the `scope` gets pushed on the stack global to the hub. In `globalHubMode` use the callback parameter of the capture methods detailed below. + + + diff --git a/src/platforms/common/enriching-events/scopes.mdx b/src/platforms/common/enriching-events/scopes.mdx index f291476903535..206766e0c0a64 100644 --- a/src/platforms/common/enriching-events/scopes.mdx +++ b/src/platforms/common/enriching-events/scopes.mdx @@ -93,13 +93,17 @@ You can also apply this configuration when unsetting a user at logout: To learn what useful information can be associated with scopes see [the context documentation](../context/). - - ## Local Scopes We also support pushing and configuring a scope within a single call. This is typically -called `with-scope` or `push-scope` depending on the SDK, and is very helpful if -you only want to send data for one specific event. In the following example we use +called `with-scope`, `push-scope` or implemented as a function parameter on the capture methods, depending on the SDK. It's very helpful if +you only want to send data for one specific event. + + + +### Using `with-scope` + +In the following example we use `with-scope` to attach a `level` and a `tag` to only one specific error: @@ -123,6 +127,28 @@ caught, and all errors that occur will be silently ignored and **not** reported. + + +### Using Scope Callback Parameter + +In the following example we use the scope callback parameter that is available for all `capture` methods to attach a `level` and a `tag` to only one specific error: + + + +Before the callback is invoked the SDK creates a clone of the current scope, and the changes +made will stay isolated within the callback function. This allows you to +more easily isolate pieces of context information to specific locations in your code or +even call `clear` to briefly remove all context information. + + + +Any exceptions that occur within the callback function for configuring a local scope will not be +caught, and all errors that occur will be silently ignored and **not** reported. + + + + + ## Kotlin Coroutines From 12e870ace8de745af107f527a6c709cd3b89b421 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Fri, 24 Jun 2022 13:44:20 +0200 Subject: [PATCH 03/10] CR remove local scope section from native, as it is not supported. Remove with-scope section from android --- src/includes/enriching-events/scopes/with-scope/native.mdx | 1 - src/platforms/common/enriching-events/scopes.mdx | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) delete mode 100644 src/includes/enriching-events/scopes/with-scope/native.mdx diff --git a/src/includes/enriching-events/scopes/with-scope/native.mdx b/src/includes/enriching-events/scopes/with-scope/native.mdx deleted file mode 100644 index b02ffbf1e714d..0000000000000 --- a/src/includes/enriching-events/scopes/with-scope/native.mdx +++ /dev/null @@ -1 +0,0 @@ -_This is not supported by the Native SDK._ diff --git a/src/platforms/common/enriching-events/scopes.mdx b/src/platforms/common/enriching-events/scopes.mdx index 206766e0c0a64..a9ca7356327c3 100644 --- a/src/platforms/common/enriching-events/scopes.mdx +++ b/src/platforms/common/enriching-events/scopes.mdx @@ -93,13 +93,15 @@ You can also apply this configuration when unsetting a user at logout: To learn what useful information can be associated with scopes see [the context documentation](../context/). + + ## Local Scopes We also support pushing and configuring a scope within a single call. This is typically called `with-scope`, `push-scope` or implemented as a function parameter on the capture methods, depending on the SDK. It's very helpful if you only want to send data for one specific event. - + ### Using `with-scope` @@ -149,6 +151,8 @@ caught, and all errors that occur will be silently ignored and **not** reported. + + ## Kotlin Coroutines From 794aa9288219a20db9d874784d446a3232bb4c3b Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Wed, 13 Jul 2022 15:11:47 +0200 Subject: [PATCH 04/10] document usage of Apollo3 Integration --- .../configuration/integrations/apollo3.mdx | 120 ++++++++++++ .../performance/instrumentation/apollo3.mdx | 171 ++++++++++++++++++ 2 files changed, 291 insertions(+) create mode 100644 src/platforms/android/configuration/integrations/apollo3.mdx create mode 100644 src/platforms/java/common/performance/instrumentation/apollo3.mdx diff --git a/src/platforms/android/configuration/integrations/apollo3.mdx b/src/platforms/android/configuration/integrations/apollo3.mdx new file mode 100644 index 0000000000000..45e231742b9ba --- /dev/null +++ b/src/platforms/android/configuration/integrations/apollo3.mdx @@ -0,0 +1,120 @@ +--- +title: Apollo3 +caseStyle: camelCase +supportLevel: production +sdk: sentry.java.apollo3 +description: "Learn more about the Sentry Apollo3 integration for the Android SDK." +categories: + - mobile +redirect_from: + - /platforms/android/performance/instrumentation/apollo3/ +--- + + + +Capturing transactions requires that you first set up performance monitoring if you haven't already. + + + +Sentry Apollo3 integration provides the `SentryApollo3Interceptor` and the `SentryApollo3HttpInterceptor`, which create a span for each outgoing HTTP request executed with an [Apollo Kotlin](https://github.com/apollographql/apollo-kotlin) GraphQL client. For easier usage the integration also provides extension functions on the `ApolloClient.Builder`. + +## Install + +```groovy {tabTitle:Gradle} +implementation 'io.sentry:sentry-apollo3:{{ packages.version('sentry.java.apollo3', '6.1.4') }}' +``` + +For other dependency managers, see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-apollo3). + +## Configure with Extension + +Add `Interceptors` to `ApolloClient.Builder` using `ApolloBuilderExtensions`: + +```java +import com.apollographql.apollo.ApolloClient; +import io.sentry.apollo3.ApolloBuilderExtensionsKt; + +ApolloClient apollo = ApolloBuilderExtensionsKt.sentryTracing(new ApolloClient.Builder()) + .serverUrl("https://your-api-host/") + .sentryTracing() + .build(); +``` + +```kotlin +import com.apollographql.apollo.ApolloClient +import io.sentry.apollo3.sentryTracing + +val apollo = ApolloClient.builder() + .serverUrl("https://your-api-host/") + .sentryTracing() + .build() +``` + +## Manual Configuration +When using a custom `NetworkTransport`, the `SentryInterceptors` need to be added manually, because then `HttpInterceptors` need to be added to the `NetworkTransport`. + +```java +import com.apollographql.apollo.ApolloClient; +import io.sentry.apollo3.ApolloBuilderExtensionsKt; + +ApolloClient apollo = new ApolloClient.Builder() + .networkTransport( + new HttpNetworkTransport.Builder() + .serverUrl("https://your-api-host/") + .addInterceptor(new SentryApollo3HttpInterceptor()) + .build()) + .addInterceptor(new SentryApollo3Interceptor()) + .build(); +``` + +```kotlin +import com.apollographql.apollo.ApolloClient +import io.sentry.apollo3.SentryApollo3HttpInterceptor +import io.sentry.apollo3.SentryApollo3Interceptor +import com.apollographql.apollo3.network.http.HttpNetworkTransport + +val apollo = ApolloClient.builder() + .networkTransport( + HttpNetworkTransport.Builder() + .serverUrl("https://apollo-fullstack-tutorial.herokuapp.com/graphql") + .addInterceptor(SentryApollo3HttpInterceptor()) + .build() + ) + .addInterceptor(SentryApollo3Interceptor()) + .build() +``` + +## Modify or Drop Spans + +Spans created around requests can be modified or dropped using `SentryApollo3HttpInterceptor.BeforeSpanCallback` passed to `SentryApollo3HttpInterceptor` or the `sentryTracing` extension function: + +```java +import com.apollographql.apollo.ApolloClient; +import io.sentry.apollo.SentryApolloInterceptor; + +ApolloClient apollo = SentryApolloBuilderExtensionsKt.sentryTracing( + new ApolloClient.Builder(), + (span, request, response) -> { + if ("LaunchDetails".equals(span.getOperation())) { + span.setTag("tag-name", "tag-value"); + } + return span; + }) + .serverUrl("https://your-api-host/") + .build(); +``` + +```kotlin +import com.apollographql.apollo.ApolloClient +import io.sentry.apollo.SentryApolloInterceptor + +val apollo = ApolloClient.builder() + .serverUrl("https://apollo-fullstack-tutorial.herokuapp.com/graphql") + .sentryTracing { span, request, response -> + if ("LaunchDetails" == span.operation) { + span.setTag("tag-name", "tag-value") + } + span + } + .build() +``` diff --git a/src/platforms/java/common/performance/instrumentation/apollo3.mdx b/src/platforms/java/common/performance/instrumentation/apollo3.mdx new file mode 100644 index 0000000000000..cf0f43b9841e8 --- /dev/null +++ b/src/platforms/java/common/performance/instrumentation/apollo3.mdx @@ -0,0 +1,171 @@ +--- +title: Apollo3 Integration +sidebar_order: 31 +description: "Learn how to capture the performance of Apollo GraphQL client." +notSupported: + - java.logback + - java.log4j2 + - java.jul +--- + + + +Capturing transactions requires that you first set up performance monitoring if you haven't already. + + + +Sentry Apollo3 integration provides the `SentryApollo3Interceptor` and the `SentryApollo3HttpInterceptor`, which create a span for each outgoing HTTP request executed with an [Apollo Kotlin](https://github.com/apollographql/apollo-kotlin) GraphQL client. For easier usage the integration also provides extension functions on the `ApolloClient.Builder`. + +## Install + +```xml {tabTitle:Maven} + + io.sentry + sentry-apollo-3 + {{ packages.version('sentry.java.apollo3', '5.2.0') }} + +``` + +```groovy {tabTitle:Gradle} +implementation 'io.sentry:sentry-apollo-3:{{ packages.version('sentry.java.apollo3', '5.2.0') }}' +``` + +```scala {tabTitle: SBT} +libraryDependencies += "io.sentry" % "sentry-apollo-3" % "{{ packages.version('sentry.java.apollo3', '5.2.0') }}" +``` + +For other dependency managers, see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-apollo-3). + +## Configure with Extension + +Add `Interceptors` to `ApolloClient.Builder` using `ApolloBuilderExtensions`: + +```java +import com.apollographql.apollo.ApolloClient; +import io.sentry.apollo3.ApolloBuilderExtensionsKt; + +ApolloClient apollo = ApolloBuilderExtensionsKt.sentryTracing(new ApolloClient.Builder()) + .serverUrl("https://your-api-host/") + .sentryTracing() + .build(); +``` + +```kotlin +import com.apollographql.apollo.ApolloClient +import io.sentry.apollo3.sentryTracing + +val apollo = ApolloClient.builder() + .serverUrl("https://your-api-host/") + .sentryTracing() + .build() +``` + +## Manual Configuration +When using a custom `NetworkTransport`, the `SentryInterceptors` need to be added manually, because then `HttpInterceptors` need to be added to the `NetworkTransport`. + +```java +import com.apollographql.apollo.ApolloClient; +import io.sentry.apollo3.ApolloBuilderExtensionsKt; + +ApolloClient apollo = new ApolloClient.Builder() + .networkTransport( + new HttpNetworkTransport.Builder() + .serverUrl("https://your-api-host/") + .addInterceptor(new SentryApollo3HttpInterceptor()) + .build()) + .addInterceptor(new SentryApollo3Interceptor()) + .build(); +``` + +```kotlin +import com.apollographql.apollo.ApolloClient +import io.sentry.apollo3.SentryApollo3HttpInterceptor +import io.sentry.apollo3.SentryApollo3Interceptor +import com.apollographql.apollo3.network.http.HttpNetworkTransport + +val apollo = ApolloClient.builder() + .networkTransport( + HttpNetworkTransport.Builder() + .serverUrl("https://apollo-fullstack-tutorial.herokuapp.com/graphql") + .addInterceptor(SentryApollo3HttpInterceptor()) + .build() + ) + .addInterceptor(SentryApollo3Interceptor()) + .build() +``` + + + +Apollo Kotlin is built with Kotlin coroutines. This means that `SentryApolloInterceptor` can be used with Java using only Global Hub Mode (single Hub used by all threads), with Kotlin using single Hub mode, or with Sentry's coroutines support. + + + +## Using With Java + +Configure Global Hub Mode: + +```java +import io.sentry.Sentry; + +Sentry.init(options -> { + .. +}, true) +``` + + +In Global Hub Mode, all threads use the same Hub. + + +## Using With Kotlin Coroutines + +To make sure that a coroutine has access to the correct Sentry context, an instance of `SentryContext` must be provided when launching a coroutine. + +```kotlin +import io.sentry.kotlin.SentryContext +import com.apollographql.apollo.exception.ApolloException +import kotlinx.coroutines.launch + +launch(SentryContext()) { + val response = try { + apollo.query(..).toDeferred().await() + } catch (e: ApolloException) { + // handle protocol errors + return@launch + } +} +``` + +## Modify or Drop Spans + +Spans created around requests can be modified or dropped using `SentryApollo3HttpInterceptor.BeforeSpanCallback` passed to `SentryApollo3HttpInterceptor` or the `sentryTracing` extension function: + +```java +import com.apollographql.apollo.ApolloClient; +import io.sentry.apollo.SentryApolloInterceptor; + +ApolloClient apollo = SentryApolloBuilderExtensionsKt.sentryTracing( + new ApolloClient.Builder(), + (span, request, response) -> { + if ("LaunchDetails".equals(span.getOperation())) { + span.setTag("tag-name", "tag-value"); + } + return span; + }) + .serverUrl("https://your-api-host/") + .build(); +``` + +```kotlin +import com.apollographql.apollo.ApolloClient +import io.sentry.apollo.SentryApolloInterceptor + +val apollo = ApolloClient.builder() + .serverUrl("https://apollo-fullstack-tutorial.herokuapp.com/graphql") + .sentryTracing { span, request, response -> + if ("LaunchDetails" == span.operation) { + span.setTag("tag-name", "tag-value") + } + span + } + .build() +``` From c767a5c8caeff223c90b9fd16eb90297e64eedb6 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Thu, 14 Jul 2022 14:52:17 +0200 Subject: [PATCH 05/10] Update src/platforms/java/common/performance/instrumentation/apollo3.mdx Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> --- .../java/common/performance/instrumentation/apollo3.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/java/common/performance/instrumentation/apollo3.mdx b/src/platforms/java/common/performance/instrumentation/apollo3.mdx index cf0f43b9841e8..06d78991c3da6 100644 --- a/src/platforms/java/common/performance/instrumentation/apollo3.mdx +++ b/src/platforms/java/common/performance/instrumentation/apollo3.mdx @@ -118,7 +118,7 @@ In Global Hub Mode, all threads use the same Hub. ## Using With Kotlin Coroutines -To make sure that a coroutine has access to the correct Sentry context, an instance of `SentryContext` must be provided when launching a coroutine. +To make sure that a coroutine has access to the correct Sentry context, provide an instance of `SentryContext` when launching a coroutine: ```kotlin import io.sentry.kotlin.SentryContext From 8fef813e88918b06c5eaf55f29016c62dcae9bfb Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Thu, 14 Jul 2022 14:54:18 +0200 Subject: [PATCH 06/10] Update src/platforms/android/configuration/integrations/apollo3.mdx Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> --- src/platforms/android/configuration/integrations/apollo3.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/android/configuration/integrations/apollo3.mdx b/src/platforms/android/configuration/integrations/apollo3.mdx index 45e231742b9ba..f559a10014f1b 100644 --- a/src/platforms/android/configuration/integrations/apollo3.mdx +++ b/src/platforms/android/configuration/integrations/apollo3.mdx @@ -51,7 +51,7 @@ val apollo = ApolloClient.builder() ``` ## Manual Configuration -When using a custom `NetworkTransport`, the `SentryInterceptors` need to be added manually, because then `HttpInterceptors` need to be added to the `NetworkTransport`. +When using a custom `NetworkTransport`, the `SentryInterceptors` need to be added manually, because `HttpInterceptors` need to be added to the `NetworkTransport`: ```java import com.apollographql.apollo.ApolloClient; From cd939eed75a15f2bfa3f74c117a0730c6ee896b6 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Thu, 14 Jul 2022 14:54:41 +0200 Subject: [PATCH 07/10] Update src/platforms/android/configuration/integrations/apollo3.mdx Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> --- src/platforms/android/configuration/integrations/apollo3.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/android/configuration/integrations/apollo3.mdx b/src/platforms/android/configuration/integrations/apollo3.mdx index f559a10014f1b..30d628c676024 100644 --- a/src/platforms/android/configuration/integrations/apollo3.mdx +++ b/src/platforms/android/configuration/integrations/apollo3.mdx @@ -26,7 +26,7 @@ implementation 'io.sentry:sentry-apollo3:{{ packages.version('sentry.java.apollo For other dependency managers, see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-apollo3). -## Configure with Extension +## Configure With Extension Add `Interceptors` to `ApolloClient.Builder` using `ApolloBuilderExtensions`: From bfa494e43dbfcf6cdf32dcc510bc925625d15202 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Thu, 14 Jul 2022 14:56:04 +0200 Subject: [PATCH 08/10] Update src/platforms/android/configuration/integrations/apollo3.mdx Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> --- src/platforms/android/configuration/integrations/apollo3.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/android/configuration/integrations/apollo3.mdx b/src/platforms/android/configuration/integrations/apollo3.mdx index 30d628c676024..aa4bfc5d55bf5 100644 --- a/src/platforms/android/configuration/integrations/apollo3.mdx +++ b/src/platforms/android/configuration/integrations/apollo3.mdx @@ -16,7 +16,7 @@ Capturing transactions requires that you first -Sentry Apollo3 integration provides the `SentryApollo3Interceptor` and the `SentryApollo3HttpInterceptor`, which create a span for each outgoing HTTP request executed with an [Apollo Kotlin](https://github.com/apollographql/apollo-kotlin) GraphQL client. For easier usage the integration also provides extension functions on the `ApolloClient.Builder`. +Sentry Apollo3 integration provides the `SentryApollo3Interceptor` and the `SentryApollo3HttpInterceptor`, which create a span for each outgoing HTTP request executed with an [Apollo Kotlin](https://github.com/apollographql/apollo-kotlin) GraphQL client. For easier usage, the integration also provides extension functions on the `ApolloClient.Builder`. ## Install From 05d9afd049dc2f14e0006e38b8bd36167631ff16 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Thu, 14 Jul 2022 15:11:39 +0200 Subject: [PATCH 09/10] Changes from Review, use correct package name --- .../android/configuration/integrations/apollo3.mdx | 8 +++----- .../java/common/performance/instrumentation/apollo.mdx | 2 ++ .../java/common/performance/instrumentation/apollo3.mdx | 8 +++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/platforms/android/configuration/integrations/apollo3.mdx b/src/platforms/android/configuration/integrations/apollo3.mdx index aa4bfc5d55bf5..da0d7df131699 100644 --- a/src/platforms/android/configuration/integrations/apollo3.mdx +++ b/src/platforms/android/configuration/integrations/apollo3.mdx @@ -2,12 +2,10 @@ title: Apollo3 caseStyle: camelCase supportLevel: production -sdk: sentry.java.apollo3 +sdk: sentry.java.apollo-3 description: "Learn more about the Sentry Apollo3 integration for the Android SDK." categories: - mobile -redirect_from: - - /platforms/android/performance/instrumentation/apollo3/ --- @@ -21,10 +19,10 @@ Sentry Apollo3 integration provides the `SentryApollo3Interceptor` and the `Sent ## Install ```groovy {tabTitle:Gradle} -implementation 'io.sentry:sentry-apollo3:{{ packages.version('sentry.java.apollo3', '6.1.4') }}' +implementation 'io.sentry:sentry-apollo-3:{{ packages.version('sentry.java.apollo-3', '6.1.4') }}' ``` -For other dependency managers, see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-apollo3). +For other dependency managers, see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-apollo-3). ## Configure With Extension diff --git a/src/platforms/java/common/performance/instrumentation/apollo.mdx b/src/platforms/java/common/performance/instrumentation/apollo.mdx index b3b88e3583482..6df6e2069fd5c 100644 --- a/src/platforms/java/common/performance/instrumentation/apollo.mdx +++ b/src/platforms/java/common/performance/instrumentation/apollo.mdx @@ -75,7 +75,9 @@ Sentry.init(options -> { ``` + In Global Hub Mode, all threads use the same Hub. + ## Using With Kotlin Coroutines diff --git a/src/platforms/java/common/performance/instrumentation/apollo3.mdx b/src/platforms/java/common/performance/instrumentation/apollo3.mdx index 06d78991c3da6..7db2ce41720ff 100644 --- a/src/platforms/java/common/performance/instrumentation/apollo3.mdx +++ b/src/platforms/java/common/performance/instrumentation/apollo3.mdx @@ -14,7 +14,7 @@ Capturing transactions requires that you first -Sentry Apollo3 integration provides the `SentryApollo3Interceptor` and the `SentryApollo3HttpInterceptor`, which create a span for each outgoing HTTP request executed with an [Apollo Kotlin](https://github.com/apollographql/apollo-kotlin) GraphQL client. For easier usage the integration also provides extension functions on the `ApolloClient.Builder`. +Sentry Apollo3 integration provides the `SentryApollo3Interceptor` and the `SentryApollo3HttpInterceptor`, which create a span for each outgoing HTTP request executed with an [Apollo Kotlin](https://github.com/apollographql/apollo-kotlin) GraphQL client. For easier usage, the integration also provides extension functions on the `ApolloClient.Builder`. ## Install @@ -36,7 +36,7 @@ libraryDependencies += "io.sentry" % "sentry-apollo-3" % "{{ packages.version('s For other dependency managers, see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-apollo-3). -## Configure with Extension +## Configure With Extension Add `Interceptors` to `ApolloClient.Builder` using `ApolloBuilderExtensions`: @@ -61,7 +61,7 @@ val apollo = ApolloClient.builder() ``` ## Manual Configuration -When using a custom `NetworkTransport`, the `SentryInterceptors` need to be added manually, because then `HttpInterceptors` need to be added to the `NetworkTransport`. +When using a custom `NetworkTransport`, the `SentryInterceptors` need to be added manually, because `HttpInterceptors` need to be added to the `NetworkTransport`: ```java import com.apollographql.apollo.ApolloClient; @@ -113,7 +113,9 @@ Sentry.init(options -> { ``` + In Global Hub Mode, all threads use the same Hub. + ## Using With Kotlin Coroutines From e06fccb47468ad5609255133faf66baae98d1a44 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Fri, 5 Aug 2022 14:34:23 +0200 Subject: [PATCH 10/10] fix code samples --- .../configuration/integrations/apollo3.mdx | 25 ++++++++-------- .../performance/instrumentation/apollo3.mdx | 30 ++++++++++--------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/platforms/android/configuration/integrations/apollo3.mdx b/src/platforms/android/configuration/integrations/apollo3.mdx index da0d7df131699..cc418aecc3a3d 100644 --- a/src/platforms/android/configuration/integrations/apollo3.mdx +++ b/src/platforms/android/configuration/integrations/apollo3.mdx @@ -29,17 +29,16 @@ For other dependency managers, see the [central Maven repository](https://search Add `Interceptors` to `ApolloClient.Builder` using `ApolloBuilderExtensions`: ```java -import com.apollographql.apollo.ApolloClient; -import io.sentry.apollo3.ApolloBuilderExtensionsKt; +import com.apollographql.apollo3.ApolloClient; +import io.sentry.apollo3.SentryApolloBuilderExtensionsKt; -ApolloClient apollo = ApolloBuilderExtensionsKt.sentryTracing(new ApolloClient.Builder()) +ApolloClient apollo = SentryApolloBuilderExtensionsKt.sentryTracing(new ApolloClient.Builder()) .serverUrl("https://your-api-host/") - .sentryTracing() .build(); ``` ```kotlin -import com.apollographql.apollo.ApolloClient +import com.apollographql.apollo3.ApolloClient import io.sentry.apollo3.sentryTracing val apollo = ApolloClient.builder() @@ -52,8 +51,10 @@ val apollo = ApolloClient.builder() When using a custom `NetworkTransport`, the `SentryInterceptors` need to be added manually, because `HttpInterceptors` need to be added to the `NetworkTransport`: ```java -import com.apollographql.apollo.ApolloClient; -import io.sentry.apollo3.ApolloBuilderExtensionsKt; +import com.apollographql.apollo3.ApolloClient; +import com.apollographql.apollo3.network.http.HttpNetworkTransport; +import io.sentry.apollo3.SentryApollo3HttpInterceptor; +import io.sentry.apollo3.SentryApollo3Interceptor; ApolloClient apollo = new ApolloClient.Builder() .networkTransport( @@ -66,7 +67,7 @@ ApolloClient apollo = new ApolloClient.Builder() ``` ```kotlin -import com.apollographql.apollo.ApolloClient +import com.apollographql.apollo3.ApolloClient import io.sentry.apollo3.SentryApollo3HttpInterceptor import io.sentry.apollo3.SentryApollo3Interceptor import com.apollographql.apollo3.network.http.HttpNetworkTransport @@ -87,8 +88,8 @@ val apollo = ApolloClient.builder() Spans created around requests can be modified or dropped using `SentryApollo3HttpInterceptor.BeforeSpanCallback` passed to `SentryApollo3HttpInterceptor` or the `sentryTracing` extension function: ```java -import com.apollographql.apollo.ApolloClient; -import io.sentry.apollo.SentryApolloInterceptor; +import com.apollographql.apollo3.ApolloClient; +import io.sentry.apollo3.SentryApolloBuilderExtensionsKt; ApolloClient apollo = SentryApolloBuilderExtensionsKt.sentryTracing( new ApolloClient.Builder(), @@ -103,8 +104,8 @@ ApolloClient apollo = SentryApolloBuilderExtensionsKt.sentryTracing( ``` ```kotlin -import com.apollographql.apollo.ApolloClient -import io.sentry.apollo.SentryApolloInterceptor +import com.apollographql.apollo3.ApolloClient +import io.sentry.apollo3.sentryTracing val apollo = ApolloClient.builder() .serverUrl("https://apollo-fullstack-tutorial.herokuapp.com/graphql") diff --git a/src/platforms/java/common/performance/instrumentation/apollo3.mdx b/src/platforms/java/common/performance/instrumentation/apollo3.mdx index 7db2ce41720ff..37a3cc115cc35 100644 --- a/src/platforms/java/common/performance/instrumentation/apollo3.mdx +++ b/src/platforms/java/common/performance/instrumentation/apollo3.mdx @@ -38,20 +38,19 @@ For other dependency managers, see the [central Maven repository](https://search ## Configure With Extension -Add `Interceptors` to `ApolloClient.Builder` using `ApolloBuilderExtensions`: +Add `Interceptors` to `ApolloClient.Builder` using `SentryApolloBuilderExtensions`: ```java -import com.apollographql.apollo.ApolloClient; -import io.sentry.apollo3.ApolloBuilderExtensionsKt; +import com.apollographql.apollo3.ApolloClient; +import io.sentry.apollo3.SentryApolloBuilderExtensionsKt; -ApolloClient apollo = ApolloBuilderExtensionsKt.sentryTracing(new ApolloClient.Builder()) +ApolloClient apollo = SentryApolloBuilderExtensionsKt.sentryTracing(new ApolloClient.Builder()) .serverUrl("https://your-api-host/") - .sentryTracing() .build(); ``` ```kotlin -import com.apollographql.apollo.ApolloClient +import com.apollographql.apollo3.ApolloClient import io.sentry.apollo3.sentryTracing val apollo = ApolloClient.builder() @@ -64,8 +63,10 @@ val apollo = ApolloClient.builder() When using a custom `NetworkTransport`, the `SentryInterceptors` need to be added manually, because `HttpInterceptors` need to be added to the `NetworkTransport`: ```java -import com.apollographql.apollo.ApolloClient; -import io.sentry.apollo3.ApolloBuilderExtensionsKt; +import com.apollographql.apollo3.ApolloClient; +import com.apollographql.apollo3.network.http.HttpNetworkTransport; +import io.sentry.apollo3.SentryApollo3HttpInterceptor; +import io.sentry.apollo3.SentryApollo3Interceptor; ApolloClient apollo = new ApolloClient.Builder() .networkTransport( @@ -78,7 +79,7 @@ ApolloClient apollo = new ApolloClient.Builder() ``` ```kotlin -import com.apollographql.apollo.ApolloClient +import com.apollographql.apollo3.ApolloClient import io.sentry.apollo3.SentryApollo3HttpInterceptor import io.sentry.apollo3.SentryApollo3Interceptor import com.apollographql.apollo3.network.http.HttpNetworkTransport @@ -123,8 +124,9 @@ In Global Hub Mode, all threads use the same Hub. To make sure that a coroutine has access to the correct Sentry context, provide an instance of `SentryContext` when launching a coroutine: ```kotlin +import com.apollographql.apollo3.ApolloClient +import com.apollographql.apollo3.exception.ApolloException import io.sentry.kotlin.SentryContext -import com.apollographql.apollo.exception.ApolloException import kotlinx.coroutines.launch launch(SentryContext()) { @@ -142,8 +144,8 @@ launch(SentryContext()) { Spans created around requests can be modified or dropped using `SentryApollo3HttpInterceptor.BeforeSpanCallback` passed to `SentryApollo3HttpInterceptor` or the `sentryTracing` extension function: ```java -import com.apollographql.apollo.ApolloClient; -import io.sentry.apollo.SentryApolloInterceptor; +import com.apollographql.apollo3.ApolloClient; +import io.sentry.apollo3.SentryApolloBuilderExtensionsKt; ApolloClient apollo = SentryApolloBuilderExtensionsKt.sentryTracing( new ApolloClient.Builder(), @@ -158,8 +160,8 @@ ApolloClient apollo = SentryApolloBuilderExtensionsKt.sentryTracing( ``` ```kotlin -import com.apollographql.apollo.ApolloClient -import io.sentry.apollo.SentryApolloInterceptor +import com.apollographql.apollo3.ApolloClient +import io.sentry.apollo3.sentryTracing val apollo = ApolloClient.builder() .serverUrl("https://apollo-fullstack-tutorial.herokuapp.com/graphql")