getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.92k stars 1.56k forks source link

Missing a way to filter Http requests #2901

Closed gajus closed 4 years ago

gajus commented 4 years ago

Package + Version

Version:

5.23.0

Description

https://docs.sentry.io/platforms/node/integrations/default-integrations/#http does not provide a way to filter requests.

Our Http breadcrumbs are pretty much useless because they are flooded with calls to internal liveness checks, DataDog, and similar services.

There needs to be a parameter that gives control over which requests are included in tracing/ logging.

kamilogorek commented 4 years ago

https://docs.sentry.io/platforms/node/enriching-error-data/breadcrumbs/#customize-breadcrumbs

Sentry.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
  beforeBreadcrumb(breadcrumb, hint) {
    if (breadcrumb.category === 'http' && breadcrumb.data.url.startsWith('http://filterme.com')) {
      return null;
    }
    return breadcrumb;
  },
});

You can see data passed as hint (data used to assemble original breadcrumb) here: https://github.com/getsentry/sentry-javascript/blob/aca5a697ee1f922d96934caed33c4e3fc9bd9b34/packages/node/src/integrations/http.ts#L132-L156