---
title: "FetchIntegration"
description: "A default integration that creates spans and attaches tracing headers to fetch requests in Cloudflare Workers."
url: https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/integrations/fetchIntegration/
---

# FetchIntegration | Sentry for Cloudflare

This integration only works inside the Cloudflare Workers runtime.

*Import name: `Sentry.fetchIntegration`*

This integration is enabled by default. If you want to disable it, you can [modify your default integrations](https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/integrations.md#modifying-default-integrations).

The `fetchIntegration` creates [spans](https://docs.sentry.io/concepts/key-terms/tracing/distributed-tracing.md#traces-transactions-and-spans) and attaches tracing headers to fetch requests in Cloudflare Workers.

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

## [Options](https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/integrations/fetchIntegration.md#options)

### [`breadcrumbs`](https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/integrations/fetchIntegration.md#breadcrumbs)

*Type: `boolean`*

If set to false, no breadcrumbs will be captured.

### [`shouldCreateSpanForRequest`](https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/integrations/fetchIntegration.md#shouldcreatespanforrequest)

*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.

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

## [Usage](https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/integrations/fetchIntegration.md#usage)

The fetch integration automatically instruments all `fetch()` calls made within your Cloudflare Worker. 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.
