@sentry/node 9.40.0 → 10.0.0-alpha.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 (61) hide show
  1. package/build/cjs/integrations/tracing/express.js +0 -13
  2. package/build/cjs/integrations/tracing/express.js.map +1 -1
  3. package/build/cjs/integrations/tracing/index.js +0 -1
  4. package/build/cjs/integrations/tracing/index.js.map +1 -1
  5. package/build/cjs/integrations/tracing/redis.js +4 -4
  6. package/build/cjs/integrations/tracing/redis.js.map +1 -1
  7. package/build/cjs/sdk/initOtel.js +8 -6
  8. package/build/cjs/sdk/initOtel.js.map +1 -1
  9. package/build/esm/integrations/tracing/express.js +1 -13
  10. package/build/esm/integrations/tracing/express.js.map +1 -1
  11. package/build/esm/integrations/tracing/index.js +1 -2
  12. package/build/esm/integrations/tracing/index.js.map +1 -1
  13. package/build/esm/integrations/tracing/redis.js +3 -3
  14. package/build/esm/integrations/tracing/redis.js.map +1 -1
  15. package/build/esm/package.json +1 -1
  16. package/build/esm/sdk/initOtel.js +9 -7
  17. package/build/esm/sdk/initOtel.js.map +1 -1
  18. package/build/types/integrations/tracing/express.d.ts +0 -4
  19. package/build/types/integrations/tracing/express.d.ts.map +1 -1
  20. package/build/types/integrations/tracing/index.d.ts.map +1 -1
  21. package/build/types/sdk/initOtel.d.ts.map +1 -1
  22. package/build/types-ts3.8/integrations/tracing/express.d.ts +0 -4
  23. package/package.json +31 -31
  24. package/build/cjs/integrations/tracing/express-v5/enums/AttributeNames.js +0 -22
  25. package/build/cjs/integrations/tracing/express-v5/enums/AttributeNames.js.map +0 -1
  26. package/build/cjs/integrations/tracing/express-v5/enums/ExpressLayerType.js +0 -23
  27. package/build/cjs/integrations/tracing/express-v5/enums/ExpressLayerType.js.map +0 -1
  28. package/build/cjs/integrations/tracing/express-v5/instrumentation.js +0 -297
  29. package/build/cjs/integrations/tracing/express-v5/instrumentation.js.map +0 -1
  30. package/build/cjs/integrations/tracing/express-v5/internal-types.js +0 -29
  31. package/build/cjs/integrations/tracing/express-v5/internal-types.js.map +0 -1
  32. package/build/cjs/integrations/tracing/express-v5/utils.js +0 -176
  33. package/build/cjs/integrations/tracing/express-v5/utils.js.map +0 -1
  34. package/build/esm/integrations/tracing/express-v5/enums/AttributeNames.js +0 -22
  35. package/build/esm/integrations/tracing/express-v5/enums/AttributeNames.js.map +0 -1
  36. package/build/esm/integrations/tracing/express-v5/enums/ExpressLayerType.js +0 -23
  37. package/build/esm/integrations/tracing/express-v5/enums/ExpressLayerType.js.map +0 -1
  38. package/build/esm/integrations/tracing/express-v5/instrumentation.js +0 -293
  39. package/build/esm/integrations/tracing/express-v5/instrumentation.js.map +0 -1
  40. package/build/esm/integrations/tracing/express-v5/internal-types.js +0 -26
  41. package/build/esm/integrations/tracing/express-v5/internal-types.js.map +0 -1
  42. package/build/esm/integrations/tracing/express-v5/utils.js +0 -169
  43. package/build/esm/integrations/tracing/express-v5/utils.js.map +0 -1
  44. package/build/types/integrations/tracing/express-v5/enums/AttributeNames.d.ts +0 -5
  45. package/build/types/integrations/tracing/express-v5/enums/AttributeNames.d.ts.map +0 -1
  46. package/build/types/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts +0 -6
  47. package/build/types/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts.map +0 -1
  48. package/build/types/integrations/tracing/express-v5/instrumentation.d.ts +0 -27
  49. package/build/types/integrations/tracing/express-v5/instrumentation.d.ts.map +0 -1
  50. package/build/types/integrations/tracing/express-v5/internal-types.d.ts +0 -38
  51. package/build/types/integrations/tracing/express-v5/internal-types.d.ts.map +0 -1
  52. package/build/types/integrations/tracing/express-v5/types.d.ts +0 -39
  53. package/build/types/integrations/tracing/express-v5/types.d.ts.map +0 -1
  54. package/build/types/integrations/tracing/express-v5/utils.d.ts +0 -51
  55. package/build/types/integrations/tracing/express-v5/utils.d.ts.map +0 -1
  56. package/build/types-ts3.8/integrations/tracing/express-v5/enums/AttributeNames.d.ts +0 -5
  57. package/build/types-ts3.8/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts +0 -6
  58. package/build/types-ts3.8/integrations/tracing/express-v5/instrumentation.d.ts +0 -27
  59. package/build/types-ts3.8/integrations/tracing/express-v5/internal-types.d.ts +0 -38
  60. package/build/types-ts3.8/integrations/tracing/express-v5/types.d.ts +0 -39
  61. package/build/types-ts3.8/integrations/tracing/express-v5/utils.d.ts +0 -57
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/node",
3
- "version": "9.40.0",
3
+ "version": "10.0.0-alpha.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",
@@ -66,38 +66,38 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "@opentelemetry/api": "^1.9.0",
69
- "@opentelemetry/context-async-hooks": "^1.30.1",
70
- "@opentelemetry/core": "^1.30.1",
71
- "@opentelemetry/instrumentation": "^0.57.2",
72
- "@opentelemetry/instrumentation-amqplib": "^0.46.1",
73
- "@opentelemetry/instrumentation-connect": "0.43.1",
74
- "@opentelemetry/instrumentation-dataloader": "0.16.1",
75
- "@opentelemetry/instrumentation-express": "0.47.1",
76
- "@opentelemetry/instrumentation-fs": "0.19.1",
77
- "@opentelemetry/instrumentation-generic-pool": "0.43.1",
78
- "@opentelemetry/instrumentation-graphql": "0.47.1",
79
- "@opentelemetry/instrumentation-hapi": "0.45.2",
80
- "@opentelemetry/instrumentation-http": "0.57.2",
81
- "@opentelemetry/instrumentation-ioredis": "0.47.1",
82
- "@opentelemetry/instrumentation-kafkajs": "0.7.1",
83
- "@opentelemetry/instrumentation-knex": "0.44.1",
84
- "@opentelemetry/instrumentation-koa": "0.47.1",
85
- "@opentelemetry/instrumentation-lru-memoizer": "0.44.1",
86
- "@opentelemetry/instrumentation-mongodb": "0.52.0",
87
- "@opentelemetry/instrumentation-mongoose": "0.46.1",
88
- "@opentelemetry/instrumentation-mysql": "0.45.1",
89
- "@opentelemetry/instrumentation-mysql2": "0.45.2",
90
- "@opentelemetry/instrumentation-pg": "0.51.1",
91
- "@opentelemetry/instrumentation-redis-4": "0.46.1",
92
- "@opentelemetry/instrumentation-tedious": "0.18.1",
93
- "@opentelemetry/instrumentation-undici": "0.10.1",
94
- "@opentelemetry/resources": "^1.30.1",
95
- "@opentelemetry/sdk-trace-base": "^1.30.1",
69
+ "@opentelemetry/context-async-hooks": "^2.0.0",
70
+ "@opentelemetry/core": "^2.0.0",
71
+ "@opentelemetry/instrumentation": "^0.203.0",
72
+ "@opentelemetry/instrumentation-amqplib": "0.50.0",
73
+ "@opentelemetry/instrumentation-connect": "0.47.0",
74
+ "@opentelemetry/instrumentation-dataloader": "0.21.0",
75
+ "@opentelemetry/instrumentation-express": "0.52.0",
76
+ "@opentelemetry/instrumentation-fs": "0.23.0",
77
+ "@opentelemetry/instrumentation-generic-pool": "0.47.0",
78
+ "@opentelemetry/instrumentation-graphql": "0.51.0",
79
+ "@opentelemetry/instrumentation-hapi": "0.50.0",
80
+ "@opentelemetry/instrumentation-http": "0.203.0",
81
+ "@opentelemetry/instrumentation-ioredis": "0.51.0",
82
+ "@opentelemetry/instrumentation-kafkajs": "0.12.0",
83
+ "@opentelemetry/instrumentation-knex": "0.48.0",
84
+ "@opentelemetry/instrumentation-koa": "0.51.0",
85
+ "@opentelemetry/instrumentation-lru-memoizer": "0.48.0",
86
+ "@opentelemetry/instrumentation-mongodb": "0.56.0",
87
+ "@opentelemetry/instrumentation-mongoose": "0.50.0",
88
+ "@opentelemetry/instrumentation-mysql": "0.49.0",
89
+ "@opentelemetry/instrumentation-mysql2": "0.49.0",
90
+ "@opentelemetry/instrumentation-pg": "0.55.0",
91
+ "@opentelemetry/instrumentation-redis": "0.51.0",
92
+ "@opentelemetry/instrumentation-tedious": "0.22.0",
93
+ "@opentelemetry/instrumentation-undici": "0.14.0",
94
+ "@opentelemetry/resources": "^2.0.0",
95
+ "@opentelemetry/sdk-trace-base": "^2.0.0",
96
96
  "@opentelemetry/semantic-conventions": "^1.34.0",
97
97
  "@prisma/instrumentation": "6.11.1",
98
- "@sentry/core": "9.40.0",
99
- "@sentry/node-core": "9.40.0",
100
- "@sentry/opentelemetry": "9.40.0",
98
+ "@sentry/core": "10.0.0-alpha.0",
99
+ "@sentry/node-core": "10.0.0-alpha.0",
100
+ "@sentry/opentelemetry": "10.0.0-alpha.0",
101
101
  "import-in-the-middle": "^1.14.2",
102
102
  "minimatch": "^9.0.0"
103
103
  },
@@ -1,22 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- /*
4
- * Copyright The OpenTelemetry Authors
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * https://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
- exports.AttributeNames = void 0; (function (AttributeNames) {
19
- const EXPRESS_TYPE = 'express.type'; AttributeNames["EXPRESS_TYPE"] = EXPRESS_TYPE;
20
- const EXPRESS_NAME = 'express.name'; AttributeNames["EXPRESS_NAME"] = EXPRESS_NAME;
21
- })(exports.AttributeNames || (exports.AttributeNames = {}));
22
- //# sourceMappingURL=AttributeNames.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AttributeNames.js","sources":["../../../../../../src/integrations/tracing/express-v5/enums/AttributeNames.ts"],"sourcesContent":["/*\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 */\nexport enum AttributeNames {\n EXPRESS_TYPE = 'express.type',\n EXPRESS_NAME = 'express.name',\n}\n"],"names":["AttributeNames"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAA,gCAAA,CAAA,CAAA,UAAA,cAAA,EAA2B;AAC3B,EAAE,MAAA,YAAA,GAAe,cAAA,CAAA,CAAA,cAAA,CAAA,cAAA,CAAA,GAAA,YAAA;AACjB,EAAE,MAAA,YAAA,GAAe,cAAA,CAAA,CAAA,cAAA,CAAA,cAAA,CAAA,GAAA,YAAA;AACjB,CAAA,EAAAA,sBAAA,KAAAA,sBAAA,GAAA,EAAA,CAAA,CAAA;;"}
@@ -1,23 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- /*
4
- * Copyright The OpenTelemetry Authors
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * https://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
- exports.ExpressLayerType = void 0; (function (ExpressLayerType) {
19
- const ROUTER = 'router'; ExpressLayerType["ROUTER"] = ROUTER;
20
- const MIDDLEWARE = 'middleware'; ExpressLayerType["MIDDLEWARE"] = MIDDLEWARE;
21
- const REQUEST_HANDLER = 'request_handler'; ExpressLayerType["REQUEST_HANDLER"] = REQUEST_HANDLER;
22
- })(exports.ExpressLayerType || (exports.ExpressLayerType = {}));
23
- //# sourceMappingURL=ExpressLayerType.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpressLayerType.js","sources":["../../../../../../src/integrations/tracing/express-v5/enums/ExpressLayerType.ts"],"sourcesContent":["/*\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 */\nexport enum ExpressLayerType {\n ROUTER = 'router',\n MIDDLEWARE = 'middleware',\n REQUEST_HANDLER = 'request_handler',\n}\n"],"names":["ExpressLayerType"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAA,kCAAA,CAAA,CAAA,UAAA,gBAAA,EAA6B;AAC7B,EAAE,MAAA,MAAA,GAAS,QAAA,CAAA,CAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,MAAA;AACX,EAAE,MAAA,UAAA,GAAa,YAAA,CAAA,CAAA,gBAAA,CAAA,YAAA,CAAA,GAAA,UAAA;AACf,EAAE,MAAA,eAAA,GAAkB,iBAAA,CAAA,CAAA,gBAAA,CAAA,iBAAA,CAAA,GAAA,eAAA;AACpB,CAAA,EAAAA,wBAAA,KAAAA,wBAAA,GAAA,EAAA,CAAA,CAAA;;"}
@@ -1,297 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const api = require('@opentelemetry/api');
4
- const core = require('@opentelemetry/core');
5
- const instrumentation = require('@opentelemetry/instrumentation');
6
- const semanticConventions = require('@opentelemetry/semantic-conventions');
7
- const AttributeNames = require('./enums/AttributeNames.js');
8
- const ExpressLayerType = require('./enums/ExpressLayerType.js');
9
- const internalTypes = require('./internal-types.js');
10
- const utils = require('./utils.js');
11
-
12
- const PACKAGE_VERSION = '0.1.0';
13
- const PACKAGE_NAME = '@sentry/instrumentation-express-v5';
14
-
15
- /** Express instrumentation for OpenTelemetry */
16
- class ExpressInstrumentationV5 extends instrumentation.InstrumentationBase {
17
- constructor(config = {}) {
18
- super(PACKAGE_NAME, PACKAGE_VERSION, config);
19
- }
20
-
21
- init() {
22
- return [
23
- new instrumentation.InstrumentationNodeModuleDefinition(
24
- 'express',
25
- ['>=5.0.0'],
26
- moduleExports => this._setup(moduleExports),
27
- moduleExports => this._tearDown(moduleExports),
28
- ),
29
- ];
30
- }
31
-
32
- _setup(moduleExports) {
33
- const routerProto = moduleExports.Router.prototype;
34
- // patch express.Router.route
35
- if (instrumentation.isWrapped(routerProto.route)) {
36
- this._unwrap(routerProto, 'route');
37
- }
38
- this._wrap(routerProto, 'route', this._getRoutePatch());
39
- // patch express.Router.use
40
- if (instrumentation.isWrapped(routerProto.use)) {
41
- this._unwrap(routerProto, 'use');
42
- }
43
- this._wrap(routerProto, 'use', this._getRouterUsePatch() );
44
- // patch express.Application.use
45
- if (instrumentation.isWrapped(moduleExports.application.use)) {
46
- this._unwrap(moduleExports.application, 'use');
47
- }
48
- this._wrap(moduleExports.application, 'use', this._getAppUsePatch() );
49
- return moduleExports;
50
- }
51
-
52
- _tearDown(moduleExports) {
53
- if (moduleExports === undefined) return;
54
- const routerProto = moduleExports.Router.prototype;
55
- this._unwrap(routerProto, 'route');
56
- this._unwrap(routerProto, 'use');
57
- this._unwrap(moduleExports.application, 'use');
58
- }
59
-
60
- /**
61
- * Get the patch for Router.route function
62
- */
63
- _getRoutePatch() {
64
- const instrumentation = this;
65
- return function (original) {
66
- return function route_trace( ...args) {
67
- const route = original.apply(this, args);
68
- const layer = this.stack[this.stack.length - 1] ;
69
- instrumentation._applyPatch(layer, utils.getLayerPath(args));
70
- return route;
71
- };
72
- };
73
- }
74
-
75
- /**
76
- * Get the patch for Router.use function
77
- */
78
- _getRouterUsePatch() {
79
- const instrumentation = this;
80
- return function (original) {
81
- return function use( ...args) {
82
- const route = original.apply(this, args);
83
- const layer = this.stack[this.stack.length - 1] ;
84
- instrumentation._applyPatch(layer, utils.getLayerPath(args));
85
- return route;
86
- };
87
- };
88
- }
89
-
90
- /**
91
- * Get the patch for Application.use function
92
- */
93
- _getAppUsePatch() {
94
- const instrumentation = this;
95
- return function (original) {
96
- return function use(
97
- // In express 5.x the router is stored in `router` whereas in 4.x it's stored in `_router`
98
-
99
- ...args
100
- ) {
101
- // if we access app.router in express 4.x we trigger an assertion error
102
- // This property existed in v3, was removed in v4 and then re-added in v5
103
- const router = this.router;
104
- const route = original.apply(this, args);
105
- if (router) {
106
- const layer = router.stack[router.stack.length - 1] ;
107
- instrumentation._applyPatch(layer, utils.getLayerPath(args));
108
- }
109
- return route;
110
- };
111
- };
112
- }
113
-
114
- /** Patch each express layer to create span and propagate context */
115
- _applyPatch( layer, layerPath) {
116
- const instrumentation$1 = this;
117
- // avoid patching multiple times the same layer
118
- if (layer[internalTypes.kLayerPatched] === true) return;
119
- layer[internalTypes.kLayerPatched] = true;
120
-
121
- this._wrap(layer, 'handle', original => {
122
- // TODO: instrument error handlers
123
- if (original.length === 4) return original;
124
-
125
- const patched = function ( req, res) {
126
- utils.storeLayerPath(req, layerPath);
127
- const route = (req[internalTypes._LAYERS_STORE_PROPERTY] )
128
- .filter(path => path !== '/' && path !== '/*')
129
- .join('')
130
- // remove duplicate slashes to normalize route
131
- .replace(/\/{2,}/g, '/');
132
-
133
- const actualRoute = route.length > 0 ? route : undefined;
134
-
135
- const attributes = {
136
- // eslint-disable-next-line deprecation/deprecation
137
- [semanticConventions.SEMATTRS_HTTP_ROUTE]: actualRoute,
138
- };
139
- const metadata = utils.getLayerMetadata(route, layer, layerPath);
140
- const type = metadata.attributes[AttributeNames.AttributeNames.EXPRESS_TYPE] ;
141
-
142
- const rpcMetadata = core.getRPCMetadata(api.context.active());
143
- if (rpcMetadata?.type === core.RPCType.HTTP) {
144
- rpcMetadata.route = actualRoute;
145
- }
146
-
147
- // verify against the config if the layer should be ignored
148
- if (utils.isLayerIgnored(metadata.name, type, instrumentation$1.getConfig())) {
149
- if (type === ExpressLayerType.ExpressLayerType.MIDDLEWARE) {
150
- (req[internalTypes._LAYERS_STORE_PROPERTY] ).pop();
151
- }
152
- return original.apply(this, arguments);
153
- }
154
-
155
- if (api.trace.getSpan(api.context.active()) === undefined) {
156
- return original.apply(this, arguments);
157
- }
158
-
159
- const spanName = instrumentation$1._getSpanName(
160
- {
161
- request: req,
162
- layerType: type,
163
- route,
164
- },
165
- metadata.name,
166
- );
167
- const span = instrumentation$1.tracer.startSpan(spanName, {
168
- attributes: Object.assign(attributes, metadata.attributes),
169
- });
170
-
171
- const { requestHook } = instrumentation$1.getConfig();
172
- if (requestHook) {
173
- instrumentation.safeExecuteInTheMiddle(
174
- () =>
175
- requestHook(span, {
176
- request: req,
177
- layerType: type,
178
- route,
179
- }),
180
- e => {
181
- if (e) {
182
- api.diag.error('express instrumentation: request hook failed', e);
183
- }
184
- },
185
- true,
186
- );
187
- }
188
-
189
- let spanHasEnded = false;
190
- if (metadata.attributes[AttributeNames.AttributeNames.EXPRESS_TYPE] !== ExpressLayerType.ExpressLayerType.MIDDLEWARE) {
191
- span.end();
192
- spanHasEnded = true;
193
- }
194
- // listener for response.on('finish')
195
- const onResponseFinish = () => {
196
- if (spanHasEnded === false) {
197
- spanHasEnded = true;
198
- span.end();
199
- }
200
- };
201
-
202
- // verify we have a callback
203
- const args = Array.from(arguments);
204
- const callbackIdx = args.findIndex(arg => typeof arg === 'function');
205
- if (callbackIdx >= 0) {
206
- arguments[callbackIdx] = function () {
207
- // express considers anything but an empty value, "route" or "router"
208
- // passed to its callback to be an error
209
- const maybeError = arguments[0];
210
- const isError = ![undefined, null, 'route', 'router'].includes(maybeError);
211
- if (!spanHasEnded && isError) {
212
- const [error, message] = utils.asErrorAndMessage(maybeError);
213
- span.recordException(error);
214
- span.setStatus({
215
- code: api.SpanStatusCode.ERROR,
216
- message,
217
- });
218
- }
219
-
220
- if (spanHasEnded === false) {
221
- spanHasEnded = true;
222
- req.res?.removeListener('finish', onResponseFinish);
223
- span.end();
224
- }
225
- if (!(req.route && isError)) {
226
- (req[internalTypes._LAYERS_STORE_PROPERTY] ).pop();
227
- }
228
- const callback = args[callbackIdx] ;
229
- return callback.apply(this, arguments);
230
- };
231
- }
232
-
233
- try {
234
- return original.apply(this, arguments);
235
- } catch (anyError) {
236
- const [error, message] = utils.asErrorAndMessage(anyError);
237
- span.recordException(error);
238
- span.setStatus({
239
- code: api.SpanStatusCode.ERROR,
240
- message,
241
- });
242
- throw anyError;
243
- } finally {
244
- /**
245
- * At this point if the callback wasn't called, that means either the
246
- * layer is asynchronous (so it will call the callback later on) or that
247
- * the layer directly end the http response, so we'll hook into the "finish"
248
- * event to handle the later case.
249
- */
250
- if (!spanHasEnded) {
251
- res.once('finish', onResponseFinish);
252
- }
253
- }
254
- };
255
-
256
- // `handle` isn't just a regular function in some cases. It also contains
257
- // some properties holding metadata and state so we need to proxy them
258
- // through through patched function
259
- // ref: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1950
260
- // Also some apps/libs do their own patching before OTEL and have these properties
261
- // in the proptotype. So we use a `for...in` loop to get own properties and also
262
- // any enumerable prop in the prototype chain
263
- // ref: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2271
264
- for (const key in original) {
265
- Object.defineProperty(patched, key, {
266
- get() {
267
- return original[key];
268
- },
269
- set(value) {
270
- original[key] = value;
271
- },
272
- });
273
- }
274
- return patched;
275
- });
276
- }
277
-
278
- _getSpanName(info, defaultName) {
279
- const { spanNameHook } = this.getConfig();
280
-
281
- if (!(spanNameHook instanceof Function)) {
282
- return defaultName;
283
- }
284
-
285
- try {
286
- return spanNameHook(info, defaultName) ?? defaultName;
287
- } catch (err) {
288
- api.diag.error('express instrumentation: error calling span name rewrite hook', err);
289
- return defaultName;
290
- }
291
- }
292
- }
293
-
294
- exports.ExpressInstrumentationV5 = ExpressInstrumentationV5;
295
- exports.PACKAGE_NAME = PACKAGE_NAME;
296
- exports.PACKAGE_VERSION = PACKAGE_VERSION;
297
- //# sourceMappingURL=instrumentation.js.map
@@ -1 +0,0 @@
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 { context, diag, SpanStatusCode, trace } from '@opentelemetry/api';\nimport { getRPCMetadata, RPCType } 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 actualRoute = route.length > 0 ? route : undefined;\n\n const attributes: Attributes = {\n // eslint-disable-next-line deprecation/deprecation\n [SEMATTRS_HTTP_ROUTE]: actualRoute,\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 = actualRoute;\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,eAAA,GAAkB;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,E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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
@@ -1 +0,0 @@
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,sBAAA,GAAyB;;;;;"}