Skip to content

Commit

Permalink
feat(flutter): document how to add data to spans/transactions (#12367)
Browse files Browse the repository at this point in the history
* add span data info to dart

* update flutter page

* Apply suggestions from code review

Co-authored-by: Karl Heinz Struggl <[email protected]>

* Apply suggestions from code review

Co-authored-by: Alex Krawiec <[email protected]>

* Update dart.mdx

* Update dart.mdx

---------

Co-authored-by: Karl Heinz Struggl <[email protected]>
Co-authored-by: Alex Krawiec <[email protected]>
  • Loading branch information
3 people authored Jan 20, 2025
1 parent c5c59c5 commit 7de987d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ To capture transactions and spans customized to your organization's needs, you m
<PlatformContent includePath="performance/retrieve-transaction" />

<PlatformContent includePath="performance/connect-errors-spans" />

<PlatformContent includePath="performance/improving-data" />
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ To capture transactions and spans customized to your organization's needs, you m
<PlatformContent includePath="performance/retrieve-transaction" />

<PlatformContent includePath="performance/connect-errors-spans" />

<PlatformContent includePath="performance/improving-data" />
29 changes: 29 additions & 0 deletions platform-includes/performance/improving-data/dart.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Adding Data Attributes to Transactions and Spans

You can add data attributes to your transactions and spans. This data is visible in the trace explorer in Sentry. Data attributes can be of type `String`, `int`, `double` or `bool`, as well as (non-mixed) arrays of these types:

### For Transactions

```dart
final transaction = Sentry.startTransaction('my-transaction', 'http.server');
transaction.setData('data_attribute_1', 'value1');
transaction.setData('data_attribute_2', 42);
transaction.setData('data_attribute_3', true);
transaction.setData('data_attribute_4', ['value1', 'value2']);
transaction.setData('data_attribute_5', [42, 43]);
transaction.setData('data_attribute_6', [true, false]);
```

### For Spans

```dart
final span = parent.startChild('http.client');
span.setData('data_attribute_1', 'value1');
span.setData('data_attribute_2', 42);
span.setData('data_attribute_3', true);
span.setData('data_attribute_4', ['value1', 'value2']);
span.setData('data_attribute_5', [42, 43]);
span.setData('data_attribute_6', [true, false]);
```

0 comments on commit 7de987d

Please sign in to comment.