Skip to content

Commit 361a88f

Browse files
committed
feat(v8/core): Remove span.instrumenter and instrumenter option
1 parent 27273f6 commit 361a88f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+40
-384
lines changed

packages/bun/test/helpers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export function getDefaultBunClientOptions(options: Partial<BunClientOptions> =
88
integrations: [],
99
transport: () => createTransport({ recordDroppedEvent: () => undefined }, _ => resolvedSyncPromise({})),
1010
stackParser: () => [],
11-
instrumenter: 'sentry',
1211
...options,
1312
};
1413
}

packages/core/src/tracing/hubextensions.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import type { ClientOptions, CustomSamplingContext, Hub, TransactionContext } from '@sentry/types';
2-
import { logger } from '@sentry/utils';
32
import { getMainCarrier } from '../asyncContext';
43

5-
import { DEBUG_BUILD } from '../debug-build';
64
import { spanToTraceHeader } from '../utils/spanUtils';
75
import { registerErrorInstrumentation } from './errors';
86
import { IdleTransaction } from './idletransaction';
@@ -47,20 +45,6 @@ function _startTransaction(
4745
const client = this.getClient();
4846
const options: Partial<ClientOptions> = (client && client.getOptions()) || {};
4947

50-
const configInstrumenter = options.instrumenter || 'sentry';
51-
const transactionInstrumenter = transactionContext.instrumenter || 'sentry';
52-
53-
if (configInstrumenter !== transactionInstrumenter) {
54-
DEBUG_BUILD &&
55-
logger.error(
56-
`A transaction was started with instrumenter=\`${transactionInstrumenter}\`, but the SDK is configured with the \`${configInstrumenter}\` instrumenter.
57-
The transaction will not be sampled. Please use the ${configInstrumenter} instrumentation to start transactions.`,
58-
);
59-
60-
// eslint-disable-next-line deprecation/deprecation
61-
transactionContext.sampled = false;
62-
}
63-
6448
// eslint-disable-next-line deprecation/deprecation
6549
let transaction = new Transaction(transactionContext, this);
6650
transaction = sampleTransaction(transaction, options, {

packages/core/src/tracing/sentrySpan.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint-disable max-lines */
22
import type {
3-
Instrumenter,
43
Primitive,
54
Span as SpanInterface,
65
SpanAttributeValue,
@@ -92,18 +91,6 @@ export class SentrySpan implements SpanInterface {
9291
* @deprecated Use top level `Sentry.getRootSpan()` instead
9392
*/
9493
public transaction?: Transaction;
95-
96-
/**
97-
* The instrumenter that created this span.
98-
*
99-
* TODO (v8): This can probably be replaced by an `instanceOf` check of the span class.
100-
* the instrumenter can only be sentry or otel so we can check the span instance
101-
* to verify which one it is and remove this field entirely.
102-
*
103-
* @deprecated This field will be removed.
104-
*/
105-
public instrumenter: Instrumenter;
106-
10794
protected _traceId: string;
10895
protected _spanId: string;
10996
protected _parentSpanId?: string | undefined;
@@ -134,8 +121,6 @@ export class SentrySpan implements SpanInterface {
134121
this.tags = spanContext.tags ? { ...spanContext.tags } : {};
135122
// eslint-disable-next-line deprecation/deprecation
136123
this.data = spanContext.data ? { ...spanContext.data } : {};
137-
// eslint-disable-next-line deprecation/deprecation
138-
this.instrumenter = spanContext.instrumenter || 'sentry';
139124

140125
this._attributes = {};
141126
this.setAttributes({

packages/core/test/lib/serverruntimeclient.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ function getDefaultClientOptions(options: Partial<ServerRuntimeClientOptions> =
1111
integrations: [],
1212
transport: () => createTransport({ recordDroppedEvent: () => undefined }, _ => Promise.resolve({})),
1313
stackParser: () => [],
14-
instrumenter: 'sentry',
1514
...options,
1615
};
1716
}

packages/nextjs/src/common/wrapAppGetInitialPropsWithSentry.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ export function wrapAppGetInitialPropsWithSentry(origAppGetInitialProps: AppGetI
3535
const { req, res } = context.ctx;
3636

3737
const errorWrappedAppGetInitialProps = withErrorInstrumentation(wrappingTarget);
38-
const options = getClient()?.getOptions();
39-
4038
// Generally we can assume that `req` and `res` are always defined on the server:
4139
// https://nextjs.org/docs/api-reference/data-fetching/get-initial-props#context-object
4240
// This does not seem to be the case in dev mode. Because we have no clean way of associating the the data fetcher
4341
// span with each other when there are no req or res objects, we simply do not trace them at all here.
44-
if (req && res && options?.instrumenter === 'sentry') {
42+
if (req && res) {
4543
const tracedGetInitialProps = withTracedServerSideDataFetcher(errorWrappedAppGetInitialProps, req, res, {
4644
dataFetcherRouteName: '/_app',
4745
requestedRouteName: context.ctx.pathname,

packages/nextjs/src/common/wrapDocumentGetInitialPropsWithSentry.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { addTracingExtensions, getClient } from '@sentry/core';
1+
import { addTracingExtensions } from '@sentry/core';
22
import type Document from 'next/document';
33

44
import { isBuild } from './utils/isBuild';
@@ -29,13 +29,11 @@ export function wrapDocumentGetInitialPropsWithSentry(
2929
const { req, res } = context;
3030

3131
const errorWrappedGetInitialProps = withErrorInstrumentation(wrappingTarget);
32-
const options = getClient()?.getOptions();
33-
3432
// Generally we can assume that `req` and `res` are always defined on the server:
3533
// https://nextjs.org/docs/api-reference/data-fetching/get-initial-props#context-object
3634
// This does not seem to be the case in dev mode. Because we have no clean way of associating the the data fetcher
3735
// span with each other when there are no req or res objects, we simply do not trace them at all here.
38-
if (req && res && options?.instrumenter === 'sentry') {
36+
if (req && res) {
3937
const tracedGetInitialProps = withTracedServerSideDataFetcher(errorWrappedGetInitialProps, req, res, {
4038
dataFetcherRouteName: '/_document',
4139
requestedRouteName: context.pathname,

packages/nextjs/src/common/wrapErrorGetInitialPropsWithSentry.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
addTracingExtensions,
33
getActiveSpan,
4-
getClient,
54
getDynamicSamplingContextFromSpan,
65
getRootSpan,
76
spanToTraceHeader,
@@ -38,13 +37,11 @@ export function wrapErrorGetInitialPropsWithSentry(
3837
const { req, res } = context;
3938

4039
const errorWrappedGetInitialProps = withErrorInstrumentation(wrappingTarget);
41-
const options = getClient()?.getOptions();
42-
4340
// Generally we can assume that `req` and `res` are always defined on the server:
4441
// https://nextjs.org/docs/api-reference/data-fetching/get-initial-props#context-object
4542
// This does not seem to be the case in dev mode. Because we have no clean way of associating the the data fetcher
4643
// span with each other when there are no req or res objects, we simply do not trace them at all here.
47-
if (req && res && options?.instrumenter === 'sentry') {
44+
if (req && res) {
4845
const tracedGetInitialProps = withTracedServerSideDataFetcher(errorWrappedGetInitialProps, req, res, {
4946
dataFetcherRouteName: '/_error',
5047
requestedRouteName: context.pathname,

packages/nextjs/src/common/wrapGetInitialPropsWithSentry.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
addTracingExtensions,
33
getActiveSpan,
4-
getClient,
54
getDynamicSamplingContextFromSpan,
65
getRootSpan,
76
spanToTraceHeader,
@@ -34,13 +33,11 @@ export function wrapGetInitialPropsWithSentry(origGetInitialProps: GetInitialPro
3433
const { req, res } = context;
3534

3635
const errorWrappedGetInitialProps = withErrorInstrumentation(wrappingTarget);
37-
const options = getClient()?.getOptions();
38-
3936
// Generally we can assume that `req` and `res` are always defined on the server:
4037
// https://nextjs.org/docs/api-reference/data-fetching/get-initial-props#context-object
4138
// This does not seem to be the case in dev mode. Because we have no clean way of associating the the data fetcher
4239
// span with each other when there are no req or res objects, we simply do not trace them at all here.
43-
if (req && res && options?.instrumenter === 'sentry') {
40+
if (req && res) {
4441
const tracedGetInitialProps = withTracedServerSideDataFetcher(errorWrappedGetInitialProps, req, res, {
4542
dataFetcherRouteName: context.pathname,
4643
requestedRouteName: context.pathname,
Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
addTracingExtensions,
33
getActiveSpan,
4-
getClient,
54
getDynamicSamplingContextFromSpan,
65
getRootSpan,
76
spanToTraceHeader,
@@ -35,34 +34,28 @@ export function wrapGetServerSidePropsWithSentry(
3534
const { req, res } = context;
3635

3736
const errorWrappedGetServerSideProps = withErrorInstrumentation(wrappingTarget);
38-
const options = getClient()?.getOptions();
39-
40-
if (options?.instrumenter === 'sentry') {
41-
const tracedGetServerSideProps = withTracedServerSideDataFetcher(errorWrappedGetServerSideProps, req, res, {
42-
dataFetcherRouteName: parameterizedRoute,
43-
requestedRouteName: parameterizedRoute,
44-
dataFetchingMethodName: 'getServerSideProps',
45-
});
46-
47-
const serverSideProps = await (tracedGetServerSideProps.apply(thisArg, args) as ReturnType<
48-
typeof tracedGetServerSideProps
49-
>);
50-
51-
if (serverSideProps && 'props' in serverSideProps) {
52-
const activeSpan = getActiveSpan();
53-
const requestTransaction = getSpanFromRequest(req) ?? (activeSpan ? getRootSpan(activeSpan) : undefined);
54-
if (requestTransaction) {
55-
serverSideProps.props._sentryTraceData = spanToTraceHeader(requestTransaction);
56-
57-
const dynamicSamplingContext = getDynamicSamplingContextFromSpan(requestTransaction);
58-
serverSideProps.props._sentryBaggage = dynamicSamplingContextToSentryBaggageHeader(dynamicSamplingContext);
59-
}
37+
const tracedGetServerSideProps = withTracedServerSideDataFetcher(errorWrappedGetServerSideProps, req, res, {
38+
dataFetcherRouteName: parameterizedRoute,
39+
requestedRouteName: parameterizedRoute,
40+
dataFetchingMethodName: 'getServerSideProps',
41+
});
42+
43+
const serverSideProps = await (tracedGetServerSideProps.apply(thisArg, args) as ReturnType<
44+
typeof tracedGetServerSideProps
45+
>);
46+
47+
if (serverSideProps && 'props' in serverSideProps) {
48+
const activeSpan = getActiveSpan();
49+
const requestTransaction = getSpanFromRequest(req) ?? (activeSpan ? getRootSpan(activeSpan) : undefined);
50+
if (requestTransaction) {
51+
serverSideProps.props._sentryTraceData = spanToTraceHeader(requestTransaction);
52+
53+
const dynamicSamplingContext = getDynamicSamplingContextFromSpan(requestTransaction);
54+
serverSideProps.props._sentryBaggage = dynamicSamplingContextToSentryBaggageHeader(dynamicSamplingContext);
6055
}
61-
62-
return serverSideProps;
63-
} else {
64-
return errorWrappedGetServerSideProps.apply(thisArg, args);
6556
}
57+
58+
return serverSideProps;
6659
},
6760
});
6861
}

packages/nextjs/src/common/wrapGetStaticPropsWithSentry.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,10 @@ export function wrapGetStaticPropsWithSentry(
2626
addTracingExtensions();
2727

2828
const errorWrappedGetStaticProps = withErrorInstrumentation(wrappingTarget);
29-
const options = getClient()?.getOptions();
30-
31-
if (options?.instrumenter === 'sentry') {
32-
return callDataFetcherTraced(errorWrappedGetStaticProps, args, {
33-
parameterizedRoute,
34-
dataFetchingMethodName: 'getStaticProps',
35-
});
36-
}
29+
return callDataFetcherTraced(errorWrappedGetStaticProps, args, {
30+
parameterizedRoute,
31+
dataFetchingMethodName: 'getStaticProps',
32+
});
3733

3834
return errorWrappedGetStaticProps.apply(thisArg, args);
3935
},

packages/nextjs/test/config/wrappers.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('data-fetching function wrappers should create spans', () => {
2323
jest.spyOn(SentryCore, 'hasTracingEnabled').mockReturnValue(true);
2424
jest.spyOn(SentryCore, 'getClient').mockImplementation(() => {
2525
return {
26-
getOptions: () => ({ instrumenter: 'sentry' }),
26+
getOptions: () => ({}),
2727
getDsn: () => {},
2828
} as Client;
2929
});

packages/node-experimental/src/sdk/init.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ function getClientOptions(options: NodeOptions): NodeClientOptions {
153153
...baseOptions,
154154
...options,
155155
...overwriteOptions,
156-
instrumenter: 'otel',
157156
stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),
158157
integrations: getIntegrationsToSetup({
159158
defaultIntegrations: options.defaultIntegrations,

packages/node/src/handlers.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ export function tracingHandler(): (
4747
): void {
4848
const options = getClient()?.getOptions();
4949

50-
if (
51-
!options ||
52-
options.instrumenter !== 'sentry' ||
53-
req.method?.toUpperCase() === 'OPTIONS' ||
54-
req.method?.toUpperCase() === 'HEAD'
55-
) {
50+
if (req.method?.toUpperCase() === 'OPTIONS' || req.method?.toUpperCase() === 'HEAD') {
5651
return next();
5752
}
5853

packages/node/src/integrations/http.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,6 @@ export class Http implements Integration {
185185
return;
186186
}
187187

188-
// Do not auto-instrument for other instrumenter
189-
if (clientOptions && clientOptions.instrumenter !== 'sentry') {
190-
DEBUG_BUILD && logger.log('HTTP Integration is skipped because of instrumenter configuration.');
191-
return;
192-
}
193-
194188
const shouldCreateSpanForRequest = _getShouldCreateSpanForRequest(shouldCreateSpans, this._tracing, clientOptions);
195189

196190
// eslint-disable-next-line deprecation/deprecation

packages/node/src/sdk.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ export function init(options: NodeOptions = {}): void {
147147
options.autoSessionTracking = true;
148148
}
149149

150-
if (options.instrumenter === undefined) {
151-
options.instrumenter = 'sentry';
152-
}
153-
154150
// TODO(v7): Refactor this to reduce the logic above
155151
const clientOptions: NodeClientOptions = {
156152
...options,

packages/node/test/helper/node-client-options.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export function getDefaultNodeClientOptions(options: Partial<NodeClientOptions>
88
integrations: [],
99
transport: () => createTransport({ recordDroppedEvent: () => undefined }, _ => resolvedSyncPromise({})),
1010
stackParser: () => [],
11-
instrumenter: 'sentry',
1211
...options,
1312
};
1413
}

packages/node/test/index.test.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -487,24 +487,6 @@ describe('SentryNode initialization', () => {
487487
});
488488
});
489489

490-
describe('instrumenter', () => {
491-
it('defaults to sentry instrumenter', () => {
492-
init({ dsn });
493-
494-
const instrumenter = (getClient()?.getOptions() as NodeClientOptions).instrumenter;
495-
496-
expect(instrumenter).toEqual('sentry');
497-
});
498-
499-
it('allows to set instrumenter', () => {
500-
init({ dsn, instrumenter: 'otel' });
501-
502-
const instrumenter = (getClient()?.getOptions() as NodeClientOptions).instrumenter;
503-
504-
expect(instrumenter).toEqual('otel');
505-
});
506-
});
507-
508490
describe('propagation context', () => {
509491
beforeEach(() => {
510492
process.env.SENTRY_TRACE = '12312012123120121231201212312012-1121201211212012-0';

packages/node/test/integrations/http.test.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -261,33 +261,6 @@ describe('tracing', () => {
261261
expect(baggage).not.toBeDefined();
262262
});
263263

264-
it("doesn't attach when using otel instrumenter", () => {
265-
const loggerLogSpy = jest.spyOn(logger, 'log');
266-
267-
const options = getDefaultNodeClientOptions({
268-
dsn: 'https://[email protected]/12312012',
269-
tracesSampleRate: 1.0,
270-
// eslint-disable-next-line deprecation/deprecation
271-
integrations: [new HttpIntegration({ tracing: true })],
272-
release: '1.0.0',
273-
environment: 'production',
274-
instrumenter: 'otel',
275-
});
276-
const client = new NodeClient(options);
277-
setCurrentClient(client);
278-
// eslint-disable-next-line deprecation/deprecation
279-
const hub = getCurrentHub();
280-
281-
// eslint-disable-next-line deprecation/deprecation
282-
const integration = new HttpIntegration();
283-
integration.setupOnce(
284-
() => {},
285-
() => hub as Hub,
286-
);
287-
288-
expect(loggerLogSpy).toBeCalledWith('HTTP Integration is skipped because of instrumenter configuration.');
289-
});
290-
291264
it('omits query and fragment from description and adds to span data instead', () => {
292265
nock('http://dogs.are.great').get('/spaniel?tail=wag&cute=true#learn-more').reply(200);
293266

packages/opentelemetry-node/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ const {
5454
Sentry.init({
5555
dsn: '__DSN__',
5656
tracesSampleRate: 1.0,
57-
// set the instrumenter to use OpenTelemetry instead of Sentry
58-
instrumenter: 'otel',
5957
// ...
6058
});
6159

packages/opentelemetry-node/src/spanprocessor.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export class SentrySpanProcessor implements OtelSpanProcessor {
6767
// eslint-disable-next-line deprecation/deprecation
6868
const sentryChildSpan = sentryParentSpan.startChild({
6969
name: otelSpan.name,
70-
instrumenter: 'otel',
7170
startTimestamp: convertOtelTimeToSeconds(otelSpan.startTime),
7271
spanId: otelSpanId,
7372
});
@@ -80,7 +79,6 @@ export class SentrySpanProcessor implements OtelSpanProcessor {
8079
name: otelSpan.name,
8180
...traceCtx,
8281
attributes: otelSpan.attributes,
83-
instrumenter: 'otel',
8482
startTimestamp: convertOtelTimeToSeconds(otelSpan.startTime),
8583
spanId: otelSpanId,
8684
});

0 commit comments

Comments
 (0)