@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
@@ -1,169 +0,0 @@
1
- import { AttributeNames } from './enums/AttributeNames.js';
2
- import { ExpressLayerType } from './enums/ExpressLayerType.js';
3
- import { _LAYERS_STORE_PROPERTY } from './internal-types.js';
4
-
5
- /**
6
- * Store layers path in the request to be able to construct route later
7
- * @param request The request where
8
- * @param [value] the value to push into the array
9
- */
10
- const storeLayerPath = (request, value) => {
11
- if (Array.isArray(request[_LAYERS_STORE_PROPERTY]) === false) {
12
- Object.defineProperty(request, _LAYERS_STORE_PROPERTY, {
13
- enumerable: false,
14
- value: [],
15
- });
16
- }
17
- if (value === undefined) return;
18
- (request[_LAYERS_STORE_PROPERTY] ).push(value);
19
- };
20
-
21
- /**
22
- * Recursively search the router path from layer stack
23
- * @param path The path to reconstruct
24
- * @param layer The layer to reconstruct from
25
- * @returns The reconstructed path
26
- */
27
- const getRouterPath = (path, layer) => {
28
- const stackLayer = layer.handle?.stack?.[0];
29
-
30
- if (stackLayer?.route?.path) {
31
- return `${path}${stackLayer.route.path}`;
32
- }
33
-
34
- if (stackLayer?.handle?.stack) {
35
- return getRouterPath(path, stackLayer);
36
- }
37
-
38
- return path;
39
- };
40
-
41
- /**
42
- * Parse express layer context to retrieve a name and attributes.
43
- * @param route The route of the layer
44
- * @param layer Express layer
45
- * @param [layerPath] if present, the path on which the layer has been mounted
46
- */
47
- const getLayerMetadata = (
48
- route,
49
- layer,
50
- layerPath,
51
-
52
- ) => {
53
- if (layer.name === 'router') {
54
- const maybeRouterPath = getRouterPath('', layer);
55
- const extractedRouterPath = maybeRouterPath ? maybeRouterPath : layerPath || route || '/';
56
-
57
- return {
58
- attributes: {
59
- [AttributeNames.EXPRESS_NAME]: extractedRouterPath,
60
- [AttributeNames.EXPRESS_TYPE]: ExpressLayerType.ROUTER,
61
- },
62
- name: `router - ${extractedRouterPath}`,
63
- };
64
- } else if (layer.name === 'bound dispatch' || layer.name === 'handle') {
65
- return {
66
- attributes: {
67
- [AttributeNames.EXPRESS_NAME]: (route || layerPath) ?? 'request handler',
68
- [AttributeNames.EXPRESS_TYPE]: ExpressLayerType.REQUEST_HANDLER,
69
- },
70
- name: `request handler${layer.path ? ` - ${route || layerPath}` : ''}`,
71
- };
72
- } else {
73
- return {
74
- attributes: {
75
- [AttributeNames.EXPRESS_NAME]: layer.name,
76
- [AttributeNames.EXPRESS_TYPE]: ExpressLayerType.MIDDLEWARE,
77
- },
78
- name: `middleware - ${layer.name}`,
79
- };
80
- }
81
- };
82
-
83
- /**
84
- * Check whether the given obj match pattern
85
- * @param constant e.g URL of request
86
- * @param obj obj to inspect
87
- * @param pattern Match pattern
88
- */
89
- const satisfiesPattern = (constant, pattern) => {
90
- if (typeof pattern === 'string') {
91
- return pattern === constant;
92
- } else if (pattern instanceof RegExp) {
93
- return pattern.test(constant);
94
- } else if (typeof pattern === 'function') {
95
- return pattern(constant);
96
- } else {
97
- throw new TypeError('Pattern is in unsupported datatype');
98
- }
99
- };
100
-
101
- /**
102
- * Check whether the given request is ignored by configuration
103
- * It will not re-throw exceptions from `list` provided by the client
104
- * @param constant e.g URL of request
105
- * @param [list] List of ignore patterns
106
- * @param [onException] callback for doing something when an exception has
107
- * occurred
108
- */
109
- const isLayerIgnored = (
110
- name,
111
- type,
112
- config,
113
- ) => {
114
- if (Array.isArray(config?.ignoreLayersType) && config?.ignoreLayersType?.includes(type)) {
115
- return true;
116
- }
117
- if (Array.isArray(config?.ignoreLayers) === false) return false;
118
- try {
119
- for (const pattern of config.ignoreLayers) {
120
- if (satisfiesPattern(name, pattern)) {
121
- return true;
122
- }
123
- }
124
- } catch {
125
- /* catch block */
126
- }
127
-
128
- return false;
129
- };
130
-
131
- /**
132
- * Converts a user-provided error value into an error and error message pair
133
- *
134
- * @param error - User-provided error value
135
- * @returns Both an Error or string representation of the value and an error message
136
- */
137
- const asErrorAndMessage = (error) =>
138
- error instanceof Error ? [error, error.message] : [String(error), String(error)];
139
-
140
- /**
141
- * Extracts the layer path from the route arguments
142
- *
143
- * @param args - Arguments of the route
144
- * @returns The layer path
145
- */
146
- const getLayerPath = (args) => {
147
- const firstArg = args[0];
148
-
149
- if (Array.isArray(firstArg)) {
150
- return firstArg.map(arg => extractLayerPathSegment(arg) || '').join(',');
151
- }
152
-
153
- return extractLayerPathSegment(firstArg);
154
- };
155
-
156
- const extractLayerPathSegment = (arg) => {
157
- if (typeof arg === 'string') {
158
- return arg;
159
- }
160
-
161
- if (arg instanceof RegExp || typeof arg === 'number') {
162
- return arg.toString();
163
- }
164
-
165
- return;
166
- };
167
-
168
- export { asErrorAndMessage, getLayerMetadata, getLayerPath, getRouterPath, isLayerIgnored, storeLayerPath };
169
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
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 {\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":[],"mappings":";;;;AA2BA;AACA;AACA;AACA;AACA;MACa,cAAA,GAAiB,CAAC,OAAO,EAAkB,KAAK,KAAoB;AACjF,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAA,KAAM,KAAK,EAAE;AAChE,IAAI,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,sBAAsB,EAAE;AAC3D,MAAM,UAAU,EAAE,KAAK;AACvB,MAAM,KAAK,EAAE,EAAE;AACf,KAAK,CAAC;AACN;AACA,EAAE,IAAI,KAAA,KAAU,SAAS,EAAE;AAC3B,EAAE,CAAC,OAAO,CAAC,sBAAsB,CAAA,GAAe,IAAI,CAAC,KAAK,CAAC;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA;MACa,aAAA,GAAgB,CAAC,IAAI,EAAU,KAAK,KAA2B;AAC5E,EAAE,MAAM,UAAA,GAAa,KAAK,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC;;AAE7C,EAAE,IAAI,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE;AAC/B,IAAI,OAAO,CAAC,EAAA,IAAA,CAAA,EAAA,UAAA,CAAA,KAAA,CAAA,IAAA,CAAA,CAAA;AACA;;AAEA,EAAA,IAAA,UAAA,EAAA,MAAA,EAAA,KAAA,EAAA;AACA,IAAA,OAAA,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA;AACA;;AAEA,EAAA,OAAA,IAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAA,gBAAA,GAAA;AACA,EAAA,KAAA;AACA,EAAA,KAAA;AACA,EAAA,SAAA;;AAIA,KAAA;AACA,EAAA,IAAA,KAAA,CAAA,IAAA,KAAA,QAAA,EAAA;AACA,IAAA,MAAA,eAAA,GA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IAAA,KAAA,CAAA,OAAA,CAAA,QAAA,CAAA,EAAA;AACA,IAAA,OAAA,QAAA,CAAA,GAAA,CAAA,GAAA,IAAA,uBAAA,CAAA,GAAA,CAAA,IAAA,EAAA,CAAA,CAAA,IAAA,CAAA,GAAA,CAAA;AACA;;AAEA,EAAA,OAAA,uBAAA,CAAA,QAAA,CAAA;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;;;;"}
@@ -1,5 +0,0 @@
1
- export declare enum AttributeNames {
2
- EXPRESS_TYPE = "express.type",
3
- EXPRESS_NAME = "express.name"
4
- }
5
- //# sourceMappingURL=AttributeNames.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AttributeNames.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/tracing/express-v5/enums/AttributeNames.ts"],"names":[],"mappings":"AAeA,oBAAY,cAAc;IACxB,YAAY,iBAAiB;IAC7B,YAAY,iBAAiB;CAC9B"}
@@ -1,6 +0,0 @@
1
- export declare enum ExpressLayerType {
2
- ROUTER = "router",
3
- MIDDLEWARE = "middleware",
4
- REQUEST_HANDLER = "request_handler"
5
- }
6
- //# sourceMappingURL=ExpressLayerType.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpressLayerType.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/tracing/express-v5/enums/ExpressLayerType.ts"],"names":[],"mappings":"AAeA,oBAAY,gBAAgB;IAC1B,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,eAAe,oBAAoB;CACpC"}
@@ -1,27 +0,0 @@
1
- import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
2
- import type { ExpressInstrumentationConfig, ExpressRequestInfo } from './types';
3
- export declare const PACKAGE_VERSION = "0.1.0";
4
- export declare const PACKAGE_NAME = "@sentry/instrumentation-express-v5";
5
- /** Express instrumentation for OpenTelemetry */
6
- export declare class ExpressInstrumentationV5 extends InstrumentationBase<ExpressInstrumentationConfig> {
7
- constructor(config?: ExpressInstrumentationConfig);
8
- init(): InstrumentationNodeModuleDefinition[];
9
- private _setup;
10
- private _tearDown;
11
- /**
12
- * Get the patch for Router.route function
13
- */
14
- private _getRoutePatch;
15
- /**
16
- * Get the patch for Router.use function
17
- */
18
- private _getRouterUsePatch;
19
- /**
20
- * Get the patch for Application.use function
21
- */
22
- private _getAppUsePatch;
23
- /** Patch each express layer to create span and propagate context */
24
- private _applyPatch;
25
- _getSpanName(info: ExpressRequestInfo, defaultName: string): string;
26
- }
27
- //# sourceMappingURL=instrumentation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/express-v5/instrumentation.ts"],"names":[],"mappings":"AA8BA,OAAO,EACL,mBAAmB,EACnB,mCAAmC,EAGpC,MAAM,gCAAgC,CAAC;AAOxC,OAAO,KAAK,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGhF,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,YAAY,uCAAuC,CAAC;AAEjE,gDAAgD;AAChD,qBAAa,wBAAyB,SAAQ,mBAAmB,CAAC,4BAA4B,CAAC;gBACjF,MAAM,GAAE,4BAAiC;IAIrD,IAAI;IAWJ,OAAO,CAAC,MAAM;IAoBd,OAAO,CAAC,SAAS;IAQjB;;OAEG;IACH,OAAO,CAAC,cAAc;IAYtB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAY1B;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB,oEAAoE;IACpE,OAAO,CAAC,WAAW;IAmKnB,YAAY,CAAC,IAAI,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM;CAc3D"}
@@ -1,38 +0,0 @@
1
- import type { Request } from 'express';
2
- /**
3
- * This symbol is used to mark express layer as being already instrumented
4
- * since its possible to use a given layer multiple times (ex: middlewares)
5
- */
6
- export declare const kLayerPatched: unique symbol;
7
- /**
8
- * This const define where on the `request` object the Instrumentation will mount the
9
- * current stack of express layer.
10
- *
11
- * It is necessary because express doesn't store the different layers
12
- * (ie: middleware, router etc) that it called to get to the current layer.
13
- * Given that, the only way to know the route of a given layer is to
14
- * store the path of where each previous layer has been mounted.
15
- *
16
- * ex: bodyParser > auth middleware > /users router > get /:id
17
- * in this case the stack would be: ["/users", "/:id"]
18
- *
19
- * ex2: bodyParser > /api router > /v1 router > /users router > get /:id
20
- * stack: ["/api", "/v1", "/users", ":id"]
21
- *
22
- */
23
- export declare const _LAYERS_STORE_PROPERTY = "__ot_middlewares";
24
- export type PatchedRequest = {
25
- [_LAYERS_STORE_PROPERTY]?: string[];
26
- } & Request;
27
- export type PathParams = string | RegExp | Array<string | RegExp>;
28
- export type ExpressRouter = {
29
- stack: ExpressLayer[];
30
- };
31
- export type ExpressLayer = {
32
- handle: Function & Record<string, any>;
33
- [kLayerPatched]?: boolean;
34
- name: string;
35
- path: string;
36
- route?: ExpressLayer;
37
- };
38
- //# sourceMappingURL=internal-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal-types.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/express-v5/internal-types.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,OAAO,MAAwC,CAAC;AAE5E;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,sBAAsB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;CACrC,GAAG,OAAO,CAAC;AACZ,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;AAGlE,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB,CAAC;AAGF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC,aAAa,CAAC,CAAC,EAAE,OAAO,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB,CAAC"}
@@ -1,39 +0,0 @@
1
- import type { Span } from '@opentelemetry/api';
2
- import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
3
- import type { ExpressLayerType } from './enums/ExpressLayerType';
4
- export type LayerPathSegment = string | RegExp | number;
5
- export type IgnoreMatcher = string | RegExp | ((name: string) => boolean);
6
- export type ExpressRequestInfo<T = any> = {
7
- /** An express request object */
8
- request: T;
9
- route: string;
10
- layerType: ExpressLayerType;
11
- };
12
- export type SpanNameHook = (info: ExpressRequestInfo,
13
- /**
14
- * If no decision is taken based on RequestInfo, the default name
15
- * supplied by the instrumentation can be used instead.
16
- */
17
- defaultName: string) => string;
18
- /**
19
- * Function that can be used to add custom attributes to the current span or the root span on
20
- * a Express request
21
- * @param span - The Express middleware layer span.
22
- * @param info - An instance of ExpressRequestInfo that contains info about the request such as the route, and the layer type.
23
- */
24
- export interface ExpressRequestCustomAttributeFunction {
25
- (span: Span, info: ExpressRequestInfo): void;
26
- }
27
- /**
28
- * Options available for the Express Instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express#express-instrumentation-options))
29
- */
30
- export interface ExpressInstrumentationConfig extends InstrumentationConfig {
31
- /** Ignore specific based on their name */
32
- ignoreLayers?: IgnoreMatcher[];
33
- /** Ignore specific layers based on their type */
34
- ignoreLayersType?: ExpressLayerType[];
35
- spanNameHook?: SpanNameHook;
36
- /** Function for adding custom attributes on Express request */
37
- requestHook?: ExpressRequestCustomAttributeFunction;
38
- }
39
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/express-v5/types.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;AAE1E,MAAM,MAAM,kBAAkB,CAAC,CAAC,GAAG,GAAG,IAAI;IACxC,gCAAgC;IAChC,OAAO,EAAE,CAAC,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,gBAAgB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,CACzB,IAAI,EAAE,kBAAkB;AACxB;;;GAGG;AACH,WAAW,EAAE,MAAM,KAChB,MAAM,CAAC;AAEZ;;;;;GAKG;AACH,MAAM,WAAW,qCAAqC;IACpD,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,qBAAqB;IACzE,0CAA0C;IAC1C,YAAY,CAAC,EAAE,aAAa,EAAE,CAAC;IAC/B,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACtC,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B,+DAA+D;IAC/D,WAAW,CAAC,EAAE,qCAAqC,CAAC;CACrD"}
@@ -1,51 +0,0 @@
1
- import type { Attributes } from '@opentelemetry/api';
2
- import { ExpressLayerType } from './enums/ExpressLayerType';
3
- import type { ExpressLayer, PatchedRequest } from './internal-types';
4
- import type { ExpressInstrumentationConfig, LayerPathSegment } from './types';
5
- /**
6
- * Store layers path in the request to be able to construct route later
7
- * @param request The request where
8
- * @param [value] the value to push into the array
9
- */
10
- export declare const storeLayerPath: (request: PatchedRequest, value?: string) => void;
11
- /**
12
- * Recursively search the router path from layer stack
13
- * @param path The path to reconstruct
14
- * @param layer The layer to reconstruct from
15
- * @returns The reconstructed path
16
- */
17
- export declare const getRouterPath: (path: string, layer: ExpressLayer) => string;
18
- /**
19
- * Parse express layer context to retrieve a name and attributes.
20
- * @param route The route of the layer
21
- * @param layer Express layer
22
- * @param [layerPath] if present, the path on which the layer has been mounted
23
- */
24
- export declare const getLayerMetadata: (route: string, layer: ExpressLayer, layerPath?: string) => {
25
- attributes: Attributes;
26
- name: string;
27
- };
28
- /**
29
- * Check whether the given request is ignored by configuration
30
- * It will not re-throw exceptions from `list` provided by the client
31
- * @param constant e.g URL of request
32
- * @param [list] List of ignore patterns
33
- * @param [onException] callback for doing something when an exception has
34
- * occurred
35
- */
36
- export declare const isLayerIgnored: (name: string, type: ExpressLayerType, config?: ExpressInstrumentationConfig) => boolean;
37
- /**
38
- * Converts a user-provided error value into an error and error message pair
39
- *
40
- * @param error - User-provided error value
41
- * @returns Both an Error or string representation of the value and an error message
42
- */
43
- export declare const asErrorAndMessage: (error: unknown) => [error: string | Error, message: string];
44
- /**
45
- * Extracts the layer path from the route arguments
46
- *
47
- * @param args - Arguments of the route
48
- * @returns The layer path
49
- */
50
- export declare const getLayerPath: (args: [LayerPathSegment | LayerPathSegment[], ...unknown[]]) => string | undefined;
51
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/express-v5/utils.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,KAAK,EAAE,4BAA4B,EAAiB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE7F;;;;GAIG;AACH,eAAO,MAAM,cAAc,YAAa,cAAc,UAAU,MAAM,KAAG,IASxE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAU,MAAM,SAAS,YAAY,KAAG,MAYjE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UACpB,MAAM,SACN,YAAY,cACP,MAAM,KACjB;IACD,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,MAAM,CAAC;CA8Bd,CAAC;AAoBF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,SACnB,MAAM,QACN,gBAAgB,WACb,4BAA4B,KACpC,OAgBF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,UAAW,OAAO,6CACkC,CAAC;AAEnF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,SAAU,CAAC,gBAAgB,GAAG,gBAAgB,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,KAAG,MAAM,GAAG,SAQnG,CAAC"}
@@ -1,5 +0,0 @@
1
- export declare enum AttributeNames {
2
- EXPRESS_TYPE = "express.type",
3
- EXPRESS_NAME = "express.name"
4
- }
5
- //# sourceMappingURL=AttributeNames.d.ts.map
@@ -1,6 +0,0 @@
1
- export declare enum ExpressLayerType {
2
- ROUTER = "router",
3
- MIDDLEWARE = "middleware",
4
- REQUEST_HANDLER = "request_handler"
5
- }
6
- //# sourceMappingURL=ExpressLayerType.d.ts.map
@@ -1,27 +0,0 @@
1
- import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
2
- import { ExpressInstrumentationConfig, ExpressRequestInfo } from './types';
3
- export declare const PACKAGE_VERSION = "0.1.0";
4
- export declare const PACKAGE_NAME = "@sentry/instrumentation-express-v5";
5
- /** Express instrumentation for OpenTelemetry */
6
- export declare class ExpressInstrumentationV5 extends InstrumentationBase<ExpressInstrumentationConfig> {
7
- constructor(config?: ExpressInstrumentationConfig);
8
- init(): InstrumentationNodeModuleDefinition[];
9
- private _setup;
10
- private _tearDown;
11
- /**
12
- * Get the patch for Router.route function
13
- */
14
- private _getRoutePatch;
15
- /**
16
- * Get the patch for Router.use function
17
- */
18
- private _getRouterUsePatch;
19
- /**
20
- * Get the patch for Application.use function
21
- */
22
- private _getAppUsePatch;
23
- /** Patch each express layer to create span and propagate context */
24
- private _applyPatch;
25
- _getSpanName(info: ExpressRequestInfo, defaultName: string): string;
26
- }
27
- //# sourceMappingURL=instrumentation.d.ts.map
@@ -1,38 +0,0 @@
1
- import { Request } from 'express';
2
- /**
3
- * This symbol is used to mark express layer as being already instrumented
4
- * since its possible to use a given layer multiple times (ex: middlewares)
5
- */
6
- export declare const kLayerPatched: unique symbol;
7
- /**
8
- * This const define where on the `request` object the Instrumentation will mount the
9
- * current stack of express layer.
10
- *
11
- * It is necessary because express doesn't store the different layers
12
- * (ie: middleware, router etc) that it called to get to the current layer.
13
- * Given that, the only way to know the route of a given layer is to
14
- * store the path of where each previous layer has been mounted.
15
- *
16
- * ex: bodyParser > auth middleware > /users router > get /:id
17
- * in this case the stack would be: ["/users", "/:id"]
18
- *
19
- * ex2: bodyParser > /api router > /v1 router > /users router > get /:id
20
- * stack: ["/api", "/v1", "/users", ":id"]
21
- *
22
- */
23
- export declare const _LAYERS_STORE_PROPERTY = "__ot_middlewares";
24
- export type PatchedRequest = {
25
- [_LAYERS_STORE_PROPERTY]?: string[];
26
- } & Request;
27
- export type PathParams = string | RegExp | Array<string | RegExp>;
28
- export type ExpressRouter = {
29
- stack: ExpressLayer[];
30
- };
31
- export type ExpressLayer = {
32
- handle: Function & Record<string, any>;
33
- [kLayerPatched]?: boolean;
34
- name: string;
35
- path: string;
36
- route?: ExpressLayer;
37
- };
38
- //# sourceMappingURL=internal-types.d.ts.map
@@ -1,39 +0,0 @@
1
- import { Span } from '@opentelemetry/api';
2
- import { InstrumentationConfig } from '@opentelemetry/instrumentation';
3
- import { ExpressLayerType } from './enums/ExpressLayerType';
4
- export type LayerPathSegment = string | RegExp | number;
5
- export type IgnoreMatcher = string | RegExp | ((name: string) => boolean);
6
- export type ExpressRequestInfo<T = any> = {
7
- /** An express request object */
8
- request: T;
9
- route: string;
10
- layerType: ExpressLayerType;
11
- };
12
- export type SpanNameHook = (info: ExpressRequestInfo,
13
- /**
14
- * If no decision is taken based on RequestInfo, the default name
15
- * supplied by the instrumentation can be used instead.
16
- */
17
- defaultName: string) => string;
18
- /**
19
- * Function that can be used to add custom attributes to the current span or the root span on
20
- * a Express request
21
- * @param span - The Express middleware layer span.
22
- * @param info - An instance of ExpressRequestInfo that contains info about the request such as the route, and the layer type.
23
- */
24
- export interface ExpressRequestCustomAttributeFunction {
25
- (span: Span, info: ExpressRequestInfo): void;
26
- }
27
- /**
28
- * Options available for the Express Instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express#express-instrumentation-options))
29
- */
30
- export interface ExpressInstrumentationConfig extends InstrumentationConfig {
31
- /** Ignore specific based on their name */
32
- ignoreLayers?: IgnoreMatcher[];
33
- /** Ignore specific layers based on their type */
34
- ignoreLayersType?: ExpressLayerType[];
35
- spanNameHook?: SpanNameHook;
36
- /** Function for adding custom attributes on Express request */
37
- requestHook?: ExpressRequestCustomAttributeFunction;
38
- }
39
- //# sourceMappingURL=types.d.ts.map
@@ -1,57 +0,0 @@
1
- import { Attributes } from '@opentelemetry/api';
2
- import { ExpressLayerType } from './enums/ExpressLayerType';
3
- import { ExpressLayer, PatchedRequest } from './internal-types';
4
- import { ExpressInstrumentationConfig, LayerPathSegment } from './types';
5
- /**
6
- * Store layers path in the request to be able to construct route later
7
- * @param request The request where
8
- * @param [value] the value to push into the array
9
- */
10
- export declare const storeLayerPath: (request: PatchedRequest, value?: string) => void;
11
- /**
12
- * Recursively search the router path from layer stack
13
- * @param path The path to reconstruct
14
- * @param layer The layer to reconstruct from
15
- * @returns The reconstructed path
16
- */
17
- export declare const getRouterPath: (path: string, layer: ExpressLayer) => string;
18
- /**
19
- * Parse express layer context to retrieve a name and attributes.
20
- * @param route The route of the layer
21
- * @param layer Express layer
22
- * @param [layerPath] if present, the path on which the layer has been mounted
23
- */
24
- export declare const getLayerMetadata: (route: string, layer: ExpressLayer, layerPath?: string) => {
25
- attributes: Attributes;
26
- name: string;
27
- };
28
- /**
29
- * Check whether the given request is ignored by configuration
30
- * It will not re-throw exceptions from `list` provided by the client
31
- * @param constant e.g URL of request
32
- * @param [list] List of ignore patterns
33
- * @param [onException] callback for doing something when an exception has
34
- * occurred
35
- */
36
- export declare const isLayerIgnored: (name: string, type: ExpressLayerType, config?: ExpressInstrumentationConfig) => boolean;
37
- /**
38
- * Converts a user-provided error value into an error and error message pair
39
- *
40
- * @param error - User-provided error value
41
- * @returns Both an Error or string representation of the value and an error message
42
- */
43
- export declare const asErrorAndMessage: (error: unknown) => [
44
- /*error*/ string | Error,
45
- /*message*/ string
46
- ];
47
- /**
48
- * Extracts the layer path from the route arguments
49
- *
50
- * @param args - Arguments of the route
51
- * @returns The layer path
52
- */
53
- export declare const getLayerPath: (args: [
54
- LayerPathSegment | LayerPathSegment[],
55
- ...unknown[]
56
- ]) => string | undefined;
57
- //# sourceMappingURL=utils.d.ts.map