From 67a24432c495358a1ada3af1c587acd1817d7334 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 19 Feb 2024 16:54:34 +0100 Subject: [PATCH 1/4] ref: move performance integrations into folder --- packages/node-experimental/src/index.ts | 22 +++---- .../NodePerformanceIntegration.ts | 57 ------------------- .../src/integrations/{ => tracing}/express.ts | 2 +- .../src/integrations/{ => tracing}/fastify.ts | 2 +- .../src/integrations/{ => tracing}/graphql.ts | 2 +- .../src/integrations/{ => tracing}/hapi.ts | 0 .../index.ts} | 0 .../src/integrations/{ => tracing}/koa.ts | 0 .../src/integrations/{ => tracing}/mongo.ts | 2 +- .../integrations/{ => tracing}/mongoose.ts | 2 +- .../src/integrations/{ => tracing}/mysql.ts | 0 .../src/integrations/{ => tracing}/mysql2.ts | 2 +- .../src/integrations/{ => tracing}/nest.ts | 0 .../integrations/{ => tracing}/postgres.ts | 2 +- .../src/integrations/{ => tracing}/prisma.ts | 0 packages/node-experimental/src/sdk/init.ts | 2 +- 16 files changed, 19 insertions(+), 76 deletions(-) delete mode 100644 packages/node-experimental/src/integrations/NodePerformanceIntegration.ts rename packages/node-experimental/src/integrations/{ => tracing}/express.ts (96%) rename packages/node-experimental/src/integrations/{ => tracing}/fastify.ts (96%) rename packages/node-experimental/src/integrations/{ => tracing}/graphql.ts (96%) rename packages/node-experimental/src/integrations/{ => tracing}/hapi.ts (100%) rename packages/node-experimental/src/integrations/{getAutoPerformanceIntegrations.ts => tracing/index.ts} (100%) rename packages/node-experimental/src/integrations/{ => tracing}/koa.ts (100%) rename packages/node-experimental/src/integrations/{ => tracing}/mongo.ts (96%) rename packages/node-experimental/src/integrations/{ => tracing}/mongoose.ts (96%) rename packages/node-experimental/src/integrations/{ => tracing}/mysql.ts (100%) rename packages/node-experimental/src/integrations/{ => tracing}/mysql2.ts (96%) rename packages/node-experimental/src/integrations/{ => tracing}/nest.ts (100%) rename packages/node-experimental/src/integrations/{ => tracing}/postgres.ts (96%) rename packages/node-experimental/src/integrations/{ => tracing}/prisma.ts (100%) diff --git a/packages/node-experimental/src/index.ts b/packages/node-experimental/src/index.ts index 22e29a146df2..4af67b8e22dc 100644 --- a/packages/node-experimental/src/index.ts +++ b/packages/node-experimental/src/index.ts @@ -1,18 +1,18 @@ -export { expressIntegration } from './integrations/express'; -export { fastifyIntegration } from './integrations/fastify'; -export { graphqlIntegration } from './integrations/graphql'; +export { expressIntegration } from './integrations/tracing/express'; +export { fastifyIntegration } from './integrations/tracing/fastify'; +export { graphqlIntegration } from './integrations/tracing/graphql'; export { httpIntegration } from './integrations/http'; -export { mongoIntegration } from './integrations/mongo'; -export { mongooseIntegration } from './integrations/mongoose'; -export { mysqlIntegration } from './integrations/mysql'; -export { mysql2Integration } from './integrations/mysql2'; -export { nestIntegration } from './integrations/nest'; +export { mongoIntegration } from './integrations/tracing/mongo'; +export { mongooseIntegration } from './integrations/tracing/mongoose'; +export { mysqlIntegration } from './integrations/tracing/mysql'; +export { mysql2Integration } from './integrations/tracing/mysql2'; +export { nestIntegration } from './integrations/tracing/nest'; export { nativeNodeFetchIntegration } from './integrations/node-fetch'; -export { postgresIntegration } from './integrations/postgres'; -export { prismaIntegration } from './integrations/prisma'; +export { postgresIntegration } from './integrations/tracing/postgres'; +export { prismaIntegration } from './integrations/tracing/prisma'; export { init, getDefaultIntegrations } from './sdk/init'; -export { getAutoPerformanceIntegrations } from './integrations/getAutoPerformanceIntegrations'; +export { getAutoPerformanceIntegrations } from './integrations/tracing'; export * as Handlers from './sdk/handlers'; export type { Span } from './types'; diff --git a/packages/node-experimental/src/integrations/NodePerformanceIntegration.ts b/packages/node-experimental/src/integrations/NodePerformanceIntegration.ts deleted file mode 100644 index 536b9ed55daa..000000000000 --- a/packages/node-experimental/src/integrations/NodePerformanceIntegration.ts +++ /dev/null @@ -1,57 +0,0 @@ -import type { Instrumentation } from '@opentelemetry/instrumentation'; -import { registerInstrumentations } from '@opentelemetry/instrumentation'; - -/** - * The base node performance integration. - */ -export abstract class NodePerformanceIntegration { - protected _options: IntegrationOptions; - protected _unload?: () => void; - protected _instrumentations?: Instrumentation[] | undefined; - - public abstract name: string; - - public constructor(options: IntegrationOptions) { - this._options = options; - } - - /** - * Load the instrumentation(s) for this integration. - * Returns `true` if the instrumentations were loaded, else false. - */ - public loadInstrumentations(): boolean { - try { - this._instrumentations = this.setupInstrumentation(this._options) || undefined; - } catch (error) { - return false; - } - - return true; - } - - /** - * @inheritDoc - */ - public setupOnce(): void { - const instrumentations = this._instrumentations || this.setupInstrumentation(this._options); - - if (!instrumentations) { - return; - } - - // Register instrumentations we care about - this._unload = registerInstrumentations({ - instrumentations, - }); - } - - /** - * Unregister this integration. - */ - public unregister(): void { - this._unload?.(); - } - - // Return the instrumentation(s) needed for this integration. - public abstract setupInstrumentation(options: IntegrationOptions): Instrumentation[] | void; -} diff --git a/packages/node-experimental/src/integrations/express.ts b/packages/node-experimental/src/integrations/tracing/express.ts similarity index 96% rename from packages/node-experimental/src/integrations/express.ts rename to packages/node-experimental/src/integrations/tracing/express.ts index 1931038da714..7dbdb42047a5 100644 --- a/packages/node-experimental/src/integrations/express.ts +++ b/packages/node-experimental/src/integrations/tracing/express.ts @@ -4,7 +4,7 @@ import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express'; import { defineIntegration } from '@sentry/core'; import type { Integration, IntegrationFn } from '@sentry/types'; -import { addOriginToSpan } from '../utils/addOriginToSpan'; +import { addOriginToSpan } from '../../utils/addOriginToSpan'; import { NodePerformanceIntegration } from './NodePerformanceIntegration'; const _expressIntegration = (() => { diff --git a/packages/node-experimental/src/integrations/fastify.ts b/packages/node-experimental/src/integrations/tracing/fastify.ts similarity index 96% rename from packages/node-experimental/src/integrations/fastify.ts rename to packages/node-experimental/src/integrations/tracing/fastify.ts index b34d267934aa..ada513ef9d11 100644 --- a/packages/node-experimental/src/integrations/fastify.ts +++ b/packages/node-experimental/src/integrations/tracing/fastify.ts @@ -4,7 +4,7 @@ import { FastifyInstrumentation } from '@opentelemetry/instrumentation-fastify'; import { defineIntegration } from '@sentry/core'; import type { Integration, IntegrationFn } from '@sentry/types'; -import { addOriginToSpan } from '../utils/addOriginToSpan'; +import { addOriginToSpan } from '../../utils/addOriginToSpan'; import { NodePerformanceIntegration } from './NodePerformanceIntegration'; const _fastifyIntegration = (() => { diff --git a/packages/node-experimental/src/integrations/graphql.ts b/packages/node-experimental/src/integrations/tracing/graphql.ts similarity index 96% rename from packages/node-experimental/src/integrations/graphql.ts rename to packages/node-experimental/src/integrations/tracing/graphql.ts index 576d049c44b9..ff4e8691806c 100644 --- a/packages/node-experimental/src/integrations/graphql.ts +++ b/packages/node-experimental/src/integrations/tracing/graphql.ts @@ -4,7 +4,7 @@ import { GraphQLInstrumentation } from '@opentelemetry/instrumentation-graphql'; import { defineIntegration } from '@sentry/core'; import type { Integration, IntegrationFn } from '@sentry/types'; -import { addOriginToSpan } from '../utils/addOriginToSpan'; +import { addOriginToSpan } from '../../utils/addOriginToSpan'; import { NodePerformanceIntegration } from './NodePerformanceIntegration'; const _graphqlIntegration = (() => { diff --git a/packages/node-experimental/src/integrations/hapi.ts b/packages/node-experimental/src/integrations/tracing/hapi.ts similarity index 100% rename from packages/node-experimental/src/integrations/hapi.ts rename to packages/node-experimental/src/integrations/tracing/hapi.ts diff --git a/packages/node-experimental/src/integrations/getAutoPerformanceIntegrations.ts b/packages/node-experimental/src/integrations/tracing/index.ts similarity index 100% rename from packages/node-experimental/src/integrations/getAutoPerformanceIntegrations.ts rename to packages/node-experimental/src/integrations/tracing/index.ts diff --git a/packages/node-experimental/src/integrations/koa.ts b/packages/node-experimental/src/integrations/tracing/koa.ts similarity index 100% rename from packages/node-experimental/src/integrations/koa.ts rename to packages/node-experimental/src/integrations/tracing/koa.ts diff --git a/packages/node-experimental/src/integrations/mongo.ts b/packages/node-experimental/src/integrations/tracing/mongo.ts similarity index 96% rename from packages/node-experimental/src/integrations/mongo.ts rename to packages/node-experimental/src/integrations/tracing/mongo.ts index bcfaaaf1bc62..fbc23213da9b 100644 --- a/packages/node-experimental/src/integrations/mongo.ts +++ b/packages/node-experimental/src/integrations/tracing/mongo.ts @@ -4,7 +4,7 @@ import { MongoDBInstrumentation } from '@opentelemetry/instrumentation-mongodb'; import { defineIntegration } from '@sentry/core'; import type { Integration, IntegrationFn } from '@sentry/types'; -import { addOriginToSpan } from '../utils/addOriginToSpan'; +import { addOriginToSpan } from '../../utils/addOriginToSpan'; import { NodePerformanceIntegration } from './NodePerformanceIntegration'; const _mongoIntegration = (() => { diff --git a/packages/node-experimental/src/integrations/mongoose.ts b/packages/node-experimental/src/integrations/tracing/mongoose.ts similarity index 96% rename from packages/node-experimental/src/integrations/mongoose.ts rename to packages/node-experimental/src/integrations/tracing/mongoose.ts index a14c7d54a266..93fd7ec5d994 100644 --- a/packages/node-experimental/src/integrations/mongoose.ts +++ b/packages/node-experimental/src/integrations/tracing/mongoose.ts @@ -4,7 +4,7 @@ import { MongooseInstrumentation } from '@opentelemetry/instrumentation-mongoose import { defineIntegration } from '@sentry/core'; import type { Integration, IntegrationFn } from '@sentry/types'; -import { addOriginToSpan } from '../utils/addOriginToSpan'; +import { addOriginToSpan } from '../../utils/addOriginToSpan'; import { NodePerformanceIntegration } from './NodePerformanceIntegration'; const _mongooseIntegration = (() => { diff --git a/packages/node-experimental/src/integrations/mysql.ts b/packages/node-experimental/src/integrations/tracing/mysql.ts similarity index 100% rename from packages/node-experimental/src/integrations/mysql.ts rename to packages/node-experimental/src/integrations/tracing/mysql.ts diff --git a/packages/node-experimental/src/integrations/mysql2.ts b/packages/node-experimental/src/integrations/tracing/mysql2.ts similarity index 96% rename from packages/node-experimental/src/integrations/mysql2.ts rename to packages/node-experimental/src/integrations/tracing/mysql2.ts index bb89d0aa01cb..abc7ff1fceec 100644 --- a/packages/node-experimental/src/integrations/mysql2.ts +++ b/packages/node-experimental/src/integrations/tracing/mysql2.ts @@ -4,7 +4,7 @@ import { MySQL2Instrumentation } from '@opentelemetry/instrumentation-mysql2'; import { defineIntegration } from '@sentry/core'; import type { Integration, IntegrationFn } from '@sentry/types'; -import { addOriginToSpan } from '../utils/addOriginToSpan'; +import { addOriginToSpan } from '../../utils/addOriginToSpan'; import { NodePerformanceIntegration } from './NodePerformanceIntegration'; const _mysql2Integration = (() => { diff --git a/packages/node-experimental/src/integrations/nest.ts b/packages/node-experimental/src/integrations/tracing/nest.ts similarity index 100% rename from packages/node-experimental/src/integrations/nest.ts rename to packages/node-experimental/src/integrations/tracing/nest.ts diff --git a/packages/node-experimental/src/integrations/postgres.ts b/packages/node-experimental/src/integrations/tracing/postgres.ts similarity index 96% rename from packages/node-experimental/src/integrations/postgres.ts rename to packages/node-experimental/src/integrations/tracing/postgres.ts index 91a6a710ffdd..568b1d29238c 100644 --- a/packages/node-experimental/src/integrations/postgres.ts +++ b/packages/node-experimental/src/integrations/tracing/postgres.ts @@ -4,7 +4,7 @@ import { PgInstrumentation } from '@opentelemetry/instrumentation-pg'; import { defineIntegration } from '@sentry/core'; import type { Integration, IntegrationFn } from '@sentry/types'; -import { addOriginToSpan } from '../utils/addOriginToSpan'; +import { addOriginToSpan } from '../../utils/addOriginToSpan'; import { NodePerformanceIntegration } from './NodePerformanceIntegration'; const _postgresIntegration = (() => { diff --git a/packages/node-experimental/src/integrations/prisma.ts b/packages/node-experimental/src/integrations/tracing/prisma.ts similarity index 100% rename from packages/node-experimental/src/integrations/prisma.ts rename to packages/node-experimental/src/integrations/tracing/prisma.ts diff --git a/packages/node-experimental/src/sdk/init.ts b/packages/node-experimental/src/sdk/init.ts index 78d9fa7ef572..093a61cb6966 100644 --- a/packages/node-experimental/src/sdk/init.ts +++ b/packages/node-experimental/src/sdk/init.ts @@ -23,9 +23,9 @@ import { } from '@sentry/utils'; import { DEBUG_BUILD } from '../debug-build'; -import { getAutoPerformanceIntegrations } from '../integrations/getAutoPerformanceIntegrations'; import { httpIntegration } from '../integrations/http'; import { nativeNodeFetchIntegration } from '../integrations/node-fetch'; +import { getAutoPerformanceIntegrations } from '../integrations/tracing'; import { makeNodeTransport } from '../transports'; import type { NodeClientOptions, NodeOptions } from '../types'; import { NodeClient } from './client'; From b2e10961e52c8284419413cbe7cac3e8a7c3ddc6 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 19 Feb 2024 17:16:30 +0100 Subject: [PATCH 2/4] ref: remove old stuff --- .../src/integrations/tracing/express.ts | 35 +---------------- .../src/integrations/tracing/fastify.ts | 37 +----------------- .../src/integrations/tracing/graphql.ts | 38 +------------------ .../src/integrations/tracing/hapi.ts | 33 +--------------- .../src/integrations/tracing/mongo.ts | 37 +----------------- .../src/integrations/tracing/mongoose.ts | 37 +----------------- .../src/integrations/tracing/mysql.ts | 33 +--------------- .../src/integrations/tracing/mysql2.ts | 37 +----------------- .../src/integrations/tracing/nest.ts | 33 +--------------- .../src/integrations/tracing/postgres.ts | 38 +------------------ .../src/integrations/tracing/prisma.ts | 33 +--------------- 11 files changed, 22 insertions(+), 369 deletions(-) diff --git a/packages/node-experimental/src/integrations/tracing/express.ts b/packages/node-experimental/src/integrations/tracing/express.ts index 7dbdb42047a5..20081d418439 100644 --- a/packages/node-experimental/src/integrations/tracing/express.ts +++ b/packages/node-experimental/src/integrations/tracing/express.ts @@ -1,11 +1,9 @@ -import type { Instrumentation } from '@opentelemetry/instrumentation'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express'; import { defineIntegration } from '@sentry/core'; -import type { Integration, IntegrationFn } from '@sentry/types'; +import type { IntegrationFn } from '@sentry/types'; import { addOriginToSpan } from '../../utils/addOriginToSpan'; -import { NodePerformanceIntegration } from './NodePerformanceIntegration'; const _expressIntegration = (() => { return { @@ -24,39 +22,10 @@ const _expressIntegration = (() => { }; }) satisfies IntegrationFn; -export const expressIntegration = defineIntegration(_expressIntegration); - /** * Express integration * * Capture tracing data for express. * @deprecated Use `expressIntegration()` instead. */ -export class Express extends NodePerformanceIntegration implements Integration { - /** - * @inheritDoc - */ - public static id: string = 'Express'; - - /** - * @inheritDoc - */ - public name: string; - - public constructor() { - super(); - // eslint-disable-next-line deprecation/deprecation - this.name = Express.id; - } - - /** @inheritDoc */ - public setupInstrumentation(): void | Instrumentation[] { - return [ - new ExpressInstrumentation({ - requestHook(span) { - addOriginToSpan(span, 'auto.http.otel.express'); - }, - }), - ]; - } -} +export const expressIntegration = defineIntegration(_expressIntegration); diff --git a/packages/node-experimental/src/integrations/tracing/fastify.ts b/packages/node-experimental/src/integrations/tracing/fastify.ts index ada513ef9d11..11742d960dff 100644 --- a/packages/node-experimental/src/integrations/tracing/fastify.ts +++ b/packages/node-experimental/src/integrations/tracing/fastify.ts @@ -1,11 +1,9 @@ -import type { Instrumentation } from '@opentelemetry/instrumentation'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { FastifyInstrumentation } from '@opentelemetry/instrumentation-fastify'; import { defineIntegration } from '@sentry/core'; -import type { Integration, IntegrationFn } from '@sentry/types'; +import type { IntegrationFn } from '@sentry/types'; import { addOriginToSpan } from '../../utils/addOriginToSpan'; -import { NodePerformanceIntegration } from './NodePerformanceIntegration'; const _fastifyIntegration = (() => { return { @@ -24,40 +22,9 @@ const _fastifyIntegration = (() => { }; }) satisfies IntegrationFn; -export const fastifyIntegration = defineIntegration(_fastifyIntegration); - /** * Express integration * * Capture tracing data for fastify. - * - * @deprecated Use `fastifyIntegration()` instead. */ -export class Fastify extends NodePerformanceIntegration implements Integration { - /** - * @inheritDoc - */ - public static id: string = 'Fastify'; - - /** - * @inheritDoc - */ - public name: string; - - public constructor() { - super(); - // eslint-disable-next-line deprecation/deprecation - this.name = Fastify.id; - } - - /** @inheritDoc */ - public setupInstrumentation(): void | Instrumentation[] { - return [ - new FastifyInstrumentation({ - requestHook(span) { - addOriginToSpan(span, 'auto.http.otel.fastify'); - }, - }), - ]; - } -} +export const fastifyIntegration = defineIntegration(_fastifyIntegration); diff --git a/packages/node-experimental/src/integrations/tracing/graphql.ts b/packages/node-experimental/src/integrations/tracing/graphql.ts index ff4e8691806c..a91524ece6bb 100644 --- a/packages/node-experimental/src/integrations/tracing/graphql.ts +++ b/packages/node-experimental/src/integrations/tracing/graphql.ts @@ -1,11 +1,9 @@ -import type { Instrumentation } from '@opentelemetry/instrumentation'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { GraphQLInstrumentation } from '@opentelemetry/instrumentation-graphql'; import { defineIntegration } from '@sentry/core'; -import type { Integration, IntegrationFn } from '@sentry/types'; +import type { IntegrationFn } from '@sentry/types'; import { addOriginToSpan } from '../../utils/addOriginToSpan'; -import { NodePerformanceIntegration } from './NodePerformanceIntegration'; const _graphqlIntegration = (() => { return { @@ -25,41 +23,9 @@ const _graphqlIntegration = (() => { }; }) satisfies IntegrationFn; -export const graphqlIntegration = defineIntegration(_graphqlIntegration); - /** * GraphQL integration * * Capture tracing data for GraphQL. - * - * @deprecated Use `graphqlIntegration()` instead. */ -export class GraphQL extends NodePerformanceIntegration implements Integration { - /** - * @inheritDoc - */ - public static id: string = 'GraphQL'; - - /** - * @inheritDoc - */ - public name: string; - - public constructor() { - super(); - // eslint-disable-next-line deprecation/deprecation - this.name = GraphQL.id; - } - - /** @inheritDoc */ - public setupInstrumentation(): void | Instrumentation[] { - return [ - new GraphQLInstrumentation({ - ignoreTrivialResolveSpans: true, - responseHook(span) { - addOriginToSpan(span, 'auto.graphql.otel.graphql'); - }, - }), - ]; - } -} +export const graphqlIntegration = defineIntegration(_graphqlIntegration); diff --git a/packages/node-experimental/src/integrations/tracing/hapi.ts b/packages/node-experimental/src/integrations/tracing/hapi.ts index 1376bcb49ccf..949726af698b 100644 --- a/packages/node-experimental/src/integrations/tracing/hapi.ts +++ b/packages/node-experimental/src/integrations/tracing/hapi.ts @@ -1,10 +1,7 @@ -import type { Instrumentation } from '@opentelemetry/instrumentation'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { HapiInstrumentation } from '@opentelemetry/instrumentation-hapi'; import { defineIntegration } from '@sentry/core'; -import type { Integration, IntegrationFn } from '@sentry/types'; - -import { NodePerformanceIntegration } from './NodePerformanceIntegration'; +import type { IntegrationFn } from '@sentry/types'; const _hapiIntegration = (() => { return { @@ -17,35 +14,9 @@ const _hapiIntegration = (() => { }; }) satisfies IntegrationFn; -export const hapiIntegration = defineIntegration(_hapiIntegration); - /** * Hapi integration * * Capture tracing data for Hapi. - * - * @deprecated Use `hapiIntegration()` instead. */ -export class Hapi extends NodePerformanceIntegration implements Integration { - /** - * @inheritDoc - */ - public static id: string = 'Hapi'; - - /** - * @inheritDoc - */ - public name: string; - - public constructor() { - super(); - // eslint-disable-next-line deprecation/deprecation - this.name = Hapi.id; - } - - /** @inheritDoc */ - public setupInstrumentation(): void | Instrumentation[] { - // Has no hook to adjust spans and add origin - return [new HapiInstrumentation()]; - } -} +export const hapiIntegration = defineIntegration(_hapiIntegration); diff --git a/packages/node-experimental/src/integrations/tracing/mongo.ts b/packages/node-experimental/src/integrations/tracing/mongo.ts index fbc23213da9b..9bbfd16a9581 100644 --- a/packages/node-experimental/src/integrations/tracing/mongo.ts +++ b/packages/node-experimental/src/integrations/tracing/mongo.ts @@ -1,11 +1,9 @@ -import type { Instrumentation } from '@opentelemetry/instrumentation'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { MongoDBInstrumentation } from '@opentelemetry/instrumentation-mongodb'; import { defineIntegration } from '@sentry/core'; -import type { Integration, IntegrationFn } from '@sentry/types'; +import type { IntegrationFn } from '@sentry/types'; import { addOriginToSpan } from '../../utils/addOriginToSpan'; -import { NodePerformanceIntegration } from './NodePerformanceIntegration'; const _mongoIntegration = (() => { return { @@ -24,40 +22,9 @@ const _mongoIntegration = (() => { }; }) satisfies IntegrationFn; -export const mongoIntegration = defineIntegration(_mongoIntegration); - /** * MongoDB integration * * Capture tracing data for MongoDB. - * - * @deprecated Use `mongoIntegration()` instead. */ -export class Mongo extends NodePerformanceIntegration implements Integration { - /** - * @inheritDoc - */ - public static id: string = 'Mongo'; - - /** - * @inheritDoc - */ - public name: string; - - public constructor() { - super(); - // eslint-disable-next-line deprecation/deprecation - this.name = Mongo.id; - } - - /** @inheritDoc */ - public setupInstrumentation(): void | Instrumentation[] { - return [ - new MongoDBInstrumentation({ - responseHook(span) { - addOriginToSpan(span, 'auto.db.otel.mongo'); - }, - }), - ]; - } -} +export const mongoIntegration = defineIntegration(_mongoIntegration); diff --git a/packages/node-experimental/src/integrations/tracing/mongoose.ts b/packages/node-experimental/src/integrations/tracing/mongoose.ts index 93fd7ec5d994..ba15fc647907 100644 --- a/packages/node-experimental/src/integrations/tracing/mongoose.ts +++ b/packages/node-experimental/src/integrations/tracing/mongoose.ts @@ -1,11 +1,9 @@ -import type { Instrumentation } from '@opentelemetry/instrumentation'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { MongooseInstrumentation } from '@opentelemetry/instrumentation-mongoose'; import { defineIntegration } from '@sentry/core'; -import type { Integration, IntegrationFn } from '@sentry/types'; +import type { IntegrationFn } from '@sentry/types'; import { addOriginToSpan } from '../../utils/addOriginToSpan'; -import { NodePerformanceIntegration } from './NodePerformanceIntegration'; const _mongooseIntegration = (() => { return { @@ -24,40 +22,9 @@ const _mongooseIntegration = (() => { }; }) satisfies IntegrationFn; -export const mongooseIntegration = defineIntegration(_mongooseIntegration); - /** * Mongoose integration * * Capture tracing data for Mongoose. - * - * @deprecated Use `mongooseIntegration()` instead. */ -export class Mongoose extends NodePerformanceIntegration implements Integration { - /** - * @inheritDoc - */ - public static id: string = 'Mongoose'; - - /** - * @inheritDoc - */ - public name: string; - - public constructor() { - super(); - // eslint-disable-next-line deprecation/deprecation - this.name = Mongoose.id; - } - - /** @inheritDoc */ - public setupInstrumentation(): void | Instrumentation[] { - return [ - new MongooseInstrumentation({ - responseHook(span) { - addOriginToSpan(span, 'auto.db.otel.mongoose'); - }, - }), - ]; - } -} +export const mongooseIntegration = defineIntegration(_mongooseIntegration); diff --git a/packages/node-experimental/src/integrations/tracing/mysql.ts b/packages/node-experimental/src/integrations/tracing/mysql.ts index 3cf0f4e42c87..4f6123c7eed9 100644 --- a/packages/node-experimental/src/integrations/tracing/mysql.ts +++ b/packages/node-experimental/src/integrations/tracing/mysql.ts @@ -1,10 +1,7 @@ -import type { Instrumentation } from '@opentelemetry/instrumentation'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { MySQLInstrumentation } from '@opentelemetry/instrumentation-mysql'; import { defineIntegration } from '@sentry/core'; -import type { Integration, IntegrationFn } from '@sentry/types'; - -import { NodePerformanceIntegration } from './NodePerformanceIntegration'; +import type { IntegrationFn } from '@sentry/types'; const _mysqlIntegration = (() => { return { @@ -17,35 +14,9 @@ const _mysqlIntegration = (() => { }; }) satisfies IntegrationFn; -export const mysqlIntegration = defineIntegration(_mysqlIntegration); - /** * MySQL integration * * Capture tracing data for mysql. - * - * @deprecated Use `mysqlIntegration()` instead. */ -export class Mysql extends NodePerformanceIntegration implements Integration { - /** - * @inheritDoc - */ - public static id: string = 'Mysql'; - - /** - * @inheritDoc - */ - public name: string; - - public constructor() { - super(); - // eslint-disable-next-line deprecation/deprecation - this.name = Mysql.id; - } - - /** @inheritDoc */ - public setupInstrumentation(): void | Instrumentation[] { - // Has no hook to adjust spans and add origin - return [new MySQLInstrumentation({})]; - } -} +export const mysqlIntegration = defineIntegration(_mysqlIntegration); diff --git a/packages/node-experimental/src/integrations/tracing/mysql2.ts b/packages/node-experimental/src/integrations/tracing/mysql2.ts index abc7ff1fceec..14a9e826c332 100644 --- a/packages/node-experimental/src/integrations/tracing/mysql2.ts +++ b/packages/node-experimental/src/integrations/tracing/mysql2.ts @@ -1,11 +1,9 @@ -import type { Instrumentation } from '@opentelemetry/instrumentation'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { MySQL2Instrumentation } from '@opentelemetry/instrumentation-mysql2'; import { defineIntegration } from '@sentry/core'; -import type { Integration, IntegrationFn } from '@sentry/types'; +import type { IntegrationFn } from '@sentry/types'; import { addOriginToSpan } from '../../utils/addOriginToSpan'; -import { NodePerformanceIntegration } from './NodePerformanceIntegration'; const _mysql2Integration = (() => { return { @@ -24,40 +22,9 @@ const _mysql2Integration = (() => { }; }) satisfies IntegrationFn; -export const mysql2Integration = defineIntegration(_mysql2Integration); - /** * MySQL2 integration * * Capture tracing data for mysql2 - * - * @deprecated Use `mysql2Integration()` instead. */ -export class Mysql2 extends NodePerformanceIntegration implements Integration { - /** - * @inheritDoc - */ - public static id: string = 'Mysql2'; - - /** - * @inheritDoc - */ - public name: string; - - public constructor() { - super(); - // eslint-disable-next-line deprecation/deprecation - this.name = Mysql2.id; - } - - /** @inheritDoc */ - public setupInstrumentation(): void | Instrumentation[] { - return [ - new MySQL2Instrumentation({ - responseHook(span) { - addOriginToSpan(span, 'auto.db.otel.mysql2'); - }, - }), - ]; - } -} +export const mysql2Integration = defineIntegration(_mysql2Integration); diff --git a/packages/node-experimental/src/integrations/tracing/nest.ts b/packages/node-experimental/src/integrations/tracing/nest.ts index c03955f71193..1f2c75e3807e 100644 --- a/packages/node-experimental/src/integrations/tracing/nest.ts +++ b/packages/node-experimental/src/integrations/tracing/nest.ts @@ -1,10 +1,7 @@ -import type { Instrumentation } from '@opentelemetry/instrumentation'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { NestInstrumentation } from '@opentelemetry/instrumentation-nestjs-core'; import { defineIntegration } from '@sentry/core'; -import type { Integration, IntegrationFn } from '@sentry/types'; - -import { NodePerformanceIntegration } from './NodePerformanceIntegration'; +import type { IntegrationFn } from '@sentry/types'; const _nestIntegration = (() => { return { @@ -17,35 +14,9 @@ const _nestIntegration = (() => { }; }) satisfies IntegrationFn; -export const nestIntegration = defineIntegration(_nestIntegration); - /** * Nest framework integration * * Capture tracing data for nest. - * - * @deprecated Use `nestIntegration()` instead. */ -export class Nest extends NodePerformanceIntegration implements Integration { - /** - * @inheritDoc - */ - public static id: string = 'Nest'; - - /** - * @inheritDoc - */ - public name: string; - - public constructor() { - super(); - // eslint-disable-next-line deprecation/deprecation - this.name = Nest.id; - } - - /** @inheritDoc */ - public setupInstrumentation(): void | Instrumentation[] { - // Does not have a hook to adjust spans and add origin - return [new NestInstrumentation({})]; - } -} +export const nestIntegration = defineIntegration(_nestIntegration); diff --git a/packages/node-experimental/src/integrations/tracing/postgres.ts b/packages/node-experimental/src/integrations/tracing/postgres.ts index 568b1d29238c..e57df5b52d21 100644 --- a/packages/node-experimental/src/integrations/tracing/postgres.ts +++ b/packages/node-experimental/src/integrations/tracing/postgres.ts @@ -1,11 +1,9 @@ -import type { Instrumentation } from '@opentelemetry/instrumentation'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { PgInstrumentation } from '@opentelemetry/instrumentation-pg'; import { defineIntegration } from '@sentry/core'; -import type { Integration, IntegrationFn } from '@sentry/types'; +import type { IntegrationFn } from '@sentry/types'; import { addOriginToSpan } from '../../utils/addOriginToSpan'; -import { NodePerformanceIntegration } from './NodePerformanceIntegration'; const _postgresIntegration = (() => { return { @@ -25,41 +23,9 @@ const _postgresIntegration = (() => { }; }) satisfies IntegrationFn; -export const postgresIntegration = defineIntegration(_postgresIntegration); - /** * Postgres integration * * Capture tracing data for pg. - * - * @deprecated Use `postgresIntegration()` instead. */ -export class Postgres extends NodePerformanceIntegration implements Integration { - /** - * @inheritDoc - */ - public static id: string = 'Postgres'; - - /** - * @inheritDoc - */ - public name: string; - - public constructor() { - super(); - // eslint-disable-next-line deprecation/deprecation - this.name = Postgres.id; - } - - /** @inheritDoc */ - public setupInstrumentation(): void | Instrumentation[] { - return [ - new PgInstrumentation({ - requireParentSpan: true, - requestHook(span) { - addOriginToSpan(span, 'auto.db.otel.postgres'); - }, - }), - ]; - } -} +export const postgresIntegration = defineIntegration(_postgresIntegration); diff --git a/packages/node-experimental/src/integrations/tracing/prisma.ts b/packages/node-experimental/src/integrations/tracing/prisma.ts index 9edd6ce9d02d..1f78262b9a3c 100644 --- a/packages/node-experimental/src/integrations/tracing/prisma.ts +++ b/packages/node-experimental/src/integrations/tracing/prisma.ts @@ -1,10 +1,7 @@ -import type { Instrumentation } from '@opentelemetry/instrumentation'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { PrismaInstrumentation } from '@prisma/instrumentation'; import { defineIntegration } from '@sentry/core'; -import type { Integration, IntegrationFn } from '@sentry/types'; - -import { NodePerformanceIntegration } from './NodePerformanceIntegration'; +import type { IntegrationFn } from '@sentry/types'; const _prismaIntegration = (() => { return { @@ -20,8 +17,6 @@ const _prismaIntegration = (() => { }; }) satisfies IntegrationFn; -export const prismaIntegration = defineIntegration(_prismaIntegration); - /** * Prisma integration * @@ -30,29 +25,5 @@ export const prismaIntegration = defineIntegration(_prismaIntegration); * previewFeatures = ["tracing"] * For the prisma client. * See https://www.prisma.io/docs/concepts/components/prisma-client/opentelemetry-tracing for more details. - * - * @deprecated Use `prismaIntegration()` instead. */ -export class Prisma extends NodePerformanceIntegration implements Integration { - /** - * @inheritDoc - */ - public static id: string = 'Prisma'; - - /** - * @inheritDoc - */ - public name: string; - - public constructor() { - super(); - // eslint-disable-next-line deprecation/deprecation - this.name = Prisma.id; - } - - /** @inheritDoc */ - public setupInstrumentation(): void | Instrumentation[] { - // does not have a hook to adjust spans & add origin - return [new PrismaInstrumentation({})]; - } -} +export const prismaIntegration = defineIntegration(_prismaIntegration); From 4235e929ea7a91907b2bb0226971efafb834c722 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 19 Feb 2024 17:17:07 +0100 Subject: [PATCH 3/4] fix test --- packages/node-experimental/test/sdk/init.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node-experimental/test/sdk/init.test.ts b/packages/node-experimental/test/sdk/init.test.ts index 5474f3c1ca07..7f0c3a8d71ec 100644 --- a/packages/node-experimental/test/sdk/init.test.ts +++ b/packages/node-experimental/test/sdk/init.test.ts @@ -1,6 +1,6 @@ import type { Integration } from '@sentry/types'; -import * as auto from '../../src/integrations/getAutoPerformanceIntegrations'; +import * as auto from '../../src/integrations/tracing'; import { getClient } from '../../src/sdk/api'; import { init } from '../../src/sdk/init'; import { cleanupOtel } from '../helpers/mockSdkInit'; From b50ffda57acbc83427ae69025f1bc4c56b69b1af Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 19 Feb 2024 17:18:56 +0100 Subject: [PATCH 4/4] fix linting --- packages/node-experimental/src/integrations/tracing/express.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/node-experimental/src/integrations/tracing/express.ts b/packages/node-experimental/src/integrations/tracing/express.ts index 20081d418439..0606702d8220 100644 --- a/packages/node-experimental/src/integrations/tracing/express.ts +++ b/packages/node-experimental/src/integrations/tracing/express.ts @@ -26,6 +26,5 @@ const _expressIntegration = (() => { * Express integration * * Capture tracing data for express. - * @deprecated Use `expressIntegration()` instead. */ export const expressIntegration = defineIntegration(_expressIntegration);