Skip to content

Commit

Permalink
feat(core): Add beforeSendSpan documentation for javascript (#10055)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiborza authored May 17, 2024
1 parent 6b98048 commit 1214193
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/platforms/javascript/common/configuration/filtering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,9 @@ Learn more about <PlatformLink to="/configuration/sampling/">configuring the sam
### Using <PlatformIdentifier name="before-send-transaction" />

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

## Filtering Spans

To prevent certain spans from being reported to Sentry, use the <PlatformIdentifier name="before-send-span" /> configuration option, which allows you to provide a function to evaluate the current span and drop it if it's not one you want.

<PlatformContent includePath="configuration/before-send-span" />
6 changes: 6 additions & 0 deletions docs/platforms/javascript/common/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ The callback typically gets a second argument (called a "hint") which contains t

</ConfigKey>

<ConfigKey name="before-send-span">

This function is called with an SDK-specific span object, and can return a modified span object, or `null` to skip reporting the span. One way this might be used is for manual PII stripping before sending.

</ConfigKey>


## Transport Options

Expand Down
17 changes: 17 additions & 0 deletions platform-includes/configuration/before-send-span/javascript.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<SignInNote />

```javascript
Sentry.init({
dsn: "___PUBLIC_DSN___",

// Called for spans
beforeSendSpan(span) {
// Modify or drop the span here
if (span.description === 'unimportant span') {
// Don't send the span to Sentry
return null;
}
return span;
},
});
```

0 comments on commit 1214193

Please sign in to comment.