Skip to content

Commit 98d3916

Browse files
authored
feat(types): Add tracePropagationTargets to top level options (#8395)
1 parent c77555e commit 98d3916

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

packages/node/src/integrations/http.ts

+8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ interface TracingOptions {
2020
* requests. If this option is provided, the SDK will match the
2121
* request URL of outgoing requests against the items in this
2222
* array, and only attach tracing headers if a match was found.
23+
*
24+
* @deprecated Use top level `tracePropagationTargets` option instead.
25+
* ```
26+
* Sentry.init({
27+
* tracePropagationTargets: ['api.site.com'],
28+
* })
2329
*/
2430
tracePropagationTargets?: TracePropagationTargets;
2531

@@ -156,6 +162,7 @@ function _createWrappedRequestMethodFactory(
156162
};
157163

158164
const shouldAttachTraceData = (url: string): boolean => {
165+
// eslint-disable-next-line deprecation/deprecation
159166
if (tracingOptions?.tracePropagationTargets === undefined) {
160167
return true;
161168
}
@@ -165,6 +172,7 @@ function _createWrappedRequestMethodFactory(
165172
return cachedDecision;
166173
}
167174

175+
// eslint-disable-next-line deprecation/deprecation
168176
const decision = stringMatchesSomePattern(url, tracingOptions.tracePropagationTargets);
169177
headersUrlMap.set(url, decision);
170178
return decision;

packages/node/src/types.ts

+1-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ClientOptions, Options, SamplingContext, TracePropagationTargets } from '@sentry/types';
1+
import type { ClientOptions, Options, SamplingContext } from '@sentry/types';
22

33
import type { NodeTransportOptions } from './transports';
44

@@ -32,24 +32,6 @@ export interface BaseNodeOptions {
3232
*/
3333
includeLocalVariables?: boolean;
3434

35-
/**
36-
* List of strings/regex controlling to which outgoing requests
37-
* the SDK will attach tracing headers.
38-
*
39-
* By default the SDK will attach those headers to all outgoing
40-
* requests. If this option is provided, the SDK will match the
41-
* request URL of outgoing requests against the items in this
42-
* array, and only attach tracing headers if a match was found.
43-
*
44-
* @example
45-
* ```js
46-
* Sentry.init({
47-
* tracePropagationTargets: ['api.site.com'],
48-
* });
49-
* ```
50-
*/
51-
tracePropagationTargets?: TracePropagationTargets;
52-
5335
// TODO (v8): Remove this in v8
5436
/**
5537
* @deprecated Moved to constructor options of the `Http` and `Undici` integration.

packages/types/src/options.ts

+19
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { Integration } from './integration';
55
import type { CaptureContext } from './scope';
66
import type { SdkMetadata } from './sdkmetadata';
77
import type { StackLineParser, StackParser } from './stacktrace';
8+
import type { TracePropagationTargets } from './tracing';
89
import type { SamplingContext } from './transaction';
910
import type { BaseTransportOptions, Transport } from './transport';
1011

@@ -221,6 +222,24 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
221222
*/
222223
denyUrls?: Array<string | RegExp>;
223224

225+
/**
226+
* List of strings/regex controlling to which outgoing requests
227+
* the SDK will attach tracing headers.
228+
*
229+
* By default the SDK will attach those headers to all outgoing
230+
* requests. If this option is provided, the SDK will match the
231+
* request URL of outgoing requests against the items in this
232+
* array, and only attach tracing headers if a match was found.
233+
*
234+
* @example
235+
* ```js
236+
* Sentry.init({
237+
* tracePropagationTargets: ['api.site.com'],
238+
* });
239+
* ```
240+
*/
241+
tracePropagationTargets?: TracePropagationTargets;
242+
224243
/**
225244
* Function to compute tracing sample rate dynamically and filter unwanted traces.
226245
*

0 commit comments

Comments
 (0)