-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(apple): Attach data onto a span/transaction (#12520)
Add docs for how to attach data onto span/transaction. Fixes GH-12521
- Loading branch information
1 parent
2066d45
commit 52fe1bc
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
## Improving Data on Transactions and Spans | ||
|
||
### Adding Data Attributes to Transactions | ||
|
||
You can add data attributes to your transactions. This data is visible in the trace explorer in Sentry. Data attributes can be of type `String`, `Number` or `Boolean`, as well as (non-mixed) arrays of these types: | ||
|
||
```swift {tabTitle:Swift} | ||
let transaction = SentrySDK.startTransaction(name: "processOrderBatch", operation: "task") | ||
transaction.setData(value: "value1", key: "my-data-attribute-1") | ||
transaction.setData(value: 42, key: "my-data-attribute-2") | ||
transaction.setData(value: true, key: "my-data-attribute-3") | ||
|
||
transaction.setData(value: ["value1", "value2", "value3"], key: "my-data-attribute-4") | ||
transaction.setData(value: [42, 43, 44], key: "my-data-attribute-5") | ||
transaction.setData(value: [true, false, true], key: "my-data-attribute-6") | ||
``` | ||
```objc {tabTitle:Objective-C} | ||
id<SentrySpan> transaction = [SentrySDK startTransactionWithName:@"processOrderBatch" operation:@"task"]; | ||
[transaction setDataValue:@"value1" forKey:@"my-data-attribute-1"]; | ||
[transaction setDataValue:@(42) forKey:@"my-data-attribute-2"]; | ||
[transaction setDataValue:@(YES) forKey:@"my-data-attribute-3"]; | ||
|
||
[transaction setDataValue:@[@"value1", @"value2", @"value3"] forKey:@"my-data-attribute-4"]; | ||
[transaction setDataValue:@[@(42), @(43), @(44)] forKey:@"my-data-attribute-5"]; | ||
[transaction setDataValue:@[@(YES), @(NO), @(YES)] forKey:@"my-data-attribute-6"]; | ||
``` | ||
### Adding Data Attributes to Spans | ||
You can add data attributes to your spans. This data is visible in the trace explorer in Sentry. Data attributes can be of type `String`, `Number` or `Boolean`, as well as (non-mixed) arrays of these types: | ||
```swift {tabTitle:Swift} | ||
let span = parent.startChild(operation: "operation") | ||
span.setData(value: "value1", key: "my-data-attribute-1") | ||
span.setData(value: 42, key: "my-data-attribute-2") | ||
span.setData(value: true, key: "my-data-attribute-3") | ||
span.setData(value: ["value1", "value2", "value3"], key: "my-data-attribute-4") | ||
span.setData(value: [42, 43, 44], key: "my-data-attribute-5") | ||
span.setData(value: [true, false, true], key: "my-data-attribute-6") | ||
``` | ||
```objc {tabTitle:Objective-C} | ||
id<SentrySpan> span = [transaction startChildWithOperation:@"task"]; | ||
[span setDataValue:@"value1" forKey:@"my-data-attribute-1"]; | ||
[span setDataValue:@(42) forKey:@"my-data-attribute-2"]; | ||
[span setDataValue:@(YES) forKey:@"my-data-attribute-3"]; | ||
|
||
[span setDataValue:@[@"value1", @"value2", @"value3"] forKey:@"my-data-attribute-4"]; | ||
[span setDataValue:@[@(42), @(43), @(44)] forKey:@"my-data-attribute-5"]; | ||
[span setDataValue:@[@(YES), @(NO), @(YES)] forKey:@"my-data-attribute-6"]; | ||
``` |