Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(apple): Clarify trace propagation targets #9110

Merged
merged 3 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/platforms/apple/common/usage/distributed-tracing/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,38 @@ If you run any JavaScript applications in your distributed system, make sure tha
<PlatformContent includePath="distributed-tracing/how-to-use/" />

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

Per default, the Cocoa SDK will attach the `sentry-trace` and `baggage` headers to all outgoing requests. You
can use the allowlist `tracePropagationTargets` to specify to which URLs the Cocoa SDK should send these headers.
philipphofmann marked this conversation as resolved.
Show resolved Hide resolved
You can put string or regexes into the allowlist, and the SDK then only attaches the `sentry-trace` and `baggage`
philipphofmann marked this conversation as resolved.
Show resolved Hide resolved
headers to all outgoing requests whose destination contains a string in the list or matches a regex in the list.

**The `tracePropagationTargets` option matches the entire request URL, not just the domain. Using stricter regex to match certain parts of the URL ensures that requests don't unnecessarily have additional headers attached.**
Copy link
Member

@kahest kahest Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**The `tracePropagationTargets` option matches the entire request URL, not just the domain. Using stricter regex to match certain parts of the URL ensures that requests don't unnecessarily have additional headers attached.**
**Because the `tracePropagationTargets` option matches the entire request URL, not just the domain, you should use strict regexes that match specific parts of the URL to ensure that requests don't have unnecessary or unwanted headers attached.**

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to turn this into a note rather than bolding it.


The default value of `tracePropagationTargets` is `['.*']`. This means that by default, tracing headers are attached to all requests.
philipphofmann marked this conversation as resolved.
Show resolved Hide resolved

```swift {tabTitle:Swift}
import Sentry

SentrySDK.start { options in
options.dsn = "___PUBLIC_DSN___"
options.tracePropagationTargets = [
"https://myproject.org",
"https://api.otherservice.org/",
]
}
```

```objc {tabTitle:Objective-C}
@import Sentry;

[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.tracePropagationTargets = @[
@"https://myproject.org",
@"https://api.otherservice.org/"
];
}];
```
24 changes: 0 additions & 24 deletions platform-includes/distributed-tracing/how-to-use/apple.mdx
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
If you're using the current version of our Cocoa SDK, distributed tracing will work out of the box.

```swift {tabTitle:Swift}
import Sentry

SentrySDK.start { options in
options.dsn = "___PUBLIC_DSN___"
options.tracePropagationTargets = [
"https://myproject.org",
"https://api.otherservice.org/",
]
}
```

```objc {tabTitle:Objective-C}
@import Sentry;

[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.tracePropagationTargets = @[
@"https://myproject.org",
@"https://api.otherservice.org/"
];
}];
```

If you're using version `8.10.x` or below, you'll need to have our <PlatformLink to="/performance/instrumentation/automatic-instrumentation/#network-tracking">Network Tracking feature enabled</PlatformLink> in order for distributed tracing to work.
Loading