|
| 1 | +## Improving Data on Transactions and Spans |
| 2 | + |
| 3 | +### Adding Data Attributes to Transactions |
| 4 | + |
| 5 | +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: |
| 6 | + |
| 7 | +```swift {tabTitle:Swift} |
| 8 | +let transaction = SentrySDK.startTransaction(name: "processOrderBatch", operation: "task") |
| 9 | +transaction.setData(value: "value1", key: "my-data-attribute-1") |
| 10 | +transaction.setData(value: 42, key: "my-data-attribute-2") |
| 11 | +transaction.setData(value: true, key: "my-data-attribute-3") |
| 12 | + |
| 13 | +transaction.setData(value: ["value1", "value2", "value3"], key: "my-data-attribute-4") |
| 14 | +transaction.setData(value: [42, 43, 44], key: "my-data-attribute-5") |
| 15 | +transaction.setData(value: [true, false, true], key: "my-data-attribute-6") |
| 16 | +``` |
| 17 | +```objc {tabTitle:Objective-C} |
| 18 | +id<SentrySpan> transaction = [SentrySDK startTransactionWithName:@"processOrderBatch" operation:@"task"]; |
| 19 | +[transaction setDataValue:@"value1" forKey:@"my-data-attribute-1"]; |
| 20 | +[transaction setDataValue:@(42) forKey:@"my-data-attribute-2"]; |
| 21 | +[transaction setDataValue:@(YES) forKey:@"my-data-attribute-3"]; |
| 22 | + |
| 23 | +[transaction setDataValue:@[@"value1", @"value2", @"value3"] forKey:@"my-data-attribute-4"]; |
| 24 | +[transaction setDataValue:@[@(42), @(43), @(44)] forKey:@"my-data-attribute-5"]; |
| 25 | +[transaction setDataValue:@[@(YES), @(NO), @(YES)] forKey:@"my-data-attribute-6"]; |
| 26 | +``` |
| 27 | +
|
| 28 | +### Adding Data Attributes to Spans |
| 29 | +
|
| 30 | +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: |
| 31 | +
|
| 32 | +```swift {tabTitle:Swift} |
| 33 | +let span = parent.startChild(operation: "operation") |
| 34 | +span.setData(value: "value1", key: "my-data-attribute-1") |
| 35 | +span.setData(value: 42, key: "my-data-attribute-2") |
| 36 | +span.setData(value: true, key: "my-data-attribute-3") |
| 37 | +
|
| 38 | +span.setData(value: ["value1", "value2", "value3"], key: "my-data-attribute-4") |
| 39 | +span.setData(value: [42, 43, 44], key: "my-data-attribute-5") |
| 40 | +span.setData(value: [true, false, true], key: "my-data-attribute-6") |
| 41 | +``` |
| 42 | +```objc {tabTitle:Objective-C} |
| 43 | +id<SentrySpan> span = [transaction startChildWithOperation:@"task"]; |
| 44 | +[span setDataValue:@"value1" forKey:@"my-data-attribute-1"]; |
| 45 | +[span setDataValue:@(42) forKey:@"my-data-attribute-2"]; |
| 46 | +[span setDataValue:@(YES) forKey:@"my-data-attribute-3"]; |
| 47 | + |
| 48 | +[span setDataValue:@[@"value1", @"value2", @"value3"] forKey:@"my-data-attribute-4"]; |
| 49 | +[span setDataValue:@[@(42), @(43), @(44)] forKey:@"my-data-attribute-5"]; |
| 50 | +[span setDataValue:@[@(YES), @(NO), @(YES)] forKey:@"my-data-attribute-6"]; |
| 51 | +``` |
0 commit comments