Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/platforms/dart/common/configuration/filtering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,28 @@ It also allows you to sample different transactions at different rates.
If the transaction currently being processed has a parent transaction (from an upstream service calling this service), the parent (upstream) sampling decision will always be included in the sampling context data, so that your <PlatformIdentifier name="traces-sampler" /> can choose whether and when to inherit that decision. In most cases, inheritance is the right choice, to avoid breaking distributed traces. A broken trace will not include all your services. See <PlatformLink to="/configuration/sampling/#inheritance">Inheriting the parent sampling decision</PlatformLink> to learn more.

Learn more about <PlatformLink to="/configuration/sampling/">configuring the sample rate</PlatformLink>.

### Filtering Spans in Stream Mode

<Alert level="warning">

The options above apply to transactions. In stream mode there are no transactions — use `ignoreSpans` to drop spans and `beforeSendSpan` to modify them. See <PlatformLink to="/tracing/new-spans/#extended-configuration-optional">New Spans</PlatformLink> for details.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The options above apply to transactions."
Does this also apply to the "Using tracesSampler" section?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tracesSampler also works for span streaming. I guess this is confusingly worded


</Alert>

To drop spans whose name matches a rule, use `ignoreSpans`:

```dart
options.ignoreSpans = [
IgnoreSpanRule.nameEquals('health-check'),
IgnoreSpanRule.nameStartsWith('internal.'),
];
```

To modify (but not drop) span data before it's sent, use `beforeSendSpan`. It runs when each span ends and can't drop spans:

```dart
options.beforeSendSpan = (span) {
span.removeAttribute('http.request.body');
};
```
28 changes: 28 additions & 0 deletions docs/platforms/dart/common/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ A number between `0` and `1`, controlling the percentage chance a given transact

A function responsible for determining the percentage chance a given transaction will be sent to Sentry. It will automatically be passed information about the transaction and the context in which it's being created, and must return a number between `0` (0% chance of being sent) and `1` (100% chance of being sent). Can also be used for filtering transactions, by returning 0 for those that are unwanted. Either this or <PlatformIdentifier name="tracesSampleRate" /> must be defined to enable tracing.

In stream mode, the sampling context is different: read the span's `name` and `attributes` from `samplingContext.spanContext` instead of the transaction context. See <PlatformLink to="/tracing/new-spans/#sampling-optional">New Spans</PlatformLink>.

</SdkOption>

<SdkOption name="tracePropagationTargets" type="array">
Expand Down Expand Up @@ -258,3 +260,29 @@ The organization ID for your Sentry project.
The SDK will try to extract the organization ID from the DSN. If it can't be found, or if you need to override it, you can explicitly provide the ID with this option. The organization ID is used for trace propagation and features like `strictTraceContinuation`.

</SdkOption>

### Stream Mode

<Alert>

Stream mode is opt-in. The classic transaction-based mode (`SentryTraceLifecycle.static`) remains the default. See <PlatformLink to="/tracing/new-spans/">New Spans</PlatformLink> for the full guide.

</Alert>
Comment thread
buenaflor marked this conversation as resolved.
Outdated

<SdkOption name="traceLifecycle" type="enum" defaultValue="static" availableSince="9.23.0">

Controls how spans are collected and sent. With `SentryTraceLifecycle.static` (the default), spans are buffered and sent together as a transaction. With `SentryTraceLifecycle.stream`, spans are sent to Sentry as they finish, which removes the 1,000-span limit and makes trace data visible sooner. Stream mode requires the new span APIs (`Sentry.startSpan`).

</SdkOption>

<SdkOption name="beforeSendSpan" type="function" availableSince="9.23.0">

Only used in stream mode. Called when each span ends, receiving a `SentrySpanV2`. Use it to scrub or modify span attributes before the span is sent. Unlike other `beforeSend` callbacks, it can't drop spans — use `ignoreSpans` for that.

</SdkOption>

<SdkOption name="ignoreSpans" type="array" availableSince="9.23.0">

Only used in stream mode. A list of `IgnoreSpanRule`s that drop spans whose name matches a rule (`nameEquals`, `nameStartsWith`, `nameContains`, or `nameEndsWith`). See <PlatformLink to="/tracing/new-spans/#drop-spans">Drop Spans</PlatformLink>.

</SdkOption>
18 changes: 18 additions & 0 deletions docs/platforms/dart/common/configuration/sampling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ Changing the error sample rate requires re-deployment. In addition, setting an S

## Sampling Transaction Events

<Alert>

This section describes transaction mode (the default). In stream mode, `tracesSampleRate` works the same way, but a custom `tracesSampler` receives a different sampling context — read the span's `name` and `attributes` from `samplingContext.spanContext`. See <PlatformLink to="/tracing/new-spans/#sampling-optional">New Spans</PlatformLink>.

</Alert>

We recommend sampling your transactions for two reasons:

1. Capturing a single trace involves minimal overhead, but capturing traces for _every_ page load or _every_ API request may add an undesirable load to your system.
Expand Down Expand Up @@ -68,6 +74,12 @@ When using custom instrumentation to create a transaction, you can add data to t

<PlatformContent includePath="performance/custom-sampling-context" />

<Alert>

This applies to transaction mode. In stream mode there's no custom sampling context — pass data as span attributes when you start the span, then read them from `samplingContext.spanContext.attributes` in your `tracesSampler`. See <PlatformLink to="/tracing/new-spans/#sampling-optional">New Spans</PlatformLink>.

</Alert>

## Inheritance

Whatever a transaction's sampling decision, that decision will be passed to its child spans and from there to any transactions they subsequently cause in other services.
Expand All @@ -90,6 +102,12 @@ If you know at transaction creation time whether or not you want the transaction

<PlatformContent includePath="performance/force-sampling-decision" />

<Alert>

This applies to transaction mode. In stream mode you can't force a decision at span creation — control sampling with a `tracesSampler` that reads the span's `name` and `attributes`.

</Alert>

## Precedence

There are multiple ways for a transaction to end up with a sampling decision.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ SDKs provide a <PlatformIdentifier name="before-send" /> hook, which is invoked

<PlatformContent includePath="configuration/before-send/" />

In stream mode, transactions are replaced by streamed spans. Use `beforeSendSpan` to scrub span attributes before they're sent. See <PlatformLink to="/tracing/new-spans/#filter-spans">New Spans</PlatformLink>.

Sensitive data may appear in the following areas:

- Stack-locals → Some SDKs (Python, PHP and Node) will pick up variable values within the stack trace. These can be scrubbed, or this behavior can be disabled altogether if necessary.
Expand Down
25 changes: 25 additions & 0 deletions docs/platforms/dart/guides/flutter/configuration/filtering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,28 @@ It also allows you to sample different transactions at different rates.
If the transaction currently being processed has a parent transaction (from an upstream service calling this service), the parent (upstream) sampling decision will always be included in the sampling context data, so that your <PlatformIdentifier name="traces-sampler" /> can choose whether and when to inherit that decision. In most cases, inheritance is the right choice, to avoid breaking distributed traces. A broken trace will not include all your services. See <PlatformLink to="/configuration/sampling/#inheritance">Inheriting the parent sampling decision</PlatformLink> to learn more.

Learn more about <PlatformLink to="/configuration/sampling/">configuring the sample rate</PlatformLink>.

### Filtering Spans in Stream Mode

<Alert level="warning">

The options above apply to transactions. In stream mode there are no transactions — use `ignoreSpans` to drop spans and `beforeSendSpan` to modify them. See <PlatformLink to="/tracing/new-spans/#extended-configuration-optional">New Spans</PlatformLink> for details.

</Alert>

To drop spans whose name matches a rule, use `ignoreSpans`:

```dart
options.ignoreSpans = [
IgnoreSpanRule.nameEquals('health-check'),
IgnoreSpanRule.nameStartsWith('internal.'),
];
```

To modify (but not drop) span data before it's sent, use `beforeSendSpan`. It runs when each span ends and can't drop spans:

```dart
options.beforeSendSpan = (span) {
span.removeAttribute('http.request.body');
};
```
28 changes: 28 additions & 0 deletions docs/platforms/dart/guides/flutter/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ A number between `0` and `1`, controlling the percentage chance a given transact

A function responsible for determining the percentage chance a given transaction will be sent to Sentry. It will automatically be passed information about the transaction and the context in which it's being created, and must return a number between `0` (0% chance of being sent) and `1` (100% chance of being sent). Can also be used for filtering transactions, by returning 0 for those that are unwanted. Either this or <PlatformIdentifier name="tracesSampleRate" /> must be defined to enable tracing.

In stream mode, the sampling context is different: read the span's `name` and `attributes` from `samplingContext.spanContext` instead of the transaction context. See <PlatformLink to="/tracing/new-spans/#sampling-optional">New Spans</PlatformLink>.

</SdkOption>

<SdkOption name="tracePropagationTargets" type="array">
Expand All @@ -276,6 +278,32 @@ Controls whether the SDK should propagate the W3C `traceparent` HTTP header alon

</SdkOption>

### Stream Mode

<Alert>

Stream mode is opt-in. The classic transaction-based mode (`SentryTraceLifecycle.static`) remains the default. See <PlatformLink to="/tracing/new-spans/">New Spans</PlatformLink> for the full guide.

</Alert>

<SdkOption name="traceLifecycle" type="enum" defaultValue="static" availableSince="9.23.0">

Controls how spans are collected and sent. With `SentryTraceLifecycle.static` (the default), spans are buffered and sent together as a transaction. With `SentryTraceLifecycle.stream`, spans are sent to Sentry as they finish, which removes the 1,000-span limit and makes trace data visible sooner. Stream mode requires the new span APIs (`Sentry.startSpan`).

</SdkOption>

<SdkOption name="beforeSendSpan" type="function" availableSince="9.23.0">

Only used in stream mode. Called when each span ends, receiving a `SentrySpanV2`. Use it to scrub or modify span attributes before the span is sent. Unlike other `beforeSend` callbacks, it can't drop spans — use `ignoreSpans` for that.

</SdkOption>

<SdkOption name="ignoreSpans" type="array" availableSince="9.23.0">

Only used in stream mode. A list of `IgnoreSpanRule`s that drop spans whose name matches a rule (`nameEquals`, `nameStartsWith`, `nameContains`, or `nameEndsWith`). See <PlatformLink to="/tracing/new-spans/#drop-spans">Drop Spans</PlatformLink>.

</SdkOption>

## Experimental Features

<SdkOption name="experimental" type="object">
Expand Down
18 changes: 18 additions & 0 deletions docs/platforms/dart/guides/flutter/configuration/sampling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ Changing the error sample rate requires re-deployment. In addition, setting an S

## Sampling Transaction Events

<Alert>

This section describes transaction mode (the default). In stream mode, `tracesSampleRate` works the same way, but a custom `tracesSampler` receives a different sampling context — read the span's `name` and `attributes` from `samplingContext.spanContext`. See <PlatformLink to="/tracing/new-spans/#sampling-optional">New Spans</PlatformLink>.

</Alert>

We recommend sampling your transactions for two reasons:

1. Capturing a single trace involves minimal overhead, but capturing traces for _every_ page load or _every_ API request may add an undesirable load to your system.
Expand Down Expand Up @@ -68,6 +74,12 @@ When using custom instrumentation to create a transaction, you can add data to t

<PlatformContent includePath="performance/custom-sampling-context" />

<Alert>

This applies to transaction mode. In stream mode there's no custom sampling context — pass data as span attributes when you start the span, then read them from `samplingContext.spanContext.attributes` in your `tracesSampler`. See <PlatformLink to="/tracing/new-spans/#sampling-optional">New Spans</PlatformLink>.

</Alert>

## Inheritance

Whatever a transaction's sampling decision, that decision will be passed to its child spans and from there to any transactions they subsequently cause in other services.
Expand All @@ -90,6 +102,12 @@ If you know at transaction creation time whether or not you want the transaction

<PlatformContent includePath="performance/force-sampling-decision" />

<Alert>

This applies to transaction mode. In stream mode you can't force a decision at span creation — control sampling with a `tracesSampler` that reads the span's `name` and `attributes`.

</Alert>

## Precedence

There are multiple ways for a transaction to end up with a sampling decision.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ SDKs provide a <PlatformIdentifier name="before-send" /> hook, which is invoked

<PlatformContent includePath="configuration/before-send/" />

In stream mode, transactions are replaced by streamed spans. Use `beforeSendSpan` to scrub span attributes before they're sent. See <PlatformLink to="/tracing/new-spans/#filter-spans">New Spans</PlatformLink>.

Sensitive data may appear in the following areas:

- Stack-locals → Some SDKs (Python, PHP and Node) will pick up variable values within the stack trace. These can be scrubbed, or this behavior can be disabled altogether if necessary.
Expand Down
6 changes: 6 additions & 0 deletions docs/platforms/dart/guides/flutter/profiling/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Flutter Profiling is currently in Alpha and available only for **iOS** and **mac

</Alert>

<Alert level="warning">

Profiling isn't available in stream mode. It works only with the default transaction mode (`SentryTraceLifecycle.static`).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to you to also add this to the main page (New Spans) and display it only for Flutter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think we should remove this. the profiling we have in Flutter is only Alpha and might be removed soon

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, then I'll remove this warning


</Alert>

## Enable Tracing

Profiling depends on Sentry’s Tracing product being enabled beforehand. To enable tracing in the SDK:
Expand Down
Loading