Skip to content

Commit 16eee80

Browse files
committed
s/registerRequestInstrumentation/instrumentOutgoingRequests
1 parent 1486ed2 commit 16eee80

File tree

5 files changed

+11
-16
lines changed

5 files changed

+11
-16
lines changed

packages/tracing/src/browser/browsertracing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { registerBackgroundTabDetection } from './backgroundtab';
1010
import { MetricsInstrumentation } from './metrics';
1111
import {
1212
defaultRequestInstrumentationOptions,
13-
registerRequestInstrumentation,
13+
instrumentOutgoingRequests,
1414
RequestInstrumentationOptions,
1515
} from './request';
1616
import { defaultRoutingInstrumentation } from './router';
@@ -178,7 +178,7 @@ export class BrowserTracing implements Integration {
178178
registerBackgroundTabDetection();
179179
}
180180

181-
registerRequestInstrumentation({ traceFetch, traceXHR, tracingOrigins, shouldCreateSpanForRequest });
181+
instrumentOutgoingRequests({ traceFetch, traceXHR, tracingOrigins, shouldCreateSpanForRequest });
182182
}
183183

184184
/** Create routing idle transaction. */

packages/tracing/src/browser/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export { BrowserTracing } from './browsertracing';
22
export {
3-
registerRequestInstrumentation,
3+
instrumentOutgoingRequests,
44
RequestInstrumentationOptions,
55
defaultRequestInstrumentationOptions,
66
} from './request';

packages/tracing/src/browser/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const defaultRequestInstrumentationOptions: RequestInstrumentationOptions
8383
};
8484

8585
/** Registers span creators for xhr and fetch requests */
86-
export function registerRequestInstrumentation(_options?: Partial<RequestInstrumentationOptions>): void {
86+
export function instrumentOutgoingRequests(_options?: Partial<RequestInstrumentationOptions>): void {
8787
// eslint-disable-next-line @typescript-eslint/unbound-method
8888
const { traceFetch, traceXHR, tracingOrigins, shouldCreateSpanForRequest } = {
8989
...defaultRequestInstrumentationOptions,

packages/tracing/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export { Integrations };
88
export { Span } from './span';
99
export { Transaction } from './transaction';
1010
export {
11-
registerRequestInstrumentation,
11+
// TODO deprecate old name in v7
12+
instrumentOutgoingRequests as registerRequestInstrumentation,
1213
RequestInstrumentationOptions,
1314
defaultRequestInstrumentationOptions,
1415
} from './browser';

packages/tracing/test/browser/request.test.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ import { Hub, makeMain } from '@sentry/hub';
33
import * as utils from '@sentry/utils';
44

55
import { Span, SpanStatus, Transaction } from '../../src';
6-
import {
7-
fetchCallback,
8-
FetchData,
9-
registerRequestInstrumentation,
10-
xhrCallback,
11-
XHRData,
12-
} from '../../src/browser/request';
6+
import { fetchCallback, FetchData, instrumentOutgoingRequests, xhrCallback, XHRData } from '../../src/browser/request';
137
import { addExtensionMethods } from '../../src/hubextensions';
148
import * as tracingUtils from '../../src/utils';
159

@@ -24,13 +18,13 @@ const hasTracingEnabled = jest.spyOn(tracingUtils, 'hasTracingEnabled');
2418
const addInstrumentationHandler = jest.spyOn(utils, 'addInstrumentationHandler');
2519
const setRequestHeader = jest.fn();
2620

27-
describe('registerRequestInstrumentation', () => {
21+
describe('instrumentOutgoingRequests', () => {
2822
beforeEach(() => {
2923
jest.clearAllMocks();
3024
});
3125

3226
it('instruments fetch and xhr requests', () => {
33-
registerRequestInstrumentation();
27+
instrumentOutgoingRequests();
3428

3529
expect(addInstrumentationHandler).toHaveBeenCalledWith({
3630
callback: expect.any(Function),
@@ -43,13 +37,13 @@ describe('registerRequestInstrumentation', () => {
4337
});
4438

4539
it('does not instrument fetch requests if traceFetch is false', () => {
46-
registerRequestInstrumentation({ traceFetch: false });
40+
instrumentOutgoingRequests({ traceFetch: false });
4741

4842
expect(addInstrumentationHandler).not.toHaveBeenCalledWith({ callback: expect.any(Function), type: 'fetch' });
4943
});
5044

5145
it('does not instrument xhr requests if traceXHR is false', () => {
52-
registerRequestInstrumentation({ traceXHR: false });
46+
instrumentOutgoingRequests({ traceXHR: false });
5347

5448
expect(addInstrumentationHandler).not.toHaveBeenCalledWith({ callback: expect.any(Function), type: 'xhr' });
5549
});

0 commit comments

Comments
 (0)