Skip to content

Commit

Permalink
feat(types): Add tracePropagationTargets to top level options (#8395)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Jun 23, 2023
1 parent c77555e commit 98d3916
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
8 changes: 8 additions & 0 deletions packages/node/src/integrations/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ interface TracingOptions {
* requests. If this option is provided, the SDK will match the
* request URL of outgoing requests against the items in this
* array, and only attach tracing headers if a match was found.
*
* @deprecated Use top level `tracePropagationTargets` option instead.
* ```
* Sentry.init({
* tracePropagationTargets: ['api.site.com'],
* })
*/
tracePropagationTargets?: TracePropagationTargets;

Expand Down Expand Up @@ -156,6 +162,7 @@ function _createWrappedRequestMethodFactory(
};

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

// eslint-disable-next-line deprecation/deprecation
const decision = stringMatchesSomePattern(url, tracingOptions.tracePropagationTargets);
headersUrlMap.set(url, decision);
return decision;
Expand Down
20 changes: 1 addition & 19 deletions packages/node/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ClientOptions, Options, SamplingContext, TracePropagationTargets } from '@sentry/types';
import type { ClientOptions, Options, SamplingContext } from '@sentry/types';

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

Expand Down Expand Up @@ -32,24 +32,6 @@ export interface BaseNodeOptions {
*/
includeLocalVariables?: boolean;

/**
* List of strings/regex controlling to which outgoing requests
* the SDK will attach tracing headers.
*
* By default the SDK will attach those headers to all outgoing
* requests. If this option is provided, the SDK will match the
* request URL of outgoing requests against the items in this
* array, and only attach tracing headers if a match was found.
*
* @example
* ```js
* Sentry.init({
* tracePropagationTargets: ['api.site.com'],
* });
* ```
*/
tracePropagationTargets?: TracePropagationTargets;

// TODO (v8): Remove this in v8
/**
* @deprecated Moved to constructor options of the `Http` and `Undici` integration.
Expand Down
19 changes: 19 additions & 0 deletions packages/types/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Integration } from './integration';
import type { CaptureContext } from './scope';
import type { SdkMetadata } from './sdkmetadata';
import type { StackLineParser, StackParser } from './stacktrace';
import type { TracePropagationTargets } from './tracing';
import type { SamplingContext } from './transaction';
import type { BaseTransportOptions, Transport } from './transport';

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

/**
* List of strings/regex controlling to which outgoing requests
* the SDK will attach tracing headers.
*
* By default the SDK will attach those headers to all outgoing
* requests. If this option is provided, the SDK will match the
* request URL of outgoing requests against the items in this
* array, and only attach tracing headers if a match was found.
*
* @example
* ```js
* Sentry.init({
* tracePropagationTargets: ['api.site.com'],
* });
* ```
*/
tracePropagationTargets?: TracePropagationTargets;

/**
* Function to compute tracing sample rate dynamically and filter unwanted traces.
*
Expand Down

0 comments on commit 98d3916

Please sign in to comment.