Skip to content

Commit 4d72109

Browse files
markushiadinauer
andauthored
chore(java): Add docs on how to use tracePropagationTargets (#14752)
## DESCRIBE YOUR PR Based on iOS docs: https://docs.sentry.io/platforms/apple/guides/ios/tracing/trace-propagation/ ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/) --------- Co-authored-by: Alexander Dinauer <[email protected]>
1 parent 7ffc130 commit 4d72109

File tree

2 files changed

+62
-0
lines changed
  • docs/platforms

2 files changed

+62
-0
lines changed

docs/platforms/android/tracing/trace-propagation/index.mdx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,34 @@ If you run any JavaScript applications in your distributed system, make sure tha
3232
<PlatformContent includePath="distributed-tracing/how-to-use/" />
3333

3434
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.
35+
36+
### tracePropagationTargets
37+
38+
The Android SDK will attach the `sentry-trace` and `baggage` headers to all outgoing requests by default. To narrow
39+
this down to only specific URLs, add those URLs to the `tracePropagationTargets` allowlist, (you can use both
40+
strings and regexes). The SDK will then only attach the `sentry-trace` and `baggage` headers to outgoing requests matching the allowlist.
41+
42+
<Alert>
43+
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/.*"`).
44+
</Alert>
45+
46+
Since the value of `tracePropagationTargets` is `".*"` by default, tracing headers are attached to all requests unless otherwise specified.
47+
48+
```java {tabTitle:Java}
49+
SentryAndroid.init(context, options -> {
50+
final ArrayList<String> tracePropagationTargets = new ArrayList<>();
51+
tracePropagationTargets.add("https://api.myproject.org/");
52+
53+
options.setDsn("___PUBLIC_DSN___");
54+
options.setTracePropagationTargets(tracePropagationTargets);
55+
});
56+
```
57+
58+
```kotlin {tabTitle:Kotlin}
59+
SentryAndroid.init(context, { options ->
60+
options.setDsn("___PUBLIC_DSN___")
61+
options.setTracePropagationTargets(listOf(
62+
"https://api.myproject.org/"
63+
))
64+
})
65+
```

docs/platforms/java/common/tracing/trace-propagation/index.mdx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,34 @@ If you run any JavaScript applications in your distributed system, make sure tha
3232
<PlatformContent includePath="distributed-tracing/how-to-use/" />
3333

3434
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.
35+
36+
### tracePropagationTargets
37+
38+
The Java SDK will attach the `sentry-trace` and `baggage` headers to all outgoing requests by default. To narrow
39+
this down to only specific URLs, add those URLs to the `tracePropagationTargets` allowlist, (you can use both
40+
strings and regexes). The SDK will then only attach the `sentry-trace` and `baggage` headers to outgoing requests matching the allowlist.
41+
42+
<Alert>
43+
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/.*"`).
44+
</Alert>
45+
46+
Since the value of `tracePropagationTargets` is `".*"` by default, tracing headers are attached to all requests unless otherwise specified.
47+
48+
```java {tabTitle:Java}
49+
Sentry.init(context, options -> {
50+
final ArrayList<String> tracePropagationTargets = new ArrayList<>();
51+
tracePropagationTargets.add("https://api.myproject.org/");
52+
53+
options.setDsn("___PUBLIC_DSN___");
54+
options.setTracePropagationTargets(tracePropagationTargets);
55+
});
56+
```
57+
58+
```kotlin {tabTitle:Kotlin}
59+
Sentry.init(context, { options ->
60+
options.setDsn("___PUBLIC_DSN___")
61+
options.setTracePropagationTargets(listOf(
62+
"https://api.myproject.org/"
63+
))
64+
})
65+
```

0 commit comments

Comments
 (0)