Skip to content

Commit b38bccd

Browse files
authored
ref(node-experimental): Remove deprecated class integrations (#10675)
Remove deprecated class integrations from node-experimental.
1 parent dc8726a commit b38bccd

File tree

7 files changed

+10
-475
lines changed

7 files changed

+10
-475
lines changed

packages/node-experimental/src/index.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import { Integrations as CoreIntegrations } from '@sentry/core';
2-
3-
import * as NodeExperimentalIntegrations from './integrations';
41
export { expressIntegration } from './integrations/express';
52
export { fastifyIntegration } from './integrations/fastify';
63
export { graphqlIntegration } from './integrations/graphql';
@@ -14,13 +11,6 @@ export { nativeNodeFetchIntegration } from './integrations/node-fetch';
1411
export { postgresIntegration } from './integrations/postgres';
1512
export { prismaIntegration } from './integrations/prisma';
1613

17-
/** @deprecated Import the integration function directly, e.g. `inboundFiltersIntegration()` instead of `new Integrations.InboundFilter(). */
18-
export const Integrations = {
19-
// eslint-disable-next-line deprecation/deprecation
20-
...CoreIntegrations,
21-
...NodeExperimentalIntegrations,
22-
};
23-
2414
export { init, getDefaultIntegrations } from './sdk/init';
2515
export { getAutoPerformanceIntegrations } from './integrations/getAutoPerformanceIntegrations';
2616
export * as Handlers from './sdk/handlers';

packages/node-experimental/src/integrations/http.ts

Lines changed: 2 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,11 @@ import { SpanKind } from '@opentelemetry/api';
44
import { registerInstrumentations } from '@opentelemetry/instrumentation';
55
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
66

7-
import {
8-
addBreadcrumb,
9-
defineIntegration,
10-
getIsolationScope,
11-
hasTracingEnabled,
12-
isSentryRequestUrl,
13-
} from '@sentry/core';
7+
import { addBreadcrumb, defineIntegration, getIsolationScope, isSentryRequestUrl } from '@sentry/core';
148
import { _INTERNAL, getClient, getSpanKind, setSpanMetadata } from '@sentry/opentelemetry';
15-
import type { EventProcessor, Hub, Integration, IntegrationFn } from '@sentry/types';
16-
import { stringMatchesSomePattern } from '@sentry/utils';
9+
import type { IntegrationFn } from '@sentry/types';
1710

1811
import { setIsolationScope } from '../sdk/scope';
19-
import type { NodeExperimentalClient } from '../types';
2012
import { addOriginToSpan } from '../utils/addOriginToSpan';
2113
import { getRequestUrl } from '../utils/getRequestUrl';
2214

@@ -111,148 +103,6 @@ const _httpIntegration = ((options: HttpOptions = {}) => {
111103

112104
export const httpIntegration = defineIntegration(_httpIntegration);
113105

114-
interface OldHttpOptions {
115-
/**
116-
* Whether breadcrumbs should be recorded for requests
117-
* Defaults to true
118-
*/
119-
breadcrumbs?: boolean;
120-
121-
/**
122-
* Whether tracing spans should be created for requests
123-
* Defaults to false
124-
*/
125-
spans?: boolean;
126-
127-
/**
128-
* Do not capture spans or breadcrumbs for outgoing HTTP requests to URLs matching the given patterns.
129-
*/
130-
ignoreOutgoingRequests?: (string | RegExp)[];
131-
}
132-
133-
/**
134-
* Http instrumentation based on @opentelemetry/instrumentation-http.
135-
* This instrumentation does two things:
136-
* * Create breadcrumbs for outgoing requests
137-
* * Create spans for outgoing requests
138-
*
139-
* Note that this integration is also needed for the Express integration to work!
140-
*
141-
* @deprecated Use `httpIntegration()` instead.
142-
*/
143-
export class Http implements Integration {
144-
/**
145-
* @inheritDoc
146-
*/
147-
public static id: string = 'Http';
148-
149-
/**
150-
* @inheritDoc
151-
*/
152-
public name: string;
153-
154-
/**
155-
* If spans for HTTP requests should be captured.
156-
*/
157-
public shouldCreateSpansForRequests: boolean;
158-
159-
private _unload?: () => void;
160-
private readonly _breadcrumbs: boolean;
161-
// If this is undefined, use default behavior based on client settings
162-
private readonly _spans: boolean | undefined;
163-
private _ignoreOutgoingRequests: (string | RegExp)[];
164-
165-
/**
166-
* @inheritDoc
167-
*/
168-
public constructor(options: OldHttpOptions = {}) {
169-
// eslint-disable-next-line deprecation/deprecation
170-
this.name = Http.id;
171-
this._breadcrumbs = typeof options.breadcrumbs === 'undefined' ? true : options.breadcrumbs;
172-
this._spans = typeof options.spans === 'undefined' ? undefined : options.spans;
173-
174-
this._ignoreOutgoingRequests = options.ignoreOutgoingRequests || [];
175-
176-
// Properly set in setupOnce based on client settings
177-
this.shouldCreateSpansForRequests = false;
178-
}
179-
180-
/**
181-
* @inheritDoc
182-
*/
183-
public setupOnce(_addGlobalEventProcessor: (callback: EventProcessor) => void, _getCurrentHub: () => Hub): void {
184-
// No need to instrument if we don't want to track anything
185-
if (!this._breadcrumbs && this._spans === false) {
186-
return;
187-
}
188-
189-
const client = getClient<NodeExperimentalClient>();
190-
const clientOptions = client?.getOptions();
191-
192-
// This is used in the sampler function
193-
this.shouldCreateSpansForRequests =
194-
typeof this._spans === 'boolean' ? this._spans : hasTracingEnabled(clientOptions);
195-
196-
// Register instrumentations we care about
197-
this._unload = registerInstrumentations({
198-
instrumentations: [
199-
new HttpInstrumentation({
200-
ignoreOutgoingRequestHook: request => {
201-
const url = getRequestUrl(request);
202-
203-
if (!url) {
204-
return false;
205-
}
206-
207-
if (isSentryRequestUrl(url, getClient())) {
208-
return true;
209-
}
210-
211-
if (this._ignoreOutgoingRequests.length && stringMatchesSomePattern(url, this._ignoreOutgoingRequests)) {
212-
return true;
213-
}
214-
215-
return false;
216-
},
217-
218-
ignoreIncomingRequestHook: request => {
219-
const method = request.method?.toUpperCase();
220-
// We do not capture OPTIONS/HEAD requests as transactions
221-
if (method === 'OPTIONS' || method === 'HEAD') {
222-
return true;
223-
}
224-
225-
return false;
226-
},
227-
228-
requireParentforOutgoingSpans: true,
229-
requireParentforIncomingSpans: false,
230-
requestHook: (span, req) => {
231-
_updateSpan(span, req);
232-
233-
// Update the isolation scope, isolate this request
234-
if (getSpanKind(span) === SpanKind.SERVER) {
235-
setIsolationScope(getIsolationScope().clone());
236-
}
237-
},
238-
responseHook: (span, res) => {
239-
if (this._breadcrumbs) {
240-
_addRequestBreadcrumb(span, res);
241-
}
242-
},
243-
}),
244-
],
245-
});
246-
}
247-
248-
/**
249-
* Unregister this integration.
250-
*/
251-
public unregister(): void {
252-
this._unload?.();
253-
}
254-
}
255-
256106
/** Update the span with data we need. */
257107
function _updateSpan(span: Span, request: ClientRequest | IncomingMessage): void {
258108
addOriginToSpan(span, 'auto.http.otel.http');

packages/node-experimental/src/integrations/index.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/node-experimental/src/integrations/node-fetch.ts

Lines changed: 3 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ import type { Span } from '@opentelemetry/api';
22
import { SpanKind } from '@opentelemetry/api';
33
import type { Instrumentation } from '@opentelemetry/instrumentation';
44
import { registerInstrumentations } from '@opentelemetry/instrumentation';
5-
import { addBreadcrumb, defineIntegration, hasTracingEnabled } from '@sentry/core';
6-
import { _INTERNAL, getClient, getSpanKind } from '@sentry/opentelemetry';
7-
import type { Integration, IntegrationFn } from '@sentry/types';
5+
import { addBreadcrumb, defineIntegration } from '@sentry/core';
6+
import { _INTERNAL, getSpanKind } from '@sentry/opentelemetry';
7+
import type { IntegrationFn } from '@sentry/types';
88
import { parseSemver } from '@sentry/utils';
99

10-
import type { NodeExperimentalClient } from '../types';
1110
import { addOriginToSpan } from '../utils/addOriginToSpan';
12-
import { NodePerformanceIntegration } from './NodePerformanceIntegration';
1311

1412
const NODE_VERSION: ReturnType<typeof parseSemver> = parseSemver(process.versions.node);
1513

@@ -77,111 +75,6 @@ const _nativeNodeFetchIntegration = ((options: NodeFetchOptions = {}) => {
7775

7876
export const nativeNodeFetchIntegration = defineIntegration(_nativeNodeFetchIntegration);
7977

80-
interface OldNodeFetchOptions {
81-
/**
82-
* Whether breadcrumbs should be recorded for requests
83-
* Defaults to true
84-
*/
85-
breadcrumbs?: boolean;
86-
87-
/**
88-
* Whether tracing spans should be created for requests
89-
* Defaults to false
90-
*/
91-
spans?: boolean;
92-
}
93-
94-
/**
95-
* Fetch instrumentation based on opentelemetry-instrumentation-fetch.
96-
* This instrumentation does two things:
97-
* * Create breadcrumbs for outgoing requests
98-
* * Create spans for outgoing requests
99-
*
100-
* @deprecated Use `nativeNodeFetchIntegration()` instead.
101-
*/
102-
export class NodeFetch extends NodePerformanceIntegration<OldNodeFetchOptions> implements Integration {
103-
/**
104-
* @inheritDoc
105-
*/
106-
public static id: string = 'NodeFetch';
107-
108-
/**
109-
* @inheritDoc
110-
*/
111-
public name: string;
112-
113-
/**
114-
* If spans for HTTP requests should be captured.
115-
*/
116-
public shouldCreateSpansForRequests: boolean;
117-
118-
private readonly _breadcrumbs: boolean;
119-
// If this is undefined, use default behavior based on client settings
120-
private readonly _spans: boolean | undefined;
121-
122-
/**
123-
* @inheritDoc
124-
*/
125-
public constructor(options: OldNodeFetchOptions = {}) {
126-
super(options);
127-
128-
// eslint-disable-next-line deprecation/deprecation
129-
this.name = NodeFetch.id;
130-
this._breadcrumbs = typeof options.breadcrumbs === 'undefined' ? true : options.breadcrumbs;
131-
this._spans = typeof options.spans === 'undefined' ? undefined : options.spans;
132-
133-
// Properly set in setupOnce based on client settings
134-
this.shouldCreateSpansForRequests = false;
135-
}
136-
137-
/** @inheritDoc */
138-
public setupInstrumentation(): void | Instrumentation[] {
139-
// Only add NodeFetch if Node >= 16, as previous versions do not support it
140-
if (!NODE_VERSION.major || NODE_VERSION.major < 16) {
141-
return;
142-
}
143-
144-
try {
145-
// eslint-disable-next-line @typescript-eslint/no-var-requires
146-
const { FetchInstrumentation } = require('opentelemetry-instrumentation-fetch-node');
147-
return [
148-
new FetchInstrumentation({
149-
onRequest: ({ span }: { span: Span }) => {
150-
_updateSpan(span);
151-
152-
if (this._breadcrumbs) {
153-
_addRequestBreadcrumb(span);
154-
}
155-
},
156-
}),
157-
];
158-
} catch (error) {
159-
// Could not load instrumentation
160-
}
161-
}
162-
163-
/**
164-
* @inheritDoc
165-
*/
166-
public setupOnce(): void {
167-
super.setupOnce();
168-
169-
const client = getClient<NodeExperimentalClient>();
170-
const clientOptions = client?.getOptions();
171-
172-
// This is used in the sampler function
173-
this.shouldCreateSpansForRequests =
174-
typeof this._spans === 'boolean' ? this._spans : hasTracingEnabled(clientOptions);
175-
}
176-
177-
/**
178-
* Unregister this integration.
179-
*/
180-
public unregister(): void {
181-
this._unload?.();
182-
}
183-
}
184-
18578
/** Update the span with data we need. */
18679
function _updateSpan(span: Span): void {
18780
addOriginToSpan(span, 'auto.http.otel.node_fetch');

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
startSession,
88
} from '@sentry/core';
99
import {
10-
defaultIntegrations as defaultNodeIntegrations,
1110
defaultStackParser,
1211
getDefaultIntegrations as getDefaultNodeIntegrations,
1312
getSentryRelease,
@@ -34,14 +33,6 @@ import { initOtel } from './initOtel';
3433

3534
const ignoredDefaultIntegrations = ['Http', 'Undici'];
3635

37-
/** @deprecated Use `getDefaultIntegrations(options)` instead. */
38-
export const defaultIntegrations: Integration[] = [
39-
// eslint-disable-next-line deprecation/deprecation
40-
...defaultNodeIntegrations.filter(i => !ignoredDefaultIntegrations.includes(i.name)),
41-
httpIntegration(),
42-
nativeNodeFetchIntegration(),
43-
];
44-
4536
/** Get the default integrations for the Node Experimental SDK. */
4637
export function getDefaultIntegrations(options: Options): Integration[] {
4738
return [

0 commit comments

Comments
 (0)