Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃挕 Discard errors coming from specific source files #2488

Open
vinnymac opened this issue Oct 31, 2023 · 3 comments
Open

馃挕 Discard errors coming from specific source files #2488

vinnymac opened this issue Oct 31, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@vinnymac
Copy link

vinnymac commented Oct 31, 2023

Is your feature request related to a problem? Please describe.

Currently my application configures RUM to discard a subset of errors by message and resource url. Pseudo code is something like the following.

import { datadogRum } from '@datadog/browser-rum';

datadogRum.init({
    beforeSend: (event, context) => {
        // discard a RUM error based on message
        if (event.type === 'error' && event.error.message.includes('patterns')) {
            return false
        }
        
       // discard a RUM error based on resource url
        if (event.type === 'error' && event.error.resource?.url.test(/pattern/)) {
          return false;
        }
    },
});

Unfortunately not every error has a resource url. Inspecting the events and context for errors that are sent in beforeSend, and while studying the source code in this repository, I did not find any mechanism to determine the source of the error. Additionally the original error isn't available so I can attempt to parse out the source. This means I receive much more in-actionable noise in RUM than desired from third party scripts.

Describe the solution you'd like

The Datadog RUM application error interface does show the source of an error when available, yet I don't see that same information in beforeSend so I can make a decision on whether or not to discard an error. Can we add a feature for filtering errors by URL? Or can we add these sources to the event objects so that developers can decide whether or not they want to keep errors for particular third parties?

Pseudo code for a solution might look something like

import { datadogRum } from '@datadog/browser-rum';

datadogRum.init({
    // URL patterns for errors that should not be sent to RUM
    denyUrls: [/pattern/],
    // URL patterns for errors that should be sent to RUM
    allowUrls: [/pattern/],
});


// Alternatively expose source on the error event
datadogRum.init({
    beforeSend: (event, context) => {
        // discard a RUM error based on source
        if (event.type === 'error' && event.error.source.test(/pattern/)) {
            return false
        }
    },
});

Describe alternatives you've considered

I've inspected the arguments of beforeSend, and haven't seen an alternative for determining the initiator for a particular error. Perhaps for a subset of errors it may be possible to parse this out of the stack trace, when available.

I read through these docs and did not see a way to configure this functionality.

Thanks

SDK Version
CDN Sync with v5

Related issues
#1616
#362

@vinnymac vinnymac added the enhancement New feature or request label Oct 31, 2023
@bcaudan
Copy link
Contributor

bcaudan commented Nov 2, 2023

Hi @vinnymac,

my application configures RUM to discard a subset of errors by message and resource url

The RUM SDK do not collect failed network calls as error events since the v3 (cf upgrade entry), so RUM error events do not have event.error.resource field anymore.

I did not find any mechanism to determine the source of the error.

We have an error.source property on RUM errors that allow to identify error coming from the source code, a browser report or an addError API call.

The Datadog RUM application error interface does show the source of an error when available [...] Can we add a feature for filtering errors by URL?

I am guessing that what you'd want is the error.file attribute, identifying from which application source file the error is coming.
is that it?

@vinnymac
Copy link
Author

vinnymac commented Nov 2, 2023

Hi @bcaudan,

Thanks for the quick reply, must be a carry over from our old v3 implementation before we migrated to v4. We upgraded to v5 in the last week, so we have been taking a closer look at how to fine tune the configuration on our site.

We have an error.source property on RUM errors that allow to identify error coming from the source code, a browser report or an addError API call.

I see source in the datadog RUM error tracking dashboard with a value of browser for third party scripts. That seems like the error.source_type property and not the error.source property. I wonder if error.source === 'network' might help with keeping the noise down?

I am guessing that what you'd want is the error.file attribute, identifying from which application source file the error is coming.

This sounds like it would solve the problem 馃憤馃徏

@bcaudan
Copy link
Contributor

bcaudan commented Nov 6, 2023

I see source in the datadog RUM error tracking dashboard with a value of browser for third party scripts.

the source property is used to differentiate between data coming from browser, android, iOS...

I wonder if error.source === 'network' might help with keeping the noise down?

Since v3, browser RUM SDK don't collect error.source === 'network', so it should not help.

I am guessing that what you'd want is the error.file attribute, identifying from which application source file the error is coming.

This sounds like it would solve the problem 馃憤馃徏

Unfortunately, for now, the SDK don't have access to the unminified file where the error happened (error.file) and the datadog app don't have filtering capabilities for RUM events.
However, If the errors you want to discard comes from specific files, you could look for them inside the minified stacktrace error.stack.

@bcaudan bcaudan changed the title 馃挕 Discard errors before send by URL 馃挕 Discard errors coming from specific files Nov 6, 2023
@bcaudan bcaudan removed the need-info label Nov 6, 2023
@bcaudan bcaudan changed the title 馃挕 Discard errors coming from specific files 馃挕 Discard errors coming from specific source files Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants