Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ The callback function receives two arguments:
- `url`: The full URL of the incoming request, including the protocol, host, port, path and query string. For example: `https://example.com/users?name=John`.
- `request`: An object of type `RequestOptions` containing the incoming request's options. You can use this to filter on properties like the request method or headers.

### `tracePropagation`

_Type: `boolean`_ (Defaults to `true`)

Whether to inject trace propagation headers (`sentry-trace`, `baggage`, `traceparent`) into outgoing HTTP requests. When set to `false`, Sentry will not inject any trace propagation headers but will still create breadcrumbs (if `breadcrumbs` is enabled). This is useful when `skipOpenTelemetrySetup: true` is configured and your external OpenTelemetry setup already handles trace propagation, to avoid duplicate headers.

### `ignoreOutgoingRequests`

_Type: `(url: string, request: RequestOptions) => boolean`_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ _Type: `boolean`_

If set to false, no breadcrumbs will be captured.

### `tracePropagation`

_Type: `boolean`_ (Defaults to `true`)

Whether to inject trace propagation headers (`sentry-trace`, `baggage`, `traceparent`) into outgoing fetch requests. When set to `false`, Sentry will not inject any trace propagation headers but will still create breadcrumbs (if `breadcrumbs` is enabled). This is useful when `skipOpenTelemetrySetup: true` is configured and your external OpenTelemetry setup already handles trace propagation, to avoid duplicate headers.

### `ignoreOutgoingRequests`

_Type: `(url: string) => boolean`_
Expand Down
14 changes: 12 additions & 2 deletions docs/platforms/javascript/common/opentelemetry/custom-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ If you want to add your own http/node-fetch instrumentation, you have to follow

<AvailableSince version="8.35.0" />

You can add your own `@opentelemetry/instrumentation-http` instance in your OpenTelemetry setup. However, in this case, you need to disable span creation in Sentry's `httpIntegration`:
You can add your own `@opentelemetry/instrumentation-http` instance in your OpenTelemetry setup. However, in this case, you need to disable span creation in Sentry's `httpIntegration`. You can also set `tracePropagation: false` to prevent Sentry from injecting trace headers, letting your OpenTelemetry setup handle propagation instead:

<PlatformSection notSupported={["javascript.bun"]}>
```javascript
const sentryClient = Sentry.init({
dsn: "___DSN___",
skipOpenTelemetrySetup: true,
integrations: [Sentry.httpIntegration({ spans: false })],
integrations: [Sentry.httpIntegration({ spans: false, tracePropagation: false })],
});
```
</PlatformSection>
Expand All @@ -134,6 +134,16 @@ It's important that `httpIntegration` is still registered this way to ensure tha

If tracing is disabled, the Node Fetch instrumentation will not emit any spans. In this scenario, it will only inject sentry-specific trace propagation headers. You are free to add your own Node Fetch instrumentation on top of this which may emit spans as you like.

If your OpenTelemetry setup already handles trace propagation for fetch requests, you can set `tracePropagation: false` to prevent Sentry from injecting duplicate trace headers:

```javascript
const sentryClient = Sentry.init({
dsn: "___DSN___",
skipOpenTelemetrySetup: true,
integrations: [Sentry.nativeNodeFetchIntegration({ tracePropagation: false })],
});
```

## Using a Custom Sampler

While you can use your own sampler, we recommend that you use the `SentrySampler`. This will ensure that the correct subset of traces will be sent to Sentry, based on your `tracesSampleRate`. It will also ensure that all other Sentry features like trace propagation work as expected. If you do need to use your own sampler, make sure to wrap your `SamplingResult` with our `wrapSamplingDecision` method like in the example below:
Expand Down
Loading