Skip to content

Commit c28741d

Browse files
brustolinshanamatthewsphilipphofmann
authored
feat(apple): Add tracePropagationTarget to automatic instrumentation (#7160)
Added an explanation on how to filter out requests that will contain the trace id by using 'tracePropagationTarget' option. Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com> Co-authored-by: Philipp Hofmann <philipp.hofmann@sentry.io>
1 parent 386c4cb commit c28741d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/platforms/apple/common/performance/instrumentation/automatic-instrumentation.mdx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,35 @@ SentrySDK.start { options in
161161
[NSURLSession]: https://developer.apple.com/documentation/foundation/nsurlsession
162162
[NSURLConnection]: https://developer.apple.com/documentation/foundation/nsurlconnection
163163
164+
### Trace Propagation Targets
165+
166+
Sentry adds an extra header with the trace id in the outgoing HTTP requests to continue the transaction in the backend.
167+
168+
You can set the `tracePropagationTarget` option to filter which requests Sentry adds the extra header to.
169+
For example, to ensure that only your app backend will receive the trace id.
170+
171+
```swift {tabTitle:Swift}
172+
import Sentry
173+
174+
SentrySDK.start { options in
175+
options.dsn = "___PUBLIC_DSN___"
176+
options.tracePropagationTargets = ["MyAppDomain.com"]
177+
}
178+
```
179+
180+
```objc {tabTitle:Objective-C}
181+
@import Sentry;
182+
183+
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
184+
options.dsn = @"___PUBLIC_DSN___";
185+
options.tracePropagationTargets = @[@"MyAppDomain.com"]
186+
}];
187+
```
188+
189+
The option may contain a list of `NSString` or `NSRegularExpression` against which the URLs of outgoing requests are matched. If one of the entries in the list matches the URL of an outgoing request, trace data will be attached to that request. String entries do not have to be full matches, meaning the URL of a request is matched when it contains a string provided through the option.
190+
191+
If `tracePropagationTargets` is not provided, trace data is attached to every outgoing request from the instrumented client.
192+
164193
## File I/O Tracing
165194
166195
The Sentry SDK adds spans for file I/O operations to ongoing transactions bound to the scope. Currently, the SDK supports operations with [NSData][NSData], but many other APIs like [NSFileManager][NSFileManager], [NSString][NSString] and [NSBundle][NSBundle] uses [NSData][NSData].

0 commit comments

Comments
 (0)