From d69c4c3e6a81632bced3f0692adc6f553629cb97 Mon Sep 17 00:00:00 2001 From: markushi Date: Thu, 28 Aug 2025 07:59:29 +0200 Subject: [PATCH 1/2] chore(java): Add docs on how to use tracePropagationTargets --- .../tracing/trace-propagation/index.mdx | 31 +++++++++++++++++++ .../tracing/trace-propagation/index.mdx | 31 +++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/docs/platforms/android/tracing/trace-propagation/index.mdx b/docs/platforms/android/tracing/trace-propagation/index.mdx index fb41f4dd98c48f..1a5b3a47edd8dc 100644 --- a/docs/platforms/android/tracing/trace-propagation/index.mdx +++ b/docs/platforms/android/tracing/trace-propagation/index.mdx @@ -32,3 +32,34 @@ If you run any JavaScript applications in your distributed system, make sure tha Remember that in order to propagate trace information through your whole distributed system, you have to use Sentry in all of the involved services and applications. Take a look at the respective SDK documentation to learn how distributed tracing can be enabled for each platform. + +### tracePropagationTargets + +The Android SDK will attach the `sentry-trace` and `baggage` headers to all outgoing requests by default. To narrow +this down to only specific URLs, add those URLs to the `tracePropagationTargets` allowlist, (you can use both +strings and regexes). The SDK will then only attach the `sentry-trace` and `baggage` headers to outgoing requests matching the allowlist. + + +The `tracePropagationTargets` option can contain full URLs (e.g. `"https://api.myproject.org/request/path"`), sub-strings (e.g. `"api.myproject.org"`) or regular expressions (e.g. `"https://[\w]*\.myproject\.org/.*"`). + + +Since the value of `tracePropagationTargets` is `".*"` by default, tracing headers are attached to all requests unless otherwise specified. + +```swift {tabTitle:Java} +SentryAndroid.init(context, options -> { + final ArrayList tracePropagationTargets = new ArrayList<>(); + tracePropagationTargets.add("https://api.myproject.org/"); + + options.setDsn("___PUBLIC_DSN___"); + options.setTracePropagationTargets(tracePropagationTargets); +}); +``` + +```objc {tabTitle:Kotlin} +SentryAndroid.init(context, { options -> + options.setDsn("___PUBLIC_DSN___") + options.setTracePropagationTargets(listOf( + "https://api.myproject.org/" + )) +}) +``` diff --git a/docs/platforms/java/common/tracing/trace-propagation/index.mdx b/docs/platforms/java/common/tracing/trace-propagation/index.mdx index fb41f4dd98c48f..5f72458f071ca1 100644 --- a/docs/platforms/java/common/tracing/trace-propagation/index.mdx +++ b/docs/platforms/java/common/tracing/trace-propagation/index.mdx @@ -32,3 +32,34 @@ If you run any JavaScript applications in your distributed system, make sure tha Remember that in order to propagate trace information through your whole distributed system, you have to use Sentry in all of the involved services and applications. Take a look at the respective SDK documentation to learn how distributed tracing can be enabled for each platform. + +### tracePropagationTargets + +The Java SDK will attach the `sentry-trace` and `baggage` headers to all outgoing requests by default. To narrow +this down to only specific URLs, add those URLs to the `tracePropagationTargets` allowlist, (you can use both +strings and regexes). The SDK will then only attach the `sentry-trace` and `baggage` headers to outgoing requests matching the allowlist. + + +The `tracePropagationTargets` option can contain full URLs (e.g. `"https://api.myproject.org/request/path"`), sub-strings (e.g. `"api.myproject.org"`) or regular expressions (e.g. `"https://[\w]*\.myproject\.org/.*"`). + + +Since the value of `tracePropagationTargets` is `".*"` by default, tracing headers are attached to all requests unless otherwise specified. + +```swift {tabTitle:Java} +Sentry.init(context, options -> { + final ArrayList tracePropagationTargets = new ArrayList<>(); + tracePropagationTargets.add("https://api.myproject.org/"); + + options.setDsn("___PUBLIC_DSN___"); + options.setTracePropagationTargets(tracePropagationTargets); +}); +``` + +```objc {tabTitle:Kotlin} +Sentry.init(context, { options -> + options.setDsn("___PUBLIC_DSN___") + options.setTracePropagationTargets(listOf( + "https://api.myproject.org/" + )) +}) +``` \ No newline at end of file From 787723258f59540417379ef4d669efa8040cdc0b Mon Sep 17 00:00:00 2001 From: Markus Hintersteiner Date: Thu, 28 Aug 2025 08:25:46 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Alexander Dinauer --- docs/platforms/android/tracing/trace-propagation/index.mdx | 4 ++-- .../platforms/java/common/tracing/trace-propagation/index.mdx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/platforms/android/tracing/trace-propagation/index.mdx b/docs/platforms/android/tracing/trace-propagation/index.mdx index 1a5b3a47edd8dc..8661a8cb00572f 100644 --- a/docs/platforms/android/tracing/trace-propagation/index.mdx +++ b/docs/platforms/android/tracing/trace-propagation/index.mdx @@ -45,7 +45,7 @@ The `tracePropagationTargets` option can contain full URLs (e.g. `"https://api.m Since the value of `tracePropagationTargets` is `".*"` by default, tracing headers are attached to all requests unless otherwise specified. -```swift {tabTitle:Java} +```java {tabTitle:Java} SentryAndroid.init(context, options -> { final ArrayList tracePropagationTargets = new ArrayList<>(); tracePropagationTargets.add("https://api.myproject.org/"); @@ -55,7 +55,7 @@ SentryAndroid.init(context, options -> { }); ``` -```objc {tabTitle:Kotlin} +```kotlin {tabTitle:Kotlin} SentryAndroid.init(context, { options -> options.setDsn("___PUBLIC_DSN___") options.setTracePropagationTargets(listOf( diff --git a/docs/platforms/java/common/tracing/trace-propagation/index.mdx b/docs/platforms/java/common/tracing/trace-propagation/index.mdx index 5f72458f071ca1..7aaff1a8837763 100644 --- a/docs/platforms/java/common/tracing/trace-propagation/index.mdx +++ b/docs/platforms/java/common/tracing/trace-propagation/index.mdx @@ -45,7 +45,7 @@ The `tracePropagationTargets` option can contain full URLs (e.g. `"https://api.m Since the value of `tracePropagationTargets` is `".*"` by default, tracing headers are attached to all requests unless otherwise specified. -```swift {tabTitle:Java} +```java {tabTitle:Java} Sentry.init(context, options -> { final ArrayList tracePropagationTargets = new ArrayList<>(); tracePropagationTargets.add("https://api.myproject.org/"); @@ -55,7 +55,7 @@ Sentry.init(context, options -> { }); ``` -```objc {tabTitle:Kotlin} +```kotlin {tabTitle:Kotlin} Sentry.init(context, { options -> options.setDsn("___PUBLIC_DSN___") options.setTracePropagationTargets(listOf(