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 all commits
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
37 changes: 37 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,40 @@ 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

The Cocoa 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
string and regexes). The SDK will then only attach the `sentry-trace` and `baggage` headers to outgoing requests
whose destination either contains a string or matches a regex in your allowlist.

<Note>
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.
</Note>

Since the value of `tracePropagationTargets` is `['.*']` by default, tracing headers are attached to all requests unless otherwise specified.

```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