@sentry/node 9.1.1-alpha.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/integrations/anr/index.js +1 -1
- package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
- package/build/cjs/integrations/tracing/express-v5/enums/AttributeNames.js +22 -0
- package/build/cjs/integrations/tracing/express-v5/enums/AttributeNames.js.map +1 -0
- package/build/cjs/integrations/tracing/express-v5/enums/ExpressLayerType.js +23 -0
- package/build/cjs/integrations/tracing/express-v5/enums/ExpressLayerType.js.map +1 -0
- package/build/cjs/integrations/tracing/express-v5/instrumentation.js +295 -0
- package/build/cjs/integrations/tracing/express-v5/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/express-v5/internal-types.js +29 -0
- package/build/cjs/integrations/tracing/express-v5/internal-types.js.map +1 -0
- package/build/cjs/integrations/tracing/express-v5/utils.js +176 -0
- package/build/cjs/integrations/tracing/express-v5/utils.js.map +1 -0
- package/build/cjs/integrations/tracing/express.js +47 -31
- package/build/cjs/integrations/tracing/express.js.map +1 -1
- package/build/cjs/integrations/tracing/index.js +1 -0
- package/build/cjs/integrations/tracing/index.js.map +1 -1
- package/build/esm/integrations/anr/index.js +1 -1
- package/build/esm/integrations/anr/worker-script.js +2 -2
- package/build/esm/integrations/local-variables/local-variables-async.js +1 -1
- package/build/esm/integrations/local-variables/worker-script.js +2 -2
- package/build/esm/integrations/tracing/express-v5/enums/AttributeNames.js +22 -0
- package/build/esm/integrations/tracing/express-v5/enums/AttributeNames.js.map +1 -0
- package/build/esm/integrations/tracing/express-v5/enums/ExpressLayerType.js +23 -0
- package/build/esm/integrations/tracing/express-v5/enums/ExpressLayerType.js.map +1 -0
- package/build/esm/integrations/tracing/express-v5/instrumentation.js +291 -0
- package/build/esm/integrations/tracing/express-v5/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/express-v5/internal-types.js +26 -0
- package/build/esm/integrations/tracing/express-v5/internal-types.js.map +1 -0
- package/build/esm/integrations/tracing/express-v5/utils.js +169 -0
- package/build/esm/integrations/tracing/express-v5/utils.js.map +1 -0
- package/build/esm/integrations/tracing/express.js +48 -33
- package/build/esm/integrations/tracing/express.js.map +1 -1
- package/build/esm/integrations/tracing/index.js +2 -1
- package/build/esm/integrations/tracing/index.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/types/integrations/tracing/express-v5/enums/AttributeNames.d.ts +5 -0
- package/build/types/integrations/tracing/express-v5/enums/AttributeNames.d.ts.map +1 -0
- package/build/types/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts +6 -0
- package/build/types/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts.map +1 -0
- package/build/types/integrations/tracing/express-v5/instrumentation.d.ts +27 -0
- package/build/types/integrations/tracing/express-v5/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/express-v5/internal-types.d.ts +38 -0
- package/build/types/integrations/tracing/express-v5/internal-types.d.ts.map +1 -0
- package/build/types/integrations/tracing/express-v5/types.d.ts +39 -0
- package/build/types/integrations/tracing/express-v5/types.d.ts.map +1 -0
- package/build/types/integrations/tracing/express-v5/utils.d.ts +51 -0
- package/build/types/integrations/tracing/express-v5/utils.d.ts.map +1 -0
- package/build/types/integrations/tracing/express.d.ts +3 -0
- package/build/types/integrations/tracing/express.d.ts.map +1 -1
- package/build/types/integrations/tracing/index.d.ts.map +1 -1
- package/build/types-ts3.8/integrations/tracing/express-v5/enums/AttributeNames.d.ts +5 -0
- package/build/types-ts3.8/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts +6 -0
- package/build/types-ts3.8/integrations/tracing/express-v5/instrumentation.d.ts +27 -0
- package/build/types-ts3.8/integrations/tracing/express-v5/internal-types.d.ts +38 -0
- package/build/types-ts3.8/integrations/tracing/express-v5/types.d.ts +39 -0
- package/build/types-ts3.8/integrations/tracing/express-v5/utils.d.ts +57 -0
- package/build/types-ts3.8/integrations/tracing/express.d.ts +3 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sources":["../../../../src/integrations/tracing/express.ts"],"sourcesContent":["import type * as http from 'node:http';\nimport { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';\nimport type { IntegrationFn } from '@sentry/core';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n captureException,\n defineIntegration,\n getDefaultIsolationScope,\n getIsolationScope,\n logger,\n spanToJSON,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\nimport { ensureIsWrapped } from '../../utils/ensureIsWrapped';\n\nconst INTEGRATION_NAME = 'Express';\n\nexport const instrumentExpress = generateInstrumentOnce(\n INTEGRATION_NAME,\n () =>\n new ExpressInstrumentation({\n requestHook(span) {\n addOriginToSpan(span, 'auto.http.otel.express');\n\n const attributes = spanToJSON(span).data;\n // this is one of: middleware, request_handler, router\n const type = attributes['express.type'];\n\n if (type) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, `${type}.express`);\n }\n\n // Also update the name, we don't need to \"middleware - \" prefix\n const name = attributes['express.name'];\n if (typeof name === 'string') {\n span.updateName(name);\n }\n },\n spanNameHook(info, defaultName) {\n if (getIsolationScope() === getDefaultIsolationScope()) {\n DEBUG_BUILD &&\n logger.warn('Isolation scope is still default isolation scope - skipping setting transactionName');\n return defaultName;\n }\n if (info.layerType === 'request_handler') {\n // type cast b/c Otel unfortunately types info.request as any :(\n const req = info.request as { method?: string };\n const method = req.method ? req.method.toUpperCase() : 'GET';\n getIsolationScope().setTransactionName(`${method} ${info.route}`);\n }\n return defaultName;\n },\n }),\n);\n\nconst _expressIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentExpress();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for [Express](https://expressjs.com/).\n *\n * If you also want to capture errors, you need to call `setupExpressErrorHandler(app)` after you set up your Express server.\n *\n * For more information, see the [express documentation](https://docs.sentry.io/platforms/javascript/guides/express/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.expressIntegration()],\n * })\n * ```\n */\nexport const expressIntegration = defineIntegration(_expressIntegration);\n\ninterface MiddlewareError extends Error {\n status?: number | string;\n statusCode?: number | string;\n status_code?: number | string;\n output?: {\n statusCode?: number | string;\n };\n}\n\ntype ExpressMiddleware = (req: http.IncomingMessage, res: http.ServerResponse, next: () => void) => void;\n\ntype ExpressErrorMiddleware = (\n error: MiddlewareError,\n req: http.IncomingMessage,\n res: http.ServerResponse,\n next: (error: MiddlewareError) => void,\n) => void;\n\ninterface ExpressHandlerOptions {\n /**\n * Callback method deciding whether error should be captured and sent to Sentry\n * @param error Captured middleware error\n */\n shouldHandleError?(this: void, error: MiddlewareError): boolean;\n}\n\n/**\n * An Express-compatible error handler.\n */\nexport function expressErrorHandler(options?: ExpressHandlerOptions): ExpressErrorMiddleware {\n return function sentryErrorMiddleware(\n error: MiddlewareError,\n request: http.IncomingMessage,\n res: http.ServerResponse,\n next: (error: MiddlewareError) => void,\n ): void {\n // Ensure we use the express-enhanced request here, instead of the plain HTTP one\n // When an error happens, the `expressRequestHandler` middleware does not run, so we set it here too\n getIsolationScope().setSDKProcessingMetadata({ request });\n\n const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;\n\n if (shouldHandleError(error)) {\n const eventId = captureException(error, { mechanism: { type: 'middleware', handled: false } });\n (res as { sentry?: string }).sentry = eventId;\n }\n\n next(error);\n };\n}\n\nfunction expressRequestHandler(): ExpressMiddleware {\n return function sentryRequestMiddleware(\n request: http.IncomingMessage,\n _res: http.ServerResponse,\n next: () => void,\n ): void {\n // Ensure we use the express-enhanced request here, instead of the plain HTTP one\n getIsolationScope().setSDKProcessingMetadata({ request });\n\n next();\n };\n}\n\n/**\n * Add an Express error handler to capture errors to Sentry.\n *\n * The error handler must be before any other middleware and after all controllers.\n *\n * @param app The Express instances\n * @param options {ExpressHandlerOptions} Configuration options for the handler\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n * const express = require(\"express\");\n *\n * const app = express();\n *\n * // Add your routes, etc.\n *\n * // Add this after all routes,\n * // but before any and other error-handling middlewares are defined\n * Sentry.setupExpressErrorHandler(app);\n *\n * app.listen(3000);\n * ```\n */\nexport function setupExpressErrorHandler(\n app: { use: (middleware: ExpressMiddleware | ExpressErrorMiddleware) => unknown },\n options?: ExpressHandlerOptions,\n): void {\n app.use(expressRequestHandler());\n app.use(expressErrorHandler(options));\n ensureIsWrapped(app.use, 'express');\n}\n\nfunction getStatusCodeFromResponse(error: MiddlewareError): number {\n const statusCode = error.status || error.statusCode || error.status_code || error.output?.statusCode;\n return statusCode ? parseInt(statusCode as string, 10) : 500;\n}\n\n/** Returns true if response code is internal server error */\nfunction defaultShouldHandleError(error: MiddlewareError): boolean {\n const status = getStatusCodeFromResponse(error);\n return status >= 500;\n}\n"],"names":[],"mappings":";;;;;;;AAiBA,MAAM,gBAAA,GAAmB,SAAS;;AAE3B,MAAM,iBAAkB,GAAE,sBAAsB;AACvD,EAAE,gBAAgB;AAClB,EAAE;AACF,IAAI,IAAI,sBAAsB,CAAC;AAC/B,MAAM,WAAW,CAAC,IAAI,EAAE;AACxB,QAAQ,eAAe,CAAC,IAAI,EAAE,wBAAwB,CAAC;;AAEvD,QAAQ,MAAM,aAAa,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI;AAChD;AACA,QAAQ,MAAM,IAAK,GAAE,UAAU,CAAC,cAAc,CAAC;;AAE/C,QAAQ,IAAI,IAAI,EAAE;AAClB,UAAU,IAAI,CAAC,YAAY,CAAC,4BAA4B,EAAE,CAAC,EAAA,IAAA,CAAA,QAAA,CAAA,CAAA;AACA;;AAEA;AACA,QAAA,MAAA,IAAA,GAAA,UAAA,CAAA,cAAA,CAAA;AACA,QAAA,IAAA,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MAAA,GAAA,yBAAA,CAAA,KAAA,CAAA;AACA,EAAA,OAAA,MAAA,IAAA,GAAA;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"express.js","sources":["../../../../src/integrations/tracing/express.ts"],"sourcesContent":["import type * as http from 'node:http';\nimport type { Span } from '@opentelemetry/api';\nimport type { ExpressRequestInfo } from '@opentelemetry/instrumentation-express';\nimport { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';\nimport type { IntegrationFn } from '@sentry/core';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n captureException,\n defineIntegration,\n getDefaultIsolationScope,\n getIsolationScope,\n logger,\n spanToJSON,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\nimport { ensureIsWrapped } from '../../utils/ensureIsWrapped';\nimport { ExpressInstrumentationV5 } from './express-v5/instrumentation';\n\nconst INTEGRATION_NAME = 'Express';\nconst INTEGRATION_NAME_V5 = 'Express-V5';\n\nfunction requestHook(span: Span): void {\n addOriginToSpan(span, 'auto.http.otel.express');\n\n const attributes = spanToJSON(span).data;\n // this is one of: middleware, request_handler, router\n const type = attributes['express.type'];\n\n if (type) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, `${type}.express`);\n }\n\n // Also update the name, we don't need to \"middleware - \" prefix\n const name = attributes['express.name'];\n if (typeof name === 'string') {\n span.updateName(name);\n }\n}\n\nfunction spanNameHook(info: ExpressRequestInfo<unknown>, defaultName: string): string {\n if (getIsolationScope() === getDefaultIsolationScope()) {\n DEBUG_BUILD && logger.warn('Isolation scope is still default isolation scope - skipping setting transactionName');\n return defaultName;\n }\n if (info.layerType === 'request_handler') {\n // type cast b/c Otel unfortunately types info.request as any :(\n const req = info.request as { method?: string };\n const method = req.method ? req.method.toUpperCase() : 'GET';\n getIsolationScope().setTransactionName(`${method} ${info.route}`);\n }\n return defaultName;\n}\n\nexport const instrumentExpress = generateInstrumentOnce(\n INTEGRATION_NAME,\n () =>\n new ExpressInstrumentation({\n requestHook: span => requestHook(span),\n spanNameHook: (info, defaultName) => spanNameHook(info, defaultName),\n }),\n);\n\nexport const instrumentExpressV5 = generateInstrumentOnce(\n INTEGRATION_NAME_V5,\n () =>\n new ExpressInstrumentationV5({\n requestHook: span => requestHook(span),\n spanNameHook: (info, defaultName) => spanNameHook(info, defaultName),\n }),\n);\n\nconst _expressIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentExpress();\n instrumentExpressV5();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for [Express](https://expressjs.com/).\n *\n * If you also want to capture errors, you need to call `setupExpressErrorHandler(app)` after you set up your Express server.\n *\n * For more information, see the [express documentation](https://docs.sentry.io/platforms/javascript/guides/express/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.expressIntegration()],\n * })\n * ```\n */\nexport const expressIntegration = defineIntegration(_expressIntegration);\n\ninterface MiddlewareError extends Error {\n status?: number | string;\n statusCode?: number | string;\n status_code?: number | string;\n output?: {\n statusCode?: number | string;\n };\n}\n\ntype ExpressMiddleware = (req: http.IncomingMessage, res: http.ServerResponse, next: () => void) => void;\n\ntype ExpressErrorMiddleware = (\n error: MiddlewareError,\n req: http.IncomingMessage,\n res: http.ServerResponse,\n next: (error: MiddlewareError) => void,\n) => void;\n\ninterface ExpressHandlerOptions {\n /**\n * Callback method deciding whether error should be captured and sent to Sentry\n * @param error Captured middleware error\n */\n shouldHandleError?(this: void, error: MiddlewareError): boolean;\n}\n\n/**\n * An Express-compatible error handler.\n */\nexport function expressErrorHandler(options?: ExpressHandlerOptions): ExpressErrorMiddleware {\n return function sentryErrorMiddleware(\n error: MiddlewareError,\n request: http.IncomingMessage,\n res: http.ServerResponse,\n next: (error: MiddlewareError) => void,\n ): void {\n // Ensure we use the express-enhanced request here, instead of the plain HTTP one\n // When an error happens, the `expressRequestHandler` middleware does not run, so we set it here too\n getIsolationScope().setSDKProcessingMetadata({ request });\n\n const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;\n\n if (shouldHandleError(error)) {\n const eventId = captureException(error, { mechanism: { type: 'middleware', handled: false } });\n (res as { sentry?: string }).sentry = eventId;\n }\n\n next(error);\n };\n}\n\nfunction expressRequestHandler(): ExpressMiddleware {\n return function sentryRequestMiddleware(\n request: http.IncomingMessage,\n _res: http.ServerResponse,\n next: () => void,\n ): void {\n // Ensure we use the express-enhanced request here, instead of the plain HTTP one\n getIsolationScope().setSDKProcessingMetadata({ request });\n\n next();\n };\n}\n\n/**\n * Add an Express error handler to capture errors to Sentry.\n *\n * The error handler must be before any other middleware and after all controllers.\n *\n * @param app The Express instances\n * @param options {ExpressHandlerOptions} Configuration options for the handler\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n * const express = require(\"express\");\n *\n * const app = express();\n *\n * // Add your routes, etc.\n *\n * // Add this after all routes,\n * // but before any and other error-handling middlewares are defined\n * Sentry.setupExpressErrorHandler(app);\n *\n * app.listen(3000);\n * ```\n */\nexport function setupExpressErrorHandler(\n app: { use: (middleware: ExpressMiddleware | ExpressErrorMiddleware) => unknown },\n options?: ExpressHandlerOptions,\n): void {\n app.use(expressRequestHandler());\n app.use(expressErrorHandler(options));\n ensureIsWrapped(app.use, 'express');\n}\n\nfunction getStatusCodeFromResponse(error: MiddlewareError): number {\n const statusCode = error.status || error.statusCode || error.status_code || error.output?.statusCode;\n return statusCode ? parseInt(statusCode as string, 10) : 500;\n}\n\n/** Returns true if response code is internal server error */\nfunction defaultShouldHandleError(error: MiddlewareError): boolean {\n const status = getStatusCodeFromResponse(error);\n return status >= 500;\n}\n"],"names":[],"mappings":";;;;;;;;AAoBA,MAAM,gBAAA,GAAmB,SAAS;AAClC,MAAM,mBAAA,GAAsB,YAAY;;AAExC,SAAS,WAAW,CAAC,IAAI,EAAc;AACvC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,GAAA;AACA,EAAA,OAAA,SAAA,uBAAA;AACA,IAAA,OAAA;AACA,IAAA,IAAA;AACA,IAAA,IAAA;AACA,IAAA;AACA;AACA,IAAA,iBAAA,EAAA,CAAA,wBAAA,CAAA,EAAA,OAAA,EAAA,CAAA;;AAEA,IAAA,IAAA,EAAA;AACA,GAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA,wBAAA;AACA,EAAA,GAAA;AACA,EAAA,OAAA;AACA,EAAA;AACA,EAAA,GAAA,CAAA,GAAA,CAAA,qBAAA,EAAA,CAAA;AACA,EAAA,GAAA,CAAA,GAAA,CAAA,mBAAA,CAAA,OAAA,CAAA,CAAA;AACA,EAAA,eAAA,CAAA,GAAA,CAAA,GAAA,EAAA,SAAA,CAAA;AACA;;AAEA,SAAA,yBAAA,CAAA,KAAA,EAAA;AACA,EAAA,MAAA,UAAA,GAAA,KAAA,CAAA,MAAA,IAAA,KAAA,CAAA,UAAA,IAAA,KAAA,CAAA,WAAA,IAAA,KAAA,CAAA,MAAA,EAAA,UAAA;AACA,EAAA,OAAA,UAAA,GAAA,QAAA,CAAA,UAAA,GAAA,EAAA,CAAA,GAAA,GAAA;AACA;;AAEA;AACA,SAAA,wBAAA,CAAA,KAAA,EAAA;AACA,EAAA,MAAA,MAAA,GAAA,yBAAA,CAAA,KAAA,CAAA;AACA,EAAA,OAAA,MAAA,IAAA,GAAA;AACA;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { instrumentOtelHttp } from '../http/index.js';
|
|
2
2
|
import { amqplibIntegration, instrumentAmqplib } from './amqplib.js';
|
|
3
3
|
import { connectIntegration, instrumentConnect } from './connect.js';
|
|
4
|
-
import { expressIntegration, instrumentExpress } from './express.js';
|
|
4
|
+
import { expressIntegration, instrumentExpress, instrumentExpressV5 } from './express.js';
|
|
5
5
|
import { fastifyIntegration, instrumentFastify } from './fastify.js';
|
|
6
6
|
import { genericPoolIntegration, instrumentGenericPool } from './genericPool.js';
|
|
7
7
|
import { graphqlIntegration, instrumentGraphql } from './graphql.js';
|
|
@@ -56,6 +56,7 @@ function getOpenTelemetryInstrumentationToPreload() {
|
|
|
56
56
|
return [
|
|
57
57
|
instrumentOtelHttp,
|
|
58
58
|
instrumentExpress,
|
|
59
|
+
instrumentExpressV5,
|
|
59
60
|
instrumentConnect,
|
|
60
61
|
instrumentFastify,
|
|
61
62
|
instrumentHapi,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/integrations/tracing/index.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport { instrumentOtelHttp } from '../http';\n\nimport { amqplibIntegration, instrumentAmqplib } from './amqplib';\nimport { connectIntegration, instrumentConnect } from './connect';\nimport { expressIntegration, instrumentExpress } from './express';\nimport { fastifyIntegration, instrumentFastify } from './fastify';\nimport { genericPoolIntegration, instrumentGenericPool } from './genericPool';\nimport { graphqlIntegration, instrumentGraphql } from './graphql';\nimport { hapiIntegration, instrumentHapi } from './hapi';\nimport { instrumentKafka, kafkaIntegration } from './kafka';\nimport { instrumentKoa, koaIntegration } from './koa';\nimport { instrumentLruMemoizer, lruMemoizerIntegration } from './lrumemoizer';\nimport { instrumentMongo, mongoIntegration } from './mongo';\nimport { instrumentMongoose, mongooseIntegration } from './mongoose';\nimport { instrumentMysql, mysqlIntegration } from './mysql';\nimport { instrumentMysql2, mysql2Integration } from './mysql2';\nimport { instrumentPostgres, postgresIntegration } from './postgres';\nimport { instrumentRedis, redisIntegration } from './redis';\nimport { instrumentTedious, tediousIntegration } from './tedious';\nimport { instrumentVercelAi, vercelAIIntegration } from './vercelai';\n\n/**\n * With OTEL, all performance integrations will be added, as OTEL only initializes them when the patched package is actually required.\n */\nexport function getAutoPerformanceIntegrations(): Integration[] {\n return [\n expressIntegration(),\n fastifyIntegration(),\n graphqlIntegration(),\n mongoIntegration(),\n mongooseIntegration(),\n mysqlIntegration(),\n mysql2Integration(),\n redisIntegration(),\n postgresIntegration(),\n // For now, we do not include prisma by default because it has ESM issues\n // See https://github.com/prisma/prisma/issues/23410\n // TODO v8: Figure out a better solution for this, maybe only disable in ESM mode?\n // prismaIntegration(),\n hapiIntegration(),\n koaIntegration(),\n connectIntegration(),\n tediousIntegration(),\n genericPoolIntegration(),\n kafkaIntegration(),\n amqplibIntegration(),\n lruMemoizerIntegration(),\n vercelAIIntegration(),\n ];\n}\n\n/**\n * Get a list of methods to instrument OTEL, when preload instrumentation.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getOpenTelemetryInstrumentationToPreload(): (((options?: any) => void) & { id: string })[] {\n return [\n instrumentOtelHttp,\n instrumentExpress,\n instrumentConnect,\n instrumentFastify,\n instrumentHapi,\n instrumentKafka,\n instrumentKoa,\n instrumentLruMemoizer,\n instrumentMongo,\n instrumentMongoose,\n instrumentMysql,\n instrumentMysql2,\n instrumentPostgres,\n instrumentHapi,\n instrumentGraphql,\n instrumentRedis,\n instrumentTedious,\n instrumentGenericPool,\n instrumentAmqplib,\n instrumentVercelAi,\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA;AACA;AACA;AACO,SAAS,8BAA8B,GAAkB;AAChE,EAAE,OAAO;AACT,IAAI,kBAAkB,EAAE;AACxB,IAAI,kBAAkB,EAAE;AACxB,IAAI,kBAAkB,EAAE;AACxB,IAAI,gBAAgB,EAAE;AACtB,IAAI,mBAAmB,EAAE;AACzB,IAAI,gBAAgB,EAAE;AACtB,IAAI,iBAAiB,EAAE;AACvB,IAAI,gBAAgB,EAAE;AACtB,IAAI,mBAAmB,EAAE;AACzB;AACA;AACA;AACA;AACA,IAAI,eAAe,EAAE;AACrB,IAAI,cAAc,EAAE;AACpB,IAAI,kBAAkB,EAAE;AACxB,IAAI,kBAAkB,EAAE;AACxB,IAAI,sBAAsB,EAAE;AAC5B,IAAI,gBAAgB,EAAE;AACtB,IAAI,kBAAkB,EAAE;AACxB,IAAI,sBAAsB,EAAE;AAC5B,IAAI,mBAAmB,EAAE;AACzB,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACO,SAAS,wCAAwC,GAAmD;AAC3G,EAAE,OAAO;AACT,IAAI,kBAAkB;AACtB,IAAI,iBAAiB;AACrB,IAAI,iBAAiB;AACrB,IAAI,iBAAiB;AACrB,IAAI,cAAc;AAClB,IAAI,eAAe;AACnB,IAAI,aAAa;AACjB,IAAI,qBAAqB;AACzB,IAAI,eAAe;AACnB,IAAI,kBAAkB;AACtB,IAAI,eAAe;AACnB,IAAI,gBAAgB;AACpB,IAAI,kBAAkB;AACtB,IAAI,cAAc;AAClB,IAAI,iBAAiB;AACrB,IAAI,eAAe;AACnB,IAAI,iBAAiB;AACrB,IAAI,qBAAqB;AACzB,IAAI,iBAAiB;AACrB,IAAI,kBAAkB;AACtB,GAAG;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/integrations/tracing/index.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport { instrumentOtelHttp } from '../http';\n\nimport { amqplibIntegration, instrumentAmqplib } from './amqplib';\nimport { connectIntegration, instrumentConnect } from './connect';\nimport { expressIntegration, instrumentExpress, instrumentExpressV5 } from './express';\nimport { fastifyIntegration, instrumentFastify } from './fastify';\nimport { genericPoolIntegration, instrumentGenericPool } from './genericPool';\nimport { graphqlIntegration, instrumentGraphql } from './graphql';\nimport { hapiIntegration, instrumentHapi } from './hapi';\nimport { instrumentKafka, kafkaIntegration } from './kafka';\nimport { instrumentKoa, koaIntegration } from './koa';\nimport { instrumentLruMemoizer, lruMemoizerIntegration } from './lrumemoizer';\nimport { instrumentMongo, mongoIntegration } from './mongo';\nimport { instrumentMongoose, mongooseIntegration } from './mongoose';\nimport { instrumentMysql, mysqlIntegration } from './mysql';\nimport { instrumentMysql2, mysql2Integration } from './mysql2';\nimport { instrumentPostgres, postgresIntegration } from './postgres';\nimport { instrumentRedis, redisIntegration } from './redis';\nimport { instrumentTedious, tediousIntegration } from './tedious';\nimport { instrumentVercelAi, vercelAIIntegration } from './vercelai';\n\n/**\n * With OTEL, all performance integrations will be added, as OTEL only initializes them when the patched package is actually required.\n */\nexport function getAutoPerformanceIntegrations(): Integration[] {\n return [\n expressIntegration(),\n fastifyIntegration(),\n graphqlIntegration(),\n mongoIntegration(),\n mongooseIntegration(),\n mysqlIntegration(),\n mysql2Integration(),\n redisIntegration(),\n postgresIntegration(),\n // For now, we do not include prisma by default because it has ESM issues\n // See https://github.com/prisma/prisma/issues/23410\n // TODO v8: Figure out a better solution for this, maybe only disable in ESM mode?\n // prismaIntegration(),\n hapiIntegration(),\n koaIntegration(),\n connectIntegration(),\n tediousIntegration(),\n genericPoolIntegration(),\n kafkaIntegration(),\n amqplibIntegration(),\n lruMemoizerIntegration(),\n vercelAIIntegration(),\n ];\n}\n\n/**\n * Get a list of methods to instrument OTEL, when preload instrumentation.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getOpenTelemetryInstrumentationToPreload(): (((options?: any) => void) & { id: string })[] {\n return [\n instrumentOtelHttp,\n instrumentExpress,\n instrumentExpressV5,\n instrumentConnect,\n instrumentFastify,\n instrumentHapi,\n instrumentKafka,\n instrumentKoa,\n instrumentLruMemoizer,\n instrumentMongo,\n instrumentMongoose,\n instrumentMysql,\n instrumentMysql2,\n instrumentPostgres,\n instrumentHapi,\n instrumentGraphql,\n instrumentRedis,\n instrumentTedious,\n instrumentGenericPool,\n instrumentAmqplib,\n instrumentVercelAi,\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA;AACA;AACA;AACO,SAAS,8BAA8B,GAAkB;AAChE,EAAE,OAAO;AACT,IAAI,kBAAkB,EAAE;AACxB,IAAI,kBAAkB,EAAE;AACxB,IAAI,kBAAkB,EAAE;AACxB,IAAI,gBAAgB,EAAE;AACtB,IAAI,mBAAmB,EAAE;AACzB,IAAI,gBAAgB,EAAE;AACtB,IAAI,iBAAiB,EAAE;AACvB,IAAI,gBAAgB,EAAE;AACtB,IAAI,mBAAmB,EAAE;AACzB;AACA;AACA;AACA;AACA,IAAI,eAAe,EAAE;AACrB,IAAI,cAAc,EAAE;AACpB,IAAI,kBAAkB,EAAE;AACxB,IAAI,kBAAkB,EAAE;AACxB,IAAI,sBAAsB,EAAE;AAC5B,IAAI,gBAAgB,EAAE;AACtB,IAAI,kBAAkB,EAAE;AACxB,IAAI,sBAAsB,EAAE;AAC5B,IAAI,mBAAmB,EAAE;AACzB,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACO,SAAS,wCAAwC,GAAmD;AAC3G,EAAE,OAAO;AACT,IAAI,kBAAkB;AACtB,IAAI,iBAAiB;AACrB,IAAI,mBAAmB;AACvB,IAAI,iBAAiB;AACrB,IAAI,iBAAiB;AACrB,IAAI,cAAc;AAClB,IAAI,eAAe;AACnB,IAAI,aAAa;AACjB,IAAI,qBAAqB;AACzB,IAAI,eAAe;AACnB,IAAI,kBAAkB;AACtB,IAAI,eAAe;AACnB,IAAI,gBAAgB;AACpB,IAAI,kBAAkB;AACtB,IAAI,cAAc;AAClB,IAAI,iBAAiB;AACrB,IAAI,eAAe;AACnB,IAAI,iBAAiB;AACrB,IAAI,qBAAqB;AACzB,IAAI,iBAAiB;AACrB,IAAI,kBAAkB;AACtB,GAAG;AACH;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"9.
|
|
1
|
+
{"type":"module","version":"9.2.0","sideEffects":false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttributeNames.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/tracing/express-v5/enums/AttributeNames.ts"],"names":[],"mappings":"AAeA,oBAAY,cAAc;IACxB,YAAY,iBAAiB;IAC7B,YAAY,iBAAiB;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpressLayerType.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/tracing/express-v5/enums/ExpressLayerType.ts"],"names":[],"mappings":"AAeA,oBAAY,gBAAgB;IAC1B,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,eAAe,oBAAoB;CACpC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
|
+
import type { ExpressInstrumentationConfig, ExpressRequestInfo } from './types';
|
|
3
|
+
export declare const PACKAGE_VERSION = "0.1.0";
|
|
4
|
+
export declare const PACKAGE_NAME = "@sentry/instrumentation-express-v5";
|
|
5
|
+
/** Express instrumentation for OpenTelemetry */
|
|
6
|
+
export declare class ExpressInstrumentationV5 extends InstrumentationBase<ExpressInstrumentationConfig> {
|
|
7
|
+
constructor(config?: ExpressInstrumentationConfig);
|
|
8
|
+
init(): InstrumentationNodeModuleDefinition[];
|
|
9
|
+
private _setup;
|
|
10
|
+
private _tearDown;
|
|
11
|
+
/**
|
|
12
|
+
* Get the patch for Router.route function
|
|
13
|
+
*/
|
|
14
|
+
private _getRoutePatch;
|
|
15
|
+
/**
|
|
16
|
+
* Get the patch for Router.use function
|
|
17
|
+
*/
|
|
18
|
+
private _getRouterUsePatch;
|
|
19
|
+
/**
|
|
20
|
+
* Get the patch for Application.use function
|
|
21
|
+
*/
|
|
22
|
+
private _getAppUsePatch;
|
|
23
|
+
/** Patch each express layer to create span and propagate context */
|
|
24
|
+
private _applyPatch;
|
|
25
|
+
_getSpanName(info: ExpressRequestInfo, defaultName: string): string;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/express-v5/instrumentation.ts"],"names":[],"mappings":"AA8BA,OAAO,EACL,mBAAmB,EACnB,mCAAmC,EAGpC,MAAM,gCAAgC,CAAC;AAOxC,OAAO,KAAK,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGhF,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,YAAY,uCAAuC,CAAC;AAEjE,gDAAgD;AAChD,qBAAa,wBAAyB,SAAQ,mBAAmB,CAAC,4BAA4B,CAAC;gBACjF,MAAM,GAAE,4BAAiC;IAIrD,IAAI;IAWJ,OAAO,CAAC,MAAM;IAoBd,OAAO,CAAC,SAAS;IAQjB;;OAEG;IACH,OAAO,CAAC,cAAc;IAYtB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAY1B;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB,oEAAoE;IACpE,OAAO,CAAC,WAAW;IAiKnB,YAAY,CAAC,IAAI,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM;CAc3D"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Request } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* This symbol is used to mark express layer as being already instrumented
|
|
4
|
+
* since its possible to use a given layer multiple times (ex: middlewares)
|
|
5
|
+
*/
|
|
6
|
+
export declare const kLayerPatched: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* This const define where on the `request` object the Instrumentation will mount the
|
|
9
|
+
* current stack of express layer.
|
|
10
|
+
*
|
|
11
|
+
* It is necessary because express doesn't store the different layers
|
|
12
|
+
* (ie: middleware, router etc) that it called to get to the current layer.
|
|
13
|
+
* Given that, the only way to know the route of a given layer is to
|
|
14
|
+
* store the path of where each previous layer has been mounted.
|
|
15
|
+
*
|
|
16
|
+
* ex: bodyParser > auth middleware > /users router > get /:id
|
|
17
|
+
* in this case the stack would be: ["/users", "/:id"]
|
|
18
|
+
*
|
|
19
|
+
* ex2: bodyParser > /api router > /v1 router > /users router > get /:id
|
|
20
|
+
* stack: ["/api", "/v1", "/users", ":id"]
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare const _LAYERS_STORE_PROPERTY = "__ot_middlewares";
|
|
24
|
+
export type PatchedRequest = {
|
|
25
|
+
[_LAYERS_STORE_PROPERTY]?: string[];
|
|
26
|
+
} & Request;
|
|
27
|
+
export type PathParams = string | RegExp | Array<string | RegExp>;
|
|
28
|
+
export type ExpressRouter = {
|
|
29
|
+
stack: ExpressLayer[];
|
|
30
|
+
};
|
|
31
|
+
export type ExpressLayer = {
|
|
32
|
+
handle: Function & Record<string, any>;
|
|
33
|
+
[kLayerPatched]?: boolean;
|
|
34
|
+
name: string;
|
|
35
|
+
path: string;
|
|
36
|
+
route?: ExpressLayer;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=internal-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-types.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/express-v5/internal-types.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,OAAO,MAAwC,CAAC;AAE5E;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,sBAAsB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;CACrC,GAAG,OAAO,CAAC;AACZ,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;AAGlE,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB,CAAC;AAGF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC,aAAa,CAAC,CAAC,EAAE,OAAO,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Span } from '@opentelemetry/api';
|
|
2
|
+
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
3
|
+
import type { ExpressLayerType } from './enums/ExpressLayerType';
|
|
4
|
+
export type LayerPathSegment = string | RegExp | number;
|
|
5
|
+
export type IgnoreMatcher = string | RegExp | ((name: string) => boolean);
|
|
6
|
+
export type ExpressRequestInfo<T = any> = {
|
|
7
|
+
/** An express request object */
|
|
8
|
+
request: T;
|
|
9
|
+
route: string;
|
|
10
|
+
layerType: ExpressLayerType;
|
|
11
|
+
};
|
|
12
|
+
export type SpanNameHook = (info: ExpressRequestInfo,
|
|
13
|
+
/**
|
|
14
|
+
* If no decision is taken based on RequestInfo, the default name
|
|
15
|
+
* supplied by the instrumentation can be used instead.
|
|
16
|
+
*/
|
|
17
|
+
defaultName: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Function that can be used to add custom attributes to the current span or the root span on
|
|
20
|
+
* a Express request
|
|
21
|
+
* @param span - The Express middleware layer span.
|
|
22
|
+
* @param info - An instance of ExpressRequestInfo that contains info about the request such as the route, and the layer type.
|
|
23
|
+
*/
|
|
24
|
+
export interface ExpressRequestCustomAttributeFunction {
|
|
25
|
+
(span: Span, info: ExpressRequestInfo): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Options available for the Express Instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express#express-instrumentation-options))
|
|
29
|
+
*/
|
|
30
|
+
export interface ExpressInstrumentationConfig extends InstrumentationConfig {
|
|
31
|
+
/** Ignore specific based on their name */
|
|
32
|
+
ignoreLayers?: IgnoreMatcher[];
|
|
33
|
+
/** Ignore specific layers based on their type */
|
|
34
|
+
ignoreLayersType?: ExpressLayerType[];
|
|
35
|
+
spanNameHook?: SpanNameHook;
|
|
36
|
+
/** Function for adding custom attributes on Express request */
|
|
37
|
+
requestHook?: ExpressRequestCustomAttributeFunction;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/express-v5/types.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;AAE1E,MAAM,MAAM,kBAAkB,CAAC,CAAC,GAAG,GAAG,IAAI;IACxC,gCAAgC;IAChC,OAAO,EAAE,CAAC,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,gBAAgB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,CACzB,IAAI,EAAE,kBAAkB;AACxB;;;GAGG;AACH,WAAW,EAAE,MAAM,KAChB,MAAM,CAAC;AAEZ;;;;;GAKG;AACH,MAAM,WAAW,qCAAqC;IACpD,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,qBAAqB;IACzE,0CAA0C;IAC1C,YAAY,CAAC,EAAE,aAAa,EAAE,CAAC;IAC/B,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACtC,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B,+DAA+D;IAC/D,WAAW,CAAC,EAAE,qCAAqC,CAAC;CACrD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Attributes } from '@opentelemetry/api';
|
|
2
|
+
import { ExpressLayerType } from './enums/ExpressLayerType';
|
|
3
|
+
import type { ExpressLayer, PatchedRequest } from './internal-types';
|
|
4
|
+
import type { ExpressInstrumentationConfig, LayerPathSegment } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Store layers path in the request to be able to construct route later
|
|
7
|
+
* @param request The request where
|
|
8
|
+
* @param [value] the value to push into the array
|
|
9
|
+
*/
|
|
10
|
+
export declare const storeLayerPath: (request: PatchedRequest, value?: string) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Recursively search the router path from layer stack
|
|
13
|
+
* @param path The path to reconstruct
|
|
14
|
+
* @param layer The layer to reconstruct from
|
|
15
|
+
* @returns The reconstructed path
|
|
16
|
+
*/
|
|
17
|
+
export declare const getRouterPath: (path: string, layer: ExpressLayer) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Parse express layer context to retrieve a name and attributes.
|
|
20
|
+
* @param route The route of the layer
|
|
21
|
+
* @param layer Express layer
|
|
22
|
+
* @param [layerPath] if present, the path on which the layer has been mounted
|
|
23
|
+
*/
|
|
24
|
+
export declare const getLayerMetadata: (route: string, layer: ExpressLayer, layerPath?: string) => {
|
|
25
|
+
attributes: Attributes;
|
|
26
|
+
name: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Check whether the given request is ignored by configuration
|
|
30
|
+
* It will not re-throw exceptions from `list` provided by the client
|
|
31
|
+
* @param constant e.g URL of request
|
|
32
|
+
* @param [list] List of ignore patterns
|
|
33
|
+
* @param [onException] callback for doing something when an exception has
|
|
34
|
+
* occurred
|
|
35
|
+
*/
|
|
36
|
+
export declare const isLayerIgnored: (name: string, type: ExpressLayerType, config?: ExpressInstrumentationConfig) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Converts a user-provided error value into an error and error message pair
|
|
39
|
+
*
|
|
40
|
+
* @param error - User-provided error value
|
|
41
|
+
* @returns Both an Error or string representation of the value and an error message
|
|
42
|
+
*/
|
|
43
|
+
export declare const asErrorAndMessage: (error: unknown) => [error: string | Error, message: string];
|
|
44
|
+
/**
|
|
45
|
+
* Extracts the layer path from the route arguments
|
|
46
|
+
*
|
|
47
|
+
* @param args - Arguments of the route
|
|
48
|
+
* @returns The layer path
|
|
49
|
+
*/
|
|
50
|
+
export declare const getLayerPath: (args: [LayerPathSegment | LayerPathSegment[], ...unknown[]]) => string | undefined;
|
|
51
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/express-v5/utils.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,KAAK,EAAE,4BAA4B,EAAiB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE7F;;;;GAIG;AACH,eAAO,MAAM,cAAc,YAAa,cAAc,UAAU,MAAM,KAAG,IASxE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAU,MAAM,SAAS,YAAY,KAAG,MAYjE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UACpB,MAAM,SACN,YAAY,cACP,MAAM,KACjB;IACD,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,MAAM,CAAC;CA8Bd,CAAC;AAoBF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,SACnB,MAAM,QACN,gBAAgB,WACb,4BAA4B,KACpC,OAgBF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,UAAW,OAAO,6CACkC,CAAC;AAEnF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,SAAU,CAAC,gBAAgB,GAAG,gBAAgB,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,KAAG,MAAM,GAAG,SAQnG,CAAC"}
|
|
@@ -3,6 +3,9 @@ import type * as http from 'node:http';
|
|
|
3
3
|
export declare const instrumentExpress: ((options?: unknown) => void) & {
|
|
4
4
|
id: string;
|
|
5
5
|
};
|
|
6
|
+
export declare const instrumentExpressV5: ((options?: unknown) => void) & {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
6
9
|
/**
|
|
7
10
|
* Adds Sentry tracing instrumentation for [Express](https://expressjs.com/).
|
|
8
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/express.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/express.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AAuDvC,eAAO,MAAM,iBAAiB;;CAO7B,CAAC;AAEF,eAAO,MAAM,mBAAmB;;CAO/B,CAAC;AAYF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB,0CAAyC,CAAC;AAEzE,UAAU,eAAgB,SAAQ,KAAK;IACrC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,MAAM,CAAC,EAAE;QACP,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KAC9B,CAAC;CACH;AAED,KAAK,iBAAiB,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;AAEzG,KAAK,sBAAsB,GAAG,CAC5B,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,IAAI,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,KACnC,IAAI,CAAC;AAEV,UAAU,qBAAqB;IAC7B;;;OAGG;IACH,iBAAiB,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC;CACjE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,sBAAsB,CAoB3F;AAeD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE;IAAE,GAAG,EAAE,CAAC,UAAU,EAAE,iBAAiB,GAAG,sBAAsB,KAAK,OAAO,CAAA;CAAE,EACjF,OAAO,CAAC,EAAE,qBAAqB,GAC9B,IAAI,CAIN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAsBhD;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,WAAW,EAAE,CAyB9D;AAED;;GAEG;AAEH,wBAAgB,wCAAwC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAsBhD;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,WAAW,EAAE,CAyB9D;AAED;;GAEG;AAEH,wBAAgB,wCAAwC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,CAwBzG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { ExpressInstrumentationConfig, ExpressRequestInfo } from './types';
|
|
3
|
+
export declare const PACKAGE_VERSION = "0.1.0";
|
|
4
|
+
export declare const PACKAGE_NAME = "@sentry/instrumentation-express-v5";
|
|
5
|
+
/** Express instrumentation for OpenTelemetry */
|
|
6
|
+
export declare class ExpressInstrumentationV5 extends InstrumentationBase<ExpressInstrumentationConfig> {
|
|
7
|
+
constructor(config?: ExpressInstrumentationConfig);
|
|
8
|
+
init(): InstrumentationNodeModuleDefinition[];
|
|
9
|
+
private _setup;
|
|
10
|
+
private _tearDown;
|
|
11
|
+
/**
|
|
12
|
+
* Get the patch for Router.route function
|
|
13
|
+
*/
|
|
14
|
+
private _getRoutePatch;
|
|
15
|
+
/**
|
|
16
|
+
* Get the patch for Router.use function
|
|
17
|
+
*/
|
|
18
|
+
private _getRouterUsePatch;
|
|
19
|
+
/**
|
|
20
|
+
* Get the patch for Application.use function
|
|
21
|
+
*/
|
|
22
|
+
private _getAppUsePatch;
|
|
23
|
+
/** Patch each express layer to create span and propagate context */
|
|
24
|
+
private _applyPatch;
|
|
25
|
+
_getSpanName(info: ExpressRequestInfo, defaultName: string): string;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Request } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* This symbol is used to mark express layer as being already instrumented
|
|
4
|
+
* since its possible to use a given layer multiple times (ex: middlewares)
|
|
5
|
+
*/
|
|
6
|
+
export declare const kLayerPatched: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* This const define where on the `request` object the Instrumentation will mount the
|
|
9
|
+
* current stack of express layer.
|
|
10
|
+
*
|
|
11
|
+
* It is necessary because express doesn't store the different layers
|
|
12
|
+
* (ie: middleware, router etc) that it called to get to the current layer.
|
|
13
|
+
* Given that, the only way to know the route of a given layer is to
|
|
14
|
+
* store the path of where each previous layer has been mounted.
|
|
15
|
+
*
|
|
16
|
+
* ex: bodyParser > auth middleware > /users router > get /:id
|
|
17
|
+
* in this case the stack would be: ["/users", "/:id"]
|
|
18
|
+
*
|
|
19
|
+
* ex2: bodyParser > /api router > /v1 router > /users router > get /:id
|
|
20
|
+
* stack: ["/api", "/v1", "/users", ":id"]
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare const _LAYERS_STORE_PROPERTY = "__ot_middlewares";
|
|
24
|
+
export type PatchedRequest = {
|
|
25
|
+
[_LAYERS_STORE_PROPERTY]?: string[];
|
|
26
|
+
} & Request;
|
|
27
|
+
export type PathParams = string | RegExp | Array<string | RegExp>;
|
|
28
|
+
export type ExpressRouter = {
|
|
29
|
+
stack: ExpressLayer[];
|
|
30
|
+
};
|
|
31
|
+
export type ExpressLayer = {
|
|
32
|
+
handle: Function & Record<string, any>;
|
|
33
|
+
[kLayerPatched]?: boolean;
|
|
34
|
+
name: string;
|
|
35
|
+
path: string;
|
|
36
|
+
route?: ExpressLayer;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=internal-types.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Span } from '@opentelemetry/api';
|
|
2
|
+
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
3
|
+
import { ExpressLayerType } from './enums/ExpressLayerType';
|
|
4
|
+
export type LayerPathSegment = string | RegExp | number;
|
|
5
|
+
export type IgnoreMatcher = string | RegExp | ((name: string) => boolean);
|
|
6
|
+
export type ExpressRequestInfo<T = any> = {
|
|
7
|
+
/** An express request object */
|
|
8
|
+
request: T;
|
|
9
|
+
route: string;
|
|
10
|
+
layerType: ExpressLayerType;
|
|
11
|
+
};
|
|
12
|
+
export type SpanNameHook = (info: ExpressRequestInfo,
|
|
13
|
+
/**
|
|
14
|
+
* If no decision is taken based on RequestInfo, the default name
|
|
15
|
+
* supplied by the instrumentation can be used instead.
|
|
16
|
+
*/
|
|
17
|
+
defaultName: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Function that can be used to add custom attributes to the current span or the root span on
|
|
20
|
+
* a Express request
|
|
21
|
+
* @param span - The Express middleware layer span.
|
|
22
|
+
* @param info - An instance of ExpressRequestInfo that contains info about the request such as the route, and the layer type.
|
|
23
|
+
*/
|
|
24
|
+
export interface ExpressRequestCustomAttributeFunction {
|
|
25
|
+
(span: Span, info: ExpressRequestInfo): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Options available for the Express Instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express#express-instrumentation-options))
|
|
29
|
+
*/
|
|
30
|
+
export interface ExpressInstrumentationConfig extends InstrumentationConfig {
|
|
31
|
+
/** Ignore specific based on their name */
|
|
32
|
+
ignoreLayers?: IgnoreMatcher[];
|
|
33
|
+
/** Ignore specific layers based on their type */
|
|
34
|
+
ignoreLayersType?: ExpressLayerType[];
|
|
35
|
+
spanNameHook?: SpanNameHook;
|
|
36
|
+
/** Function for adding custom attributes on Express request */
|
|
37
|
+
requestHook?: ExpressRequestCustomAttributeFunction;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Attributes } from '@opentelemetry/api';
|
|
2
|
+
import { ExpressLayerType } from './enums/ExpressLayerType';
|
|
3
|
+
import { ExpressLayer, PatchedRequest } from './internal-types';
|
|
4
|
+
import { ExpressInstrumentationConfig, LayerPathSegment } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Store layers path in the request to be able to construct route later
|
|
7
|
+
* @param request The request where
|
|
8
|
+
* @param [value] the value to push into the array
|
|
9
|
+
*/
|
|
10
|
+
export declare const storeLayerPath: (request: PatchedRequest, value?: string) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Recursively search the router path from layer stack
|
|
13
|
+
* @param path The path to reconstruct
|
|
14
|
+
* @param layer The layer to reconstruct from
|
|
15
|
+
* @returns The reconstructed path
|
|
16
|
+
*/
|
|
17
|
+
export declare const getRouterPath: (path: string, layer: ExpressLayer) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Parse express layer context to retrieve a name and attributes.
|
|
20
|
+
* @param route The route of the layer
|
|
21
|
+
* @param layer Express layer
|
|
22
|
+
* @param [layerPath] if present, the path on which the layer has been mounted
|
|
23
|
+
*/
|
|
24
|
+
export declare const getLayerMetadata: (route: string, layer: ExpressLayer, layerPath?: string) => {
|
|
25
|
+
attributes: Attributes;
|
|
26
|
+
name: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Check whether the given request is ignored by configuration
|
|
30
|
+
* It will not re-throw exceptions from `list` provided by the client
|
|
31
|
+
* @param constant e.g URL of request
|
|
32
|
+
* @param [list] List of ignore patterns
|
|
33
|
+
* @param [onException] callback for doing something when an exception has
|
|
34
|
+
* occurred
|
|
35
|
+
*/
|
|
36
|
+
export declare const isLayerIgnored: (name: string, type: ExpressLayerType, config?: ExpressInstrumentationConfig) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Converts a user-provided error value into an error and error message pair
|
|
39
|
+
*
|
|
40
|
+
* @param error - User-provided error value
|
|
41
|
+
* @returns Both an Error or string representation of the value and an error message
|
|
42
|
+
*/
|
|
43
|
+
export declare const asErrorAndMessage: (error: unknown) => [
|
|
44
|
+
/*error*/ string | Error,
|
|
45
|
+
/*message*/ string
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* Extracts the layer path from the route arguments
|
|
49
|
+
*
|
|
50
|
+
* @param args - Arguments of the route
|
|
51
|
+
* @returns The layer path
|
|
52
|
+
*/
|
|
53
|
+
export declare const getLayerPath: (args: [
|
|
54
|
+
LayerPathSegment | LayerPathSegment[],
|
|
55
|
+
...unknown[]
|
|
56
|
+
]) => string | undefined;
|
|
57
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -3,6 +3,9 @@ import * as http from 'node:http';
|
|
|
3
3
|
export declare const instrumentExpress: ((options?: unknown) => void) & {
|
|
4
4
|
id: string;
|
|
5
5
|
};
|
|
6
|
+
export declare const instrumentExpressV5: ((options?: unknown) => void) & {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
6
9
|
/**
|
|
7
10
|
* Adds Sentry tracing instrumentation for [Express](https://expressjs.com/).
|
|
8
11
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/node",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "Sentry Node SDK using OpenTelemetry for performance instrumentation",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/node",
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
"@opentelemetry/sdk-trace-base": "^1.30.1",
|
|
97
97
|
"@opentelemetry/semantic-conventions": "^1.28.0",
|
|
98
98
|
"@prisma/instrumentation": "6.2.1",
|
|
99
|
-
"@sentry/core": "9.
|
|
100
|
-
"@sentry/opentelemetry": "9.
|
|
99
|
+
"@sentry/core": "9.2.0",
|
|
100
|
+
"@sentry/opentelemetry": "9.2.0",
|
|
101
101
|
"import-in-the-middle": "^1.12.0"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|