Skip to content

Commit 5f4bcc7

Browse files
antonisitaybre
andauthored
docs: Add strict trace continuation for Apple (#17140)
## DESCRIBE YOUR PR Add documentation for the `strictTraceContinuation` and `orgId` options for the Apple (Cocoa) SDK. **Changes:** - **`options.mdx`** — Add `strictTraceContinuation` and `orgId` option descriptions to the Apple SDK configuration options page - **`apple.mdx`** — Add strict trace continuation section to the Apple distributed tracing guide with Swift code examples Related SDK PR: getsentry/sentry-cocoa#7705 ## IS YOUR CHANGE URGENT? - [ ] Urgent deadline (GA date, etc.): - [ ] Other deadline: - [x] None: Not urgent, can wait up to 1 week+ ⚠️ Should be merged after getsentry/sentry-cocoa#7705 is released ## PRE-MERGE CHECKLIST - [ ] 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) --------- Co-authored-by: Itay Brenner <itaybrenner@hotmail.com>
1 parent 7881580 commit 5f4bcc7

File tree

2 files changed

+48
-0
lines changed
  • docs/platforms/apple/common/configuration
  • platform-includes/distributed-tracing/how-to-use

2 files changed

+48
-0
lines changed

docs/platforms/apple/common/configuration/options.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,24 @@ If <PlatformIdentifier name="tracePropagationTargets" /> is not provided, trace
569569
</SdkOption>
570570
571571
572+
<SdkOption name="strictTraceContinuation" type="Bool" defaultValue="false">
573+
574+
If set to `true`, the SDK will only continue a trace if the organization ID of the incoming trace found in the `baggage` header matches the organization ID of the current Sentry client.
575+
576+
The client's organization ID is extracted from the DSN or can be set with the `orgId` option.
577+
578+
If the organization IDs do not match, the SDK will start a new trace instead of continuing the incoming one. This is useful to prevent traces of unknown third-party services from being continued in your application.
579+
580+
</SdkOption>
581+
582+
<SdkOption name="orgId" type="String?">
583+
584+
The organization ID for your Sentry project.
585+
586+
The SDK will try to extract the organization ID from the DSN. If it cannot be found, or if you need to override it, you can provide the ID with this option. The organization ID is used for trace propagation and features like `strictTraceContinuation`.
587+
588+
</SdkOption>
589+
572590
<SdkOption name="enablePropagateTraceparent" type="bool" defaultValue="false" availableSince="9.0.0">
573591
574592
This option is available as of [version 9.0.0](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#9000).
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
11
If you're using the current version of our Cocoa SDK, distributed tracing will work out of the box.
22

33
If you're using version `8.10.x` or below, you'll need to have our <PlatformLink to="/tracing/instrumentation/automatic-instrumentation/#network-tracking">Network Tracking feature enabled</PlatformLink> in order for distributed tracing to work.
4+
5+
### Strict Trace Continuation
6+
7+
When your application communicates with backend services, the responses might include `sentry-trace` and `baggage` headers from an upstream service that is also using Sentry.
8+
By default, the SDK will continue the trace from these incoming headers. However, this behavior can be undesirable if the responses are from a third-party service,
9+
as it can lead to unwanted traces, increased billing, and skewed performance data.
10+
11+
To prevent this, you can enable `strictTraceContinuation`. When this option is set to `true`, the SDK checks incoming trace information and *only* continues the trace if it belongs to the same Sentry organization.
12+
Otherwise, it starts a new trace.
13+
14+
```swift {4}
15+
SentrySDK.start { options in
16+
options.dsn = "___PUBLIC_DSN___"
17+
options.tracesSampleRate = 1.0
18+
// Ensure that only traces from your own organization are continued
19+
options.strictTraceContinuation = true
20+
}
21+
```
22+
23+
The SDK automatically parses the organization ID from your DSN. If you use a DSN format that doesn't include the organization ID (number followed by the letter `"o"`), or if you need to override it, you can provide it manually using the `orgId` option:
24+
25+
```swift {5}
26+
SentrySDK.start { options in
27+
options.dsn = "___PUBLIC_DSN___"
28+
options.tracesSampleRate = 1.0
29+
options.strictTraceContinuation = true
30+
// Manually provide your organization ID (overrides organization ID parsed from DSN)
31+
options.orgId = "12345"
32+
}
33+
```

0 commit comments

Comments
 (0)