@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.
Files changed (58) hide show
  1. package/build/cjs/integrations/anr/index.js +1 -1
  2. package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
  3. package/build/cjs/integrations/tracing/express-v5/enums/AttributeNames.js +22 -0
  4. package/build/cjs/integrations/tracing/express-v5/enums/AttributeNames.js.map +1 -0
  5. package/build/cjs/integrations/tracing/express-v5/enums/ExpressLayerType.js +23 -0
  6. package/build/cjs/integrations/tracing/express-v5/enums/ExpressLayerType.js.map +1 -0
  7. package/build/cjs/integrations/tracing/express-v5/instrumentation.js +295 -0
  8. package/build/cjs/integrations/tracing/express-v5/instrumentation.js.map +1 -0
  9. package/build/cjs/integrations/tracing/express-v5/internal-types.js +29 -0
  10. package/build/cjs/integrations/tracing/express-v5/internal-types.js.map +1 -0
  11. package/build/cjs/integrations/tracing/express-v5/utils.js +176 -0
  12. package/build/cjs/integrations/tracing/express-v5/utils.js.map +1 -0
  13. package/build/cjs/integrations/tracing/express.js +47 -31
  14. package/build/cjs/integrations/tracing/express.js.map +1 -1
  15. package/build/cjs/integrations/tracing/index.js +1 -0
  16. package/build/cjs/integrations/tracing/index.js.map +1 -1
  17. package/build/esm/integrations/anr/index.js +1 -1
  18. package/build/esm/integrations/anr/worker-script.js +2 -2
  19. package/build/esm/integrations/local-variables/local-variables-async.js +1 -1
  20. package/build/esm/integrations/local-variables/worker-script.js +2 -2
  21. package/build/esm/integrations/tracing/express-v5/enums/AttributeNames.js +22 -0
  22. package/build/esm/integrations/tracing/express-v5/enums/AttributeNames.js.map +1 -0
  23. package/build/esm/integrations/tracing/express-v5/enums/ExpressLayerType.js +23 -0
  24. package/build/esm/integrations/tracing/express-v5/enums/ExpressLayerType.js.map +1 -0
  25. package/build/esm/integrations/tracing/express-v5/instrumentation.js +291 -0
  26. package/build/esm/integrations/tracing/express-v5/instrumentation.js.map +1 -0
  27. package/build/esm/integrations/tracing/express-v5/internal-types.js +26 -0
  28. package/build/esm/integrations/tracing/express-v5/internal-types.js.map +1 -0
  29. package/build/esm/integrations/tracing/express-v5/utils.js +169 -0
  30. package/build/esm/integrations/tracing/express-v5/utils.js.map +1 -0
  31. package/build/esm/integrations/tracing/express.js +48 -33
  32. package/build/esm/integrations/tracing/express.js.map +1 -1
  33. package/build/esm/integrations/tracing/index.js +2 -1
  34. package/build/esm/integrations/tracing/index.js.map +1 -1
  35. package/build/esm/package.json +1 -1
  36. package/build/types/integrations/tracing/express-v5/enums/AttributeNames.d.ts +5 -0
  37. package/build/types/integrations/tracing/express-v5/enums/AttributeNames.d.ts.map +1 -0
  38. package/build/types/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts +6 -0
  39. package/build/types/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts.map +1 -0
  40. package/build/types/integrations/tracing/express-v5/instrumentation.d.ts +27 -0
  41. package/build/types/integrations/tracing/express-v5/instrumentation.d.ts.map +1 -0
  42. package/build/types/integrations/tracing/express-v5/internal-types.d.ts +38 -0
  43. package/build/types/integrations/tracing/express-v5/internal-types.d.ts.map +1 -0
  44. package/build/types/integrations/tracing/express-v5/types.d.ts +39 -0
  45. package/build/types/integrations/tracing/express-v5/types.d.ts.map +1 -0
  46. package/build/types/integrations/tracing/express-v5/utils.d.ts +51 -0
  47. package/build/types/integrations/tracing/express-v5/utils.d.ts.map +1 -0
  48. package/build/types/integrations/tracing/express.d.ts +3 -0
  49. package/build/types/integrations/tracing/express.d.ts.map +1 -1
  50. package/build/types/integrations/tracing/index.d.ts.map +1 -1
  51. package/build/types-ts3.8/integrations/tracing/express-v5/enums/AttributeNames.d.ts +5 -0
  52. package/build/types-ts3.8/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts +6 -0
  53. package/build/types-ts3.8/integrations/tracing/express-v5/instrumentation.d.ts +27 -0
  54. package/build/types-ts3.8/integrations/tracing/express-v5/internal-types.d.ts +38 -0
  55. package/build/types-ts3.8/integrations/tracing/express-v5/types.d.ts +39 -0
  56. package/build/types-ts3.8/integrations/tracing/express-v5/utils.d.ts +57 -0
  57. package/build/types-ts3.8/integrations/tracing/express.d.ts +3 -0
  58. package/package.json +3 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/express-v5/instrumentation.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/member-ordering */\n/* eslint-disable guard-for-in */\n/* eslint-disable @typescript-eslint/ban-types */\n/* eslint-disable prefer-rest-params */\n/* eslint-disable @typescript-eslint/no-this-alias */\n/* eslint-disable jsdoc/require-jsdoc */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\n/* eslint-disable @typescript-eslint/explicit-member-accessibility */\n\n/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Attributes } from '@opentelemetry/api';\nimport { SpanStatusCode, context, diag, trace } from '@opentelemetry/api';\nimport { RPCType, getRPCMetadata } from '@opentelemetry/core';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n isWrapped,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';\nimport type * as express from 'express';\nimport { AttributeNames } from './enums/AttributeNames';\nimport { ExpressLayerType } from './enums/ExpressLayerType';\nimport type { ExpressLayer, ExpressRouter, PatchedRequest } from './internal-types';\nimport { _LAYERS_STORE_PROPERTY, kLayerPatched } from './internal-types';\nimport type { ExpressInstrumentationConfig, ExpressRequestInfo } from './types';\nimport { asErrorAndMessage, getLayerMetadata, getLayerPath, isLayerIgnored, storeLayerPath } from './utils';\n\nexport const PACKAGE_VERSION = '0.1.0';\nexport const PACKAGE_NAME = '@sentry/instrumentation-express-v5';\n\n/** Express instrumentation for OpenTelemetry */\nexport class ExpressInstrumentationV5 extends InstrumentationBase<ExpressInstrumentationConfig> {\n constructor(config: ExpressInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n }\n\n init() {\n return [\n new InstrumentationNodeModuleDefinition(\n 'express',\n ['>=5.0.0'],\n moduleExports => this._setup(moduleExports),\n moduleExports => this._tearDown(moduleExports),\n ),\n ];\n }\n\n private _setup(moduleExports: any) {\n const routerProto = moduleExports.Router.prototype;\n // patch express.Router.route\n if (isWrapped(routerProto.route)) {\n this._unwrap(routerProto, 'route');\n }\n this._wrap(routerProto, 'route', this._getRoutePatch());\n // patch express.Router.use\n if (isWrapped(routerProto.use)) {\n this._unwrap(routerProto, 'use');\n }\n this._wrap(routerProto, 'use', this._getRouterUsePatch() as any);\n // patch express.Application.use\n if (isWrapped(moduleExports.application.use)) {\n this._unwrap(moduleExports.application, 'use');\n }\n this._wrap(moduleExports.application, 'use', this._getAppUsePatch() as any);\n return moduleExports;\n }\n\n private _tearDown(moduleExports: any) {\n if (moduleExports === undefined) return;\n const routerProto = moduleExports.Router.prototype;\n this._unwrap(routerProto, 'route');\n this._unwrap(routerProto, 'use');\n this._unwrap(moduleExports.application, 'use');\n }\n\n /**\n * Get the patch for Router.route function\n */\n private _getRoutePatch() {\n const instrumentation = this;\n return function (original: express.Router['route']) {\n return function route_trace(this: ExpressRouter, ...args: Parameters<typeof original>) {\n const route = original.apply(this, args);\n const layer = this.stack[this.stack.length - 1] as ExpressLayer;\n instrumentation._applyPatch(layer, getLayerPath(args));\n return route;\n };\n };\n }\n\n /**\n * Get the patch for Router.use function\n */\n private _getRouterUsePatch() {\n const instrumentation = this;\n return function (original: express.Router['use']) {\n return function use(this: express.Application, ...args: Parameters<typeof original>) {\n const route = original.apply(this, args);\n const layer = this.stack[this.stack.length - 1] as ExpressLayer;\n instrumentation._applyPatch(layer, getLayerPath(args));\n return route;\n };\n };\n }\n\n /**\n * Get the patch for Application.use function\n */\n private _getAppUsePatch() {\n const instrumentation = this;\n return function (original: express.Application['use']) {\n return function use(\n // In express 5.x the router is stored in `router` whereas in 4.x it's stored in `_router`\n this: { _router?: ExpressRouter; router?: ExpressRouter },\n ...args: Parameters<typeof original>\n ) {\n // if we access app.router in express 4.x we trigger an assertion error\n // This property existed in v3, was removed in v4 and then re-added in v5\n const router = this.router;\n const route = original.apply(this, args);\n if (router) {\n const layer = router.stack[router.stack.length - 1] as ExpressLayer;\n instrumentation._applyPatch(layer, getLayerPath(args));\n }\n return route;\n };\n };\n }\n\n /** Patch each express layer to create span and propagate context */\n private _applyPatch(this: ExpressInstrumentationV5, layer: ExpressLayer, layerPath?: string) {\n const instrumentation = this;\n // avoid patching multiple times the same layer\n if (layer[kLayerPatched] === true) return;\n layer[kLayerPatched] = true;\n\n this._wrap(layer, 'handle', original => {\n // TODO: instrument error handlers\n if (original.length === 4) return original;\n\n const patched = function (this: ExpressLayer, req: PatchedRequest, res: express.Response) {\n storeLayerPath(req, layerPath);\n const route = (req[_LAYERS_STORE_PROPERTY] as string[])\n .filter(path => path !== '/' && path !== '/*')\n .join('')\n // remove duplicate slashes to normalize route\n .replace(/\\/{2,}/g, '/');\n\n const attributes: Attributes = {\n // eslint-disable-next-line deprecation/deprecation\n [SEMATTRS_HTTP_ROUTE]: route.length > 0 ? route : '/',\n };\n const metadata = getLayerMetadata(route, layer, layerPath);\n const type = metadata.attributes[AttributeNames.EXPRESS_TYPE] as ExpressLayerType;\n\n const rpcMetadata = getRPCMetadata(context.active());\n if (rpcMetadata?.type === RPCType.HTTP) {\n rpcMetadata.route = route || '/';\n }\n\n // verify against the config if the layer should be ignored\n if (isLayerIgnored(metadata.name, type, instrumentation.getConfig())) {\n if (type === ExpressLayerType.MIDDLEWARE) {\n (req[_LAYERS_STORE_PROPERTY] as string[]).pop();\n }\n return original.apply(this, arguments);\n }\n\n if (trace.getSpan(context.active()) === undefined) {\n return original.apply(this, arguments);\n }\n\n const spanName = instrumentation._getSpanName(\n {\n request: req,\n layerType: type,\n route,\n },\n metadata.name,\n );\n const span = instrumentation.tracer.startSpan(spanName, {\n attributes: Object.assign(attributes, metadata.attributes),\n });\n\n const { requestHook } = instrumentation.getConfig();\n if (requestHook) {\n safeExecuteInTheMiddle(\n () =>\n requestHook(span, {\n request: req,\n layerType: type,\n route,\n }),\n e => {\n if (e) {\n diag.error('express instrumentation: request hook failed', e);\n }\n },\n true,\n );\n }\n\n let spanHasEnded = false;\n if (metadata.attributes[AttributeNames.EXPRESS_TYPE] !== ExpressLayerType.MIDDLEWARE) {\n span.end();\n spanHasEnded = true;\n }\n // listener for response.on('finish')\n const onResponseFinish = () => {\n if (spanHasEnded === false) {\n spanHasEnded = true;\n span.end();\n }\n };\n\n // verify we have a callback\n const args = Array.from(arguments);\n const callbackIdx = args.findIndex(arg => typeof arg === 'function');\n if (callbackIdx >= 0) {\n arguments[callbackIdx] = function () {\n // express considers anything but an empty value, \"route\" or \"router\"\n // passed to its callback to be an error\n const maybeError = arguments[0];\n const isError = ![undefined, null, 'route', 'router'].includes(maybeError);\n if (!spanHasEnded && isError) {\n const [error, message] = asErrorAndMessage(maybeError);\n span.recordException(error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message,\n });\n }\n\n if (spanHasEnded === false) {\n spanHasEnded = true;\n req.res?.removeListener('finish', onResponseFinish);\n span.end();\n }\n if (!(req.route && isError)) {\n (req[_LAYERS_STORE_PROPERTY] as string[]).pop();\n }\n const callback = args[callbackIdx] as Function;\n return callback.apply(this, arguments);\n };\n }\n\n try {\n return original.apply(this, arguments);\n } catch (anyError) {\n const [error, message] = asErrorAndMessage(anyError);\n span.recordException(error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message,\n });\n throw anyError;\n } finally {\n /**\n * At this point if the callback wasn't called, that means either the\n * layer is asynchronous (so it will call the callback later on) or that\n * the layer directly end the http response, so we'll hook into the \"finish\"\n * event to handle the later case.\n */\n if (!spanHasEnded) {\n res.once('finish', onResponseFinish);\n }\n }\n };\n\n // `handle` isn't just a regular function in some cases. It also contains\n // some properties holding metadata and state so we need to proxy them\n // through through patched function\n // ref: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1950\n // Also some apps/libs do their own patching before OTEL and have these properties\n // in the proptotype. So we use a `for...in` loop to get own properties and also\n // any enumerable prop in the prototype chain\n // ref: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2271\n for (const key in original) {\n Object.defineProperty(patched, key, {\n get() {\n return original[key];\n },\n set(value) {\n original[key] = value;\n },\n });\n }\n return patched;\n });\n }\n\n _getSpanName(info: ExpressRequestInfo, defaultName: string) {\n const { spanNameHook } = this.getConfig();\n\n if (!(spanNameHook instanceof Function)) {\n return defaultName;\n }\n\n try {\n return spanNameHook(info, defaultName) ?? defaultName;\n } catch (err) {\n diag.error('express instrumentation: error calling span name rewrite hook', err);\n return defaultName;\n }\n }\n}\n"],"names":["InstrumentationBase","InstrumentationNodeModuleDefinition","isWrapped","getLayerPath","instrumentation","kLayerPatched","storeLayerPath","_LAYERS_STORE_PROPERTY","SEMATTRS_HTTP_ROUTE","getLayerMetadata","AttributeNames","getRPCMetadata","context","RPCType","isLayerIgnored","ExpressLayerType","trace","safeExecuteInTheMiddle","diag","asErrorAndMessage","SpanStatusCode"],"mappings":";;;;;;;;;;;AA6CO,MAAM,eAAgB,GAAE;AACxB,MAAM,YAAa,GAAE;;AAE5B;AACO,MAAM,wBAAA,SAAiCA,mCAAmB,CAA+B;AAChG,EAAE,WAAW,CAAC,MAAM,GAAiC,EAAE,EAAE;AACzD,IAAI,KAAK,CAAC,YAAY,EAAE,eAAe,EAAE,MAAM,CAAC;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AC,SAAS,CAAC;AACzB,YAAY,IAAI,EAAEC,kBAAc,CAAC,KAAK;AACtC,YAAY,OAAO;AACnB,WAAW,CAAC;AACZ,UAAU,MAAM,QAAQ;AACxB,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,IAAI,CAAC,YAAY,EAAE;AAC7B,YAAY,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC;AAChD;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,KAAK,MAAM,GAAI,IAAG,QAAQ,EAAE;AAClC,QAAQ,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE;AAC5C,UAAU,GAAG,GAAG;AAChB,YAAY,OAAO,QAAQ,CAAC,GAAG,CAAC;AAChC,WAAW;AACX,UAAU,GAAG,CAAC,KAAK,EAAE;AACrB,YAAY,QAAQ,CAAC,GAAG,CAAA,GAAI,KAAK;AACjC,WAAW;AACX,SAAS,CAAC;AACV;AACA,MAAM,OAAO,OAAO;AACpB,KAAK,CAAC;AACN;;AAEA,EAAE,YAAY,CAAC,IAAI,EAAsB,WAAW,EAAU;AAC9D,IAAI,MAAM,EAAE,YAAa,EAAA,GAAI,IAAI,CAAC,SAAS,EAAE;;AAE7C,IAAI,IAAI,EAAE,wBAAwB,QAAQ,CAAC,EAAE;AAC7C,MAAM,OAAO,WAAW;AACxB;;AAEA,IAAI,IAAI;AACR,MAAM,OAAO,YAAY,CAAC,IAAI,EAAE,WAAW,CAAA,IAAK,WAAW;AAC3D,KAAM,CAAA,OAAO,GAAG,EAAE;AAClB,MAAMF,QAAI,CAAC,KAAK,CAAC,+DAA+D,EAAE,GAAG,CAAC;AACtF,MAAM,OAAO,WAAW;AACxB;AACA;AACA;;;;;;"}
@@ -0,0 +1,29 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ /**
4
+ * This symbol is used to mark express layer as being already instrumented
5
+ * since its possible to use a given layer multiple times (ex: middlewares)
6
+ */
7
+ const kLayerPatched = Symbol('express-layer-patched');
8
+
9
+ /**
10
+ * This const define where on the `request` object the Instrumentation will mount the
11
+ * current stack of express layer.
12
+ *
13
+ * It is necessary because express doesn't store the different layers
14
+ * (ie: middleware, router etc) that it called to get to the current layer.
15
+ * Given that, the only way to know the route of a given layer is to
16
+ * store the path of where each previous layer has been mounted.
17
+ *
18
+ * ex: bodyParser > auth middleware > /users router > get /:id
19
+ * in this case the stack would be: ["/users", "/:id"]
20
+ *
21
+ * ex2: bodyParser > /api router > /v1 router > /users router > get /:id
22
+ * stack: ["/api", "/v1", "/users", ":id"]
23
+ *
24
+ */
25
+ const _LAYERS_STORE_PROPERTY = '__ot_middlewares';
26
+
27
+ exports._LAYERS_STORE_PROPERTY = _LAYERS_STORE_PROPERTY;
28
+ exports.kLayerPatched = kLayerPatched;
29
+ //# sourceMappingURL=internal-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-types.js","sources":["../../../../../src/integrations/tracing/express-v5/internal-types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/ban-types */\n\n/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Request } from 'express';\n\n/**\n * This symbol is used to mark express layer as being already instrumented\n * since its possible to use a given layer multiple times (ex: middlewares)\n */\nexport const kLayerPatched: unique symbol = Symbol('express-layer-patched');\n\n/**\n * This const define where on the `request` object the Instrumentation will mount the\n * current stack of express layer.\n *\n * It is necessary because express doesn't store the different layers\n * (ie: middleware, router etc) that it called to get to the current layer.\n * Given that, the only way to know the route of a given layer is to\n * store the path of where each previous layer has been mounted.\n *\n * ex: bodyParser > auth middleware > /users router > get /:id\n * in this case the stack would be: [\"/users\", \"/:id\"]\n *\n * ex2: bodyParser > /api router > /v1 router > /users router > get /:id\n * stack: [\"/api\", \"/v1\", \"/users\", \":id\"]\n *\n */\nexport const _LAYERS_STORE_PROPERTY = '__ot_middlewares';\n\nexport type PatchedRequest = {\n [_LAYERS_STORE_PROPERTY]?: string[];\n} & Request;\nexport type PathParams = string | RegExp | Array<string | RegExp>;\n\n// https://github.com/expressjs/express/blob/main/lib/router/index.js#L53\nexport type ExpressRouter = {\n stack: ExpressLayer[];\n};\n\n// https://github.com/expressjs/express/blob/main/lib/router/layer.js#L33\nexport type ExpressLayer = {\n handle: Function & Record<string, any>;\n [kLayerPatched]?: boolean;\n name: string;\n path: string;\n route?: ExpressLayer;\n};\n"],"names":[],"mappings":";;AAqBA;AACA;AACA;AACA;MACa,aAAa,GAAkB,MAAM,CAAC,uBAAuB;;AAE1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,sBAAuB,GAAE;;;;;"}
@@ -0,0 +1,176 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const AttributeNames = require('./enums/AttributeNames.js');
4
+ const ExpressLayerType = require('./enums/ExpressLayerType.js');
5
+ const internalTypes = require('./internal-types.js');
6
+
7
+ /**
8
+ * Store layers path in the request to be able to construct route later
9
+ * @param request The request where
10
+ * @param [value] the value to push into the array
11
+ */
12
+ const storeLayerPath = (request, value) => {
13
+ if (Array.isArray(request[internalTypes._LAYERS_STORE_PROPERTY]) === false) {
14
+ Object.defineProperty(request, internalTypes._LAYERS_STORE_PROPERTY, {
15
+ enumerable: false,
16
+ value: [],
17
+ });
18
+ }
19
+ if (value === undefined) return;
20
+ (request[internalTypes._LAYERS_STORE_PROPERTY] ).push(value);
21
+ };
22
+
23
+ /**
24
+ * Recursively search the router path from layer stack
25
+ * @param path The path to reconstruct
26
+ * @param layer The layer to reconstruct from
27
+ * @returns The reconstructed path
28
+ */
29
+ const getRouterPath = (path, layer) => {
30
+ const stackLayer = layer.handle?.stack?.[0];
31
+
32
+ if (stackLayer?.route?.path) {
33
+ return `${path}${stackLayer.route.path}`;
34
+ }
35
+
36
+ if (stackLayer?.handle?.stack) {
37
+ return getRouterPath(path, stackLayer);
38
+ }
39
+
40
+ return path;
41
+ };
42
+
43
+ /**
44
+ * Parse express layer context to retrieve a name and attributes.
45
+ * @param route The route of the layer
46
+ * @param layer Express layer
47
+ * @param [layerPath] if present, the path on which the layer has been mounted
48
+ */
49
+ const getLayerMetadata = (
50
+ route,
51
+ layer,
52
+ layerPath,
53
+
54
+ ) => {
55
+ if (layer.name === 'router') {
56
+ const maybeRouterPath = getRouterPath('', layer);
57
+ const extractedRouterPath = maybeRouterPath ? maybeRouterPath : layerPath || route || '/';
58
+
59
+ return {
60
+ attributes: {
61
+ [AttributeNames.AttributeNames.EXPRESS_NAME]: extractedRouterPath,
62
+ [AttributeNames.AttributeNames.EXPRESS_TYPE]: ExpressLayerType.ExpressLayerType.ROUTER,
63
+ },
64
+ name: `router - ${extractedRouterPath}`,
65
+ };
66
+ } else if (layer.name === 'bound dispatch' || layer.name === 'handle') {
67
+ return {
68
+ attributes: {
69
+ [AttributeNames.AttributeNames.EXPRESS_NAME]: (route || layerPath) ?? 'request handler',
70
+ [AttributeNames.AttributeNames.EXPRESS_TYPE]: ExpressLayerType.ExpressLayerType.REQUEST_HANDLER,
71
+ },
72
+ name: `request handler${layer.path ? ` - ${route || layerPath}` : ''}`,
73
+ };
74
+ } else {
75
+ return {
76
+ attributes: {
77
+ [AttributeNames.AttributeNames.EXPRESS_NAME]: layer.name,
78
+ [AttributeNames.AttributeNames.EXPRESS_TYPE]: ExpressLayerType.ExpressLayerType.MIDDLEWARE,
79
+ },
80
+ name: `middleware - ${layer.name}`,
81
+ };
82
+ }
83
+ };
84
+
85
+ /**
86
+ * Check whether the given obj match pattern
87
+ * @param constant e.g URL of request
88
+ * @param obj obj to inspect
89
+ * @param pattern Match pattern
90
+ */
91
+ const satisfiesPattern = (constant, pattern) => {
92
+ if (typeof pattern === 'string') {
93
+ return pattern === constant;
94
+ } else if (pattern instanceof RegExp) {
95
+ return pattern.test(constant);
96
+ } else if (typeof pattern === 'function') {
97
+ return pattern(constant);
98
+ } else {
99
+ throw new TypeError('Pattern is in unsupported datatype');
100
+ }
101
+ };
102
+
103
+ /**
104
+ * Check whether the given request is ignored by configuration
105
+ * It will not re-throw exceptions from `list` provided by the client
106
+ * @param constant e.g URL of request
107
+ * @param [list] List of ignore patterns
108
+ * @param [onException] callback for doing something when an exception has
109
+ * occurred
110
+ */
111
+ const isLayerIgnored = (
112
+ name,
113
+ type,
114
+ config,
115
+ ) => {
116
+ if (Array.isArray(config?.ignoreLayersType) && config?.ignoreLayersType?.includes(type)) {
117
+ return true;
118
+ }
119
+ if (Array.isArray(config?.ignoreLayers) === false) return false;
120
+ try {
121
+ for (const pattern of config.ignoreLayers) {
122
+ if (satisfiesPattern(name, pattern)) {
123
+ return true;
124
+ }
125
+ }
126
+ } catch (e) {
127
+ /* catch block */
128
+ }
129
+
130
+ return false;
131
+ };
132
+
133
+ /**
134
+ * Converts a user-provided error value into an error and error message pair
135
+ *
136
+ * @param error - User-provided error value
137
+ * @returns Both an Error or string representation of the value and an error message
138
+ */
139
+ const asErrorAndMessage = (error) =>
140
+ error instanceof Error ? [error, error.message] : [String(error), String(error)];
141
+
142
+ /**
143
+ * Extracts the layer path from the route arguments
144
+ *
145
+ * @param args - Arguments of the route
146
+ * @returns The layer path
147
+ */
148
+ const getLayerPath = (args) => {
149
+ const firstArg = args[0];
150
+
151
+ if (Array.isArray(firstArg)) {
152
+ return firstArg.map(arg => extractLayerPathSegment(arg) || '').join(',');
153
+ }
154
+
155
+ return extractLayerPathSegment(firstArg);
156
+ };
157
+
158
+ const extractLayerPathSegment = (arg) => {
159
+ if (typeof arg === 'string') {
160
+ return arg;
161
+ }
162
+
163
+ if (arg instanceof RegExp || typeof arg === 'number') {
164
+ return arg.toString();
165
+ }
166
+
167
+ return;
168
+ };
169
+
170
+ exports.asErrorAndMessage = asErrorAndMessage;
171
+ exports.getLayerMetadata = getLayerMetadata;
172
+ exports.getLayerPath = getLayerPath;
173
+ exports.getRouterPath = getRouterPath;
174
+ exports.isLayerIgnored = isLayerIgnored;
175
+ exports.storeLayerPath = storeLayerPath;
176
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../../../src/integrations/tracing/express-v5/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n\n/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Attributes } from '@opentelemetry/api';\nimport { AttributeNames } from './enums/AttributeNames';\nimport { ExpressLayerType } from './enums/ExpressLayerType';\nimport type { ExpressLayer, PatchedRequest } from './internal-types';\nimport { _LAYERS_STORE_PROPERTY } from './internal-types';\nimport type { ExpressInstrumentationConfig, IgnoreMatcher, LayerPathSegment } from './types';\n\n/**\n * Store layers path in the request to be able to construct route later\n * @param request The request where\n * @param [value] the value to push into the array\n */\nexport const storeLayerPath = (request: PatchedRequest, value?: string): void => {\n if (Array.isArray(request[_LAYERS_STORE_PROPERTY]) === false) {\n Object.defineProperty(request, _LAYERS_STORE_PROPERTY, {\n enumerable: false,\n value: [],\n });\n }\n if (value === undefined) return;\n (request[_LAYERS_STORE_PROPERTY] as string[]).push(value);\n};\n\n/**\n * Recursively search the router path from layer stack\n * @param path The path to reconstruct\n * @param layer The layer to reconstruct from\n * @returns The reconstructed path\n */\nexport const getRouterPath = (path: string, layer: ExpressLayer): string => {\n const stackLayer = layer.handle?.stack?.[0];\n\n if (stackLayer?.route?.path) {\n return `${path}${stackLayer.route.path}`;\n }\n\n if (stackLayer?.handle?.stack) {\n return getRouterPath(path, stackLayer);\n }\n\n return path;\n};\n\n/**\n * Parse express layer context to retrieve a name and attributes.\n * @param route The route of the layer\n * @param layer Express layer\n * @param [layerPath] if present, the path on which the layer has been mounted\n */\nexport const getLayerMetadata = (\n route: string,\n layer: ExpressLayer,\n layerPath?: string,\n): {\n attributes: Attributes;\n name: string;\n} => {\n if (layer.name === 'router') {\n const maybeRouterPath = getRouterPath('', layer);\n const extractedRouterPath = maybeRouterPath ? maybeRouterPath : layerPath || route || '/';\n\n return {\n attributes: {\n [AttributeNames.EXPRESS_NAME]: extractedRouterPath,\n [AttributeNames.EXPRESS_TYPE]: ExpressLayerType.ROUTER,\n },\n name: `router - ${extractedRouterPath}`,\n };\n } else if (layer.name === 'bound dispatch' || layer.name === 'handle') {\n return {\n attributes: {\n [AttributeNames.EXPRESS_NAME]: (route || layerPath) ?? 'request handler',\n [AttributeNames.EXPRESS_TYPE]: ExpressLayerType.REQUEST_HANDLER,\n },\n name: `request handler${layer.path ? ` - ${route || layerPath}` : ''}`,\n };\n } else {\n return {\n attributes: {\n [AttributeNames.EXPRESS_NAME]: layer.name,\n [AttributeNames.EXPRESS_TYPE]: ExpressLayerType.MIDDLEWARE,\n },\n name: `middleware - ${layer.name}`,\n };\n }\n};\n\n/**\n * Check whether the given obj match pattern\n * @param constant e.g URL of request\n * @param obj obj to inspect\n * @param pattern Match pattern\n */\nconst satisfiesPattern = (constant: string, pattern: IgnoreMatcher): boolean => {\n if (typeof pattern === 'string') {\n return pattern === constant;\n } else if (pattern instanceof RegExp) {\n return pattern.test(constant);\n } else if (typeof pattern === 'function') {\n return pattern(constant);\n } else {\n throw new TypeError('Pattern is in unsupported datatype');\n }\n};\n\n/**\n * Check whether the given request is ignored by configuration\n * It will not re-throw exceptions from `list` provided by the client\n * @param constant e.g URL of request\n * @param [list] List of ignore patterns\n * @param [onException] callback for doing something when an exception has\n * occurred\n */\nexport const isLayerIgnored = (\n name: string,\n type: ExpressLayerType,\n config?: ExpressInstrumentationConfig,\n): boolean => {\n if (Array.isArray(config?.ignoreLayersType) && config?.ignoreLayersType?.includes(type)) {\n return true;\n }\n if (Array.isArray(config?.ignoreLayers) === false) return false;\n try {\n for (const pattern of config!.ignoreLayers!) {\n if (satisfiesPattern(name, pattern)) {\n return true;\n }\n }\n } catch (e) {\n /* catch block */\n }\n\n return false;\n};\n\n/**\n * Converts a user-provided error value into an error and error message pair\n *\n * @param error - User-provided error value\n * @returns Both an Error or string representation of the value and an error message\n */\nexport const asErrorAndMessage = (error: unknown): [error: string | Error, message: string] =>\n error instanceof Error ? [error, error.message] : [String(error), String(error)];\n\n/**\n * Extracts the layer path from the route arguments\n *\n * @param args - Arguments of the route\n * @returns The layer path\n */\nexport const getLayerPath = (args: [LayerPathSegment | LayerPathSegment[], ...unknown[]]): string | undefined => {\n const firstArg = args[0];\n\n if (Array.isArray(firstArg)) {\n return firstArg.map(arg => extractLayerPathSegment(arg) || '').join(',');\n }\n\n return extractLayerPathSegment(firstArg);\n};\n\nconst extractLayerPathSegment = (arg: LayerPathSegment) => {\n if (typeof arg === 'string') {\n return arg;\n }\n\n if (arg instanceof RegExp || typeof arg === 'number') {\n return arg.toString();\n }\n\n return;\n};\n"],"names":["_LAYERS_STORE_PROPERTY","AttributeNames","ExpressLayerType"],"mappings":";;;;;;AA2BA;AACA;AACA;AACA;AACA;MACa,cAAe,GAAE,CAAC,OAAO,EAAkB,KAAK,KAAoB;AACjF,EAAE,IAAI,KAAK,CAAC,OAAO,C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AACA;;AAEA,MAAA,uBAAA,GAAA,CAAA,GAAA,KAAA;AACA,EAAA,IAAA,OAAA,GAAA,KAAA,QAAA,EAAA;AACA,IAAA,OAAA,GAAA;AACA;;AAEA,EAAA,IAAA,GAAA,YAAA,MAAA,IAAA,OAAA,GAAA,KAAA,QAAA,EAAA;AACA,IAAA,OAAA,GAAA,CAAA,QAAA,EAAA;AACA;;AAEA,EAAA;AACA,CAAA;;;;;;;;;"}
@@ -6,44 +6,58 @@ const debugBuild = require('../../debug-build.js');
6
6
  const instrument = require('../../otel/instrument.js');
7
7
  const addOriginToSpan = require('../../utils/addOriginToSpan.js');
8
8
  const ensureIsWrapped = require('../../utils/ensureIsWrapped.js');
9
+ const instrumentation = require('./express-v5/instrumentation.js');
9
10
 
10
11
  const INTEGRATION_NAME = 'Express';
12
+ const INTEGRATION_NAME_V5 = 'Express-V5';
13
+
14
+ function requestHook(span) {
15
+ addOriginToSpan.addOriginToSpan(span, 'auto.http.otel.express');
16
+
17
+ const attributes = core.spanToJSON(span).data;
18
+ // this is one of: middleware, request_handler, router
19
+ const type = attributes['express.type'];
20
+
21
+ if (type) {
22
+ span.setAttribute(core.SEMANTIC_ATTRIBUTE_SENTRY_OP, `${type}.express`);
23
+ }
24
+
25
+ // Also update the name, we don't need to "middleware - " prefix
26
+ const name = attributes['express.name'];
27
+ if (typeof name === 'string') {
28
+ span.updateName(name);
29
+ }
30
+ }
31
+
32
+ function spanNameHook(info, defaultName) {
33
+ if (core.getIsolationScope() === core.getDefaultIsolationScope()) {
34
+ debugBuild.DEBUG_BUILD && core.logger.warn('Isolation scope is still default isolation scope - skipping setting transactionName');
35
+ return defaultName;
36
+ }
37
+ if (info.layerType === 'request_handler') {
38
+ // type cast b/c Otel unfortunately types info.request as any :(
39
+ const req = info.request ;
40
+ const method = req.method ? req.method.toUpperCase() : 'GET';
41
+ core.getIsolationScope().setTransactionName(`${method} ${info.route}`);
42
+ }
43
+ return defaultName;
44
+ }
11
45
 
12
46
  const instrumentExpress = instrument.generateInstrumentOnce(
13
47
  INTEGRATION_NAME,
14
48
  () =>
15
49
  new instrumentationExpress.ExpressInstrumentation({
16
- requestHook(span) {
17
- addOriginToSpan.addOriginToSpan(span, 'auto.http.otel.express');
18
-
19
- const attributes = core.spanToJSON(span).data;
20
- // this is one of: middleware, request_handler, router
21
- const type = attributes['express.type'];
22
-
23
- if (type) {
24
- span.setAttribute(core.SEMANTIC_ATTRIBUTE_SENTRY_OP, `${type}.express`);
25
- }
26
-
27
- // Also update the name, we don't need to "middleware - " prefix
28
- const name = attributes['express.name'];
29
- if (typeof name === 'string') {
30
- span.updateName(name);
31
- }
32
- },
33
- spanNameHook(info, defaultName) {
34
- if (core.getIsolationScope() === core.getDefaultIsolationScope()) {
35
- debugBuild.DEBUG_BUILD &&
36
- core.logger.warn('Isolation scope is still default isolation scope - skipping setting transactionName');
37
- return defaultName;
38
- }
39
- if (info.layerType === 'request_handler') {
40
- // type cast b/c Otel unfortunately types info.request as any :(
41
- const req = info.request ;
42
- const method = req.method ? req.method.toUpperCase() : 'GET';
43
- core.getIsolationScope().setTransactionName(`${method} ${info.route}`);
44
- }
45
- return defaultName;
46
- },
50
+ requestHook: span => requestHook(span),
51
+ spanNameHook: (info, defaultName) => spanNameHook(info, defaultName),
52
+ }),
53
+ );
54
+
55
+ const instrumentExpressV5 = instrument.generateInstrumentOnce(
56
+ INTEGRATION_NAME_V5,
57
+ () =>
58
+ new instrumentation.ExpressInstrumentationV5({
59
+ requestHook: span => requestHook(span),
60
+ spanNameHook: (info, defaultName) => spanNameHook(info, defaultName),
47
61
  }),
48
62
  );
49
63
 
@@ -52,6 +66,7 @@ const _expressIntegration = (() => {
52
66
  name: INTEGRATION_NAME,
53
67
  setupOnce() {
54
68
  instrumentExpress();
69
+ instrumentExpressV5();
55
70
  },
56
71
  };
57
72
  }) ;
@@ -159,5 +174,6 @@ function defaultShouldHandleError(error) {
159
174
  exports.expressErrorHandler = expressErrorHandler;
160
175
  exports.expressIntegration = expressIntegration;
161
176
  exports.instrumentExpress = instrumentExpress;
177
+ exports.instrumentExpressV5 = instrumentExpressV5;
162
178
  exports.setupExpressErrorHandler = setupExpressErrorHandler;
163
179
  //# sourceMappingURL=express.js.map
@@ -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":["generateInstrumentOnce","ExpressInstrumentation","addOriginToSpan","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_OP","getIsolationScope","getDefaultIsolationScope","DEBUG_BUILD","logger","defineIntegration","captureException","ensureIsWrapped"],"mappings":";;;;;;;;;AAiBA,MAAM,gBAAA,GAAmB,SAAS;;AAE3B,MAAM,iBAAkB,GAAEA,iCAAsB;AACvD,EAAE,gBAAgB;AAClB,EAAE;AACF,IAAI,IAAIC,6CAAsB,CAAC;AAC/B,MAAM,WAAW,CAAC,IAAI,EAAE;AACxB,QAAQC,+BAAe,CAAC,IAAI,EAAE,wBAAwB,CAAC;;AAEvD,QAAQ,MAAM,aAAaC,eAAU,CAAC,IAAI,CAAC,CAAC,IAAI;AACh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,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
+ {"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":["addOriginToSpan","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_OP","getIsolationScope","getDefaultIsolationScope","DEBUG_BUILD","logger","generateInstrumentOnce","ExpressInstrumentation","ExpressInstrumentationV5","defineIntegration","captureException","ensureIsWrapped"],"mappings":";;;;;;;;;;AAoBA,MAAM,gBAAA,GAAmB,SAAS;AAClC,MAAM,mBAAA,GAAsB,YAAY;;AAExC,SAAS,WAAW,CAAC,IAAI,EAAc;AACvC,EAAEA,+BAAe,CAAC,IAAI,EAAE,wBAAwB,CAAC;;AAEjD,EAAE,MAAM,aAAaC,eAAU,CAAC,IAAI,CAAC,CAAC,IAAI;AAC1C;AACA,EAAE,MAAM,IAAK,GAAE,UAAU,CAAC,cAAc,CAAC;;AAEzC,EAAE,IAAI,IAAI,EAAE;AACZ,IAAI,IAAI,CAAC,YAAY,CAACC,iCAA4B,EAAE,CAAC,EAAA,IAAA,CAAA,QAAA,CAAA,CAAA;AACA;;AAEA;AACA,EAAA,MAAA,IAAA,GAAA,UAAA,CAAA,cAAA,CAAA;AACA,EAAA,IAAA,OAAA,IAAA,KAAA,QAAA,EAAA;AACA,IAAA,IAAA,CAAA,UAAA,CAAA,IAAA,CAAA;AACA;AACA;;AAEA,SAAA,YAAA,CAAA,IAAA,EAAA,WAAA,EAAA;AACA,EAAA,IAAAC,sBAAA,EAAA,KAAAC,6BAAA,EAAA,EAAA;AACA,IAAAC,sBAAA,IAAAC,WAAA,CAAA,IAAA,CAAA,qFAAA,CAAA;AACA,IAAA,OAAA,WAAA;AACA;AACA,EAAA,IAAA,IAAA,CAAA,SAAA,KAAA,iBAAA,EAAA;AACA;AACA,IAAA,MAAA,GAAA,GAAA,IAAA,CAAA,OAAA;AACA,IAAA,MAAA,MAAA,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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;;;;;;;;"}
@@ -58,6 +58,7 @@ function getOpenTelemetryInstrumentationToPreload() {
58
58
  return [
59
59
  index$2.instrumentOtelHttp,
60
60
  express.instrumentExpress,
61
+ express.instrumentExpressV5,
61
62
  connect.instrumentConnect,
62
63
  fastify.instrumentFastify,
63
64
  index.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":["expressIntegration","fastifyIntegration","graphqlIntegration","mongoIntegration","mongooseIntegration","mysqlIntegration","mysql2Integration","redisIntegration","postgresIntegration","hapiIntegration","koaIntegration","connectIntegration","tediousIntegration","genericPoolIntegration","kafkaIntegration","amqplibIntegration","lruMemoizerIntegration","vercelAIIntegration","instrumentOtelHttp","instrumentExpress","instrumentConnect","instrumentFastify","instrumentHapi","instrumentKafka","instrumentKoa","instrumentLruMemoizer","instrumentMongo","instrumentMongoose","instrumentMysql","instrumentMysql2","instrumentPostgres","instrumentGraphql","instrumentRedis","instrumentTedious","instrumentGenericPool","instrumentAmqplib","instrumentVercelAi"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA;AACA;AACA;AACO,SAAS,8BAA8B,GAAkB;AAChE,EAAE,OAAO;AACT,IAAIA,0BAAkB,EAAE;AACxB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,4BAAmB,EAAE;AACzB,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,wBAAiB,EAAE;AACvB,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,4BAAmB,EAAE;AACzB;AACA;AACA;AACA;AACA,IAAIC,qBAAe,EAAE;AACrB,IAAIC,kBAAc,EAAE;AACpB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,kCAAsB,EAAE;AAC5B,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,kCAAsB,EAAE;AAC5B,IAAIC,2BAAmB,EAAE;AACzB,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACO,SAAS,wCAAwC,GAAmD;AAC3G,EAAE,OAAO;AACT,IAAIC,0BAAkB;AACtB,IAAIC,yBAAiB;AACrB,IAAIC,yBAAiB;AACrB,IAAIC,yBAAiB;AACrB,IAAIC,oBAAc;AAClB,IAAIC,qBAAe;AACnB,IAAIC,iBAAa;AACjB,IAAIC,iCAAqB;AACzB,IAAIC,qBAAe;AACnB,IAAIC,2BAAkB;AACtB,IAAIC,qBAAe;AACnB,IAAIC,uBAAgB;AACpB,IAAIC,2BAAkB;AACtB,IAAIR,oBAAc;AAClB,IAAIS,yBAAiB;AACrB,IAAIC,qBAAe;AACnB,IAAIC,yBAAiB;AACrB,IAAIC,iCAAqB;AACzB,IAAIC,yBAAiB;AACrB,IAAIC,0BAAkB;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":["expressIntegration","fastifyIntegration","graphqlIntegration","mongoIntegration","mongooseIntegration","mysqlIntegration","mysql2Integration","redisIntegration","postgresIntegration","hapiIntegration","koaIntegration","connectIntegration","tediousIntegration","genericPoolIntegration","kafkaIntegration","amqplibIntegration","lruMemoizerIntegration","vercelAIIntegration","instrumentOtelHttp","instrumentExpress","instrumentExpressV5","instrumentConnect","instrumentFastify","instrumentHapi","instrumentKafka","instrumentKoa","instrumentLruMemoizer","instrumentMongo","instrumentMongoose","instrumentMysql","instrumentMysql2","instrumentPostgres","instrumentGraphql","instrumentRedis","instrumentTedious","instrumentGenericPool","instrumentAmqplib","instrumentVercelAi"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA;AACA;AACA;AACO,SAAS,8BAA8B,GAAkB;AAChE,EAAE,OAAO;AACT,IAAIA,0BAAkB,EAAE;AACxB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,4BAAmB,EAAE;AACzB,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,wBAAiB,EAAE;AACvB,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,4BAAmB,EAAE;AACzB;AACA;AACA;AACA;AACA,IAAIC,qBAAe,EAAE;AACrB,IAAIC,kBAAc,EAAE;AACpB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,kCAAsB,EAAE;AAC5B,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,kCAAsB,EAAE;AAC5B,IAAIC,2BAAmB,EAAE;AACzB,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACO,SAAS,wCAAwC,GAAmD;AAC3G,EAAE,OAAO;AACT,IAAIC,0BAAkB;AACtB,IAAIC,yBAAiB;AACrB,IAAIC,2BAAmB;AACvB,IAAIC,yBAAiB;AACrB,IAAIC,yBAAiB;AACrB,IAAIC,oBAAc;AAClB,IAAIC,qBAAe;AACnB,IAAIC,iBAAa;AACjB,IAAIC,iCAAqB;AACzB,IAAIC,qBAAe;AACnB,IAAIC,2BAAkB;AACtB,IAAIC,qBAAe;AACnB,IAAIC,uBAAgB;AACpB,IAAIC,2BAAkB;AACtB,IAAIR,oBAAc;AAClB,IAAIS,yBAAiB;AACrB,IAAIC,qBAAe;AACnB,IAAIC,yBAAiB;AACrB,IAAIC,iCAAqB;AACzB,IAAIC,yBAAiB;AACrB,IAAIC,0BAAkB;AACtB,GAAG;AACH;;;;;"}