FetchIntegration for Bun

A default integration that creates spans and attaches tracing headers to fetch requests.

Import name: Sentry.fetchIntegration

This integration is enabled by default. If you want to disable it, you can modify your default integrations.

The fetchIntegration creates spans and attaches tracing headers to outgoing fetch() requests.

Sentry.init({
  integrations: [Sentry.fetchIntegration()],
});

Type: boolean

If set to false, no breadcrumbs will be captured.

Type: (url: string) => boolean

Allows you to define a method to determine whether or not to create spans to track outgoing requests to the given URL. By default, spans will be created for all outgoing requests.

Sentry.init({
  integrations: [
    Sentry.fetchIntegration({
      shouldCreateSpanForRequest: (url) => {
        // Only create spans for external API calls
        return url.includes('api.example.com');
      },
    }),
  ],
});

The fetch integration automatically instruments all outgoing fetch() calls. This includes:

  • Creating performance spans for outgoing HTTP requests
  • Adding tracing headers to continue distributed traces
  • Capturing breadcrumbs for debugging purposes
  • Tracking request duration and response status

The integration works with both the standard fetch() API and any libraries that use fetch under the hood.

Note: If you need to disable fetch instrumentation for specific requests, use the shouldCreateSpanForRequest option to filter out unwanted requests.

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").