Skip to content

Add ignoreSpans option #16820

Open
Open
@mydea

Description

@mydea

Description

We have the recurring request to be able to ignore certain spans. We removed the option to use beforeSendSpan to allow dropping spans, because it can break metric extrapolation when using non-deterministic code to drop spans.

The replacement for this has been to configure specific integrations to drop spans. While this works, it has a few problems:

  1. It can be hard to know where/how to configure integrations. Option names can differ, and you may have to configure a whole bunch of integrations to make this work as you want.
  2. Some integrations do not have options to drop stuff. While we can add things in general, esp. with OpenTelemetry it can be hard because we require upstream changes.

In order to help alleviate this, we should add a ignoreSpans option that can be used to filter spans at creation time:

type IgnoreSpansFilter = 
{
  name: string | RegExp,
  op: string | RegExp,
} | 
{
  name: string | RegExp
} | 
{
  op: string | RegExp
}

interface Options {
  // ...
  ignoreSpans: (string | RegExp | IgnoreSpansFilter)[]
}

This will match against the span name at creation time, and make the span non-recording if it matches.

Important notes:

  • On browser, this should work reasonably well, as we emit all the spans and they usually have the correct span name at span creation time. Important exception: pageload spans often get updated, they may not have the correct span name at creation time.
  • On node, we need to infer the name at creation time, which is a bit more expensive, resource wise. This is an opt-in option though, we just need to make it clear there may be a performance overhead with this. Also, in node span names can often be updated later, this also needs to be documented well.
  • We need to document well that ignoring a span like this will also drop child spans of this span. So this should ideally mostly be used for leaf nodes.

This function will be run in the place where we also run beforeSendSpan, so after processing. If possible, we will re-stitch parent-child relationships of spans that are dropped there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions