@sentry/node 9.41.0 → 10.0.0-alpha.1

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 (73) 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/fastify/index.js +10 -56
  4. package/build/cjs/integrations/tracing/fastify/index.js.map +1 -1
  5. package/build/cjs/integrations/tracing/index.js +0 -1
  6. package/build/cjs/integrations/tracing/index.js.map +1 -1
  7. package/build/cjs/integrations/tracing/redis.js +4 -4
  8. package/build/cjs/integrations/tracing/redis.js.map +1 -1
  9. package/build/cjs/integrations/tracing/vercelai/instrumentation.js +2 -15
  10. package/build/cjs/integrations/tracing/vercelai/instrumentation.js.map +1 -1
  11. package/build/cjs/sdk/initOtel.js +8 -6
  12. package/build/cjs/sdk/initOtel.js.map +1 -1
  13. package/build/esm/integrations/tracing/express.js +1 -13
  14. package/build/esm/integrations/tracing/express.js.map +1 -1
  15. package/build/esm/integrations/tracing/fastify/index.js +10 -56
  16. package/build/esm/integrations/tracing/fastify/index.js.map +1 -1
  17. package/build/esm/integrations/tracing/index.js +1 -2
  18. package/build/esm/integrations/tracing/index.js.map +1 -1
  19. package/build/esm/integrations/tracing/redis.js +3 -3
  20. package/build/esm/integrations/tracing/redis.js.map +1 -1
  21. package/build/esm/integrations/tracing/vercelai/instrumentation.js +3 -16
  22. package/build/esm/integrations/tracing/vercelai/instrumentation.js.map +1 -1
  23. package/build/esm/package.json +1 -1
  24. package/build/esm/sdk/initOtel.js +9 -7
  25. package/build/esm/sdk/initOtel.js.map +1 -1
  26. package/build/types/integrations/tracing/express.d.ts +0 -4
  27. package/build/types/integrations/tracing/express.d.ts.map +1 -1
  28. package/build/types/integrations/tracing/fastify/index.d.ts +2 -38
  29. package/build/types/integrations/tracing/fastify/index.d.ts.map +1 -1
  30. package/build/types/integrations/tracing/index.d.ts.map +1 -1
  31. package/build/types/integrations/tracing/vercelai/instrumentation.d.ts.map +1 -1
  32. package/build/types/sdk/initOtel.d.ts.map +1 -1
  33. package/build/types-ts3.8/integrations/tracing/express.d.ts +0 -4
  34. package/build/types-ts3.8/integrations/tracing/fastify/index.d.ts +2 -38
  35. package/package.json +31 -31
  36. package/build/cjs/integrations/tracing/express-v5/enums/AttributeNames.js +0 -22
  37. package/build/cjs/integrations/tracing/express-v5/enums/AttributeNames.js.map +0 -1
  38. package/build/cjs/integrations/tracing/express-v5/enums/ExpressLayerType.js +0 -23
  39. package/build/cjs/integrations/tracing/express-v5/enums/ExpressLayerType.js.map +0 -1
  40. package/build/cjs/integrations/tracing/express-v5/instrumentation.js +0 -297
  41. package/build/cjs/integrations/tracing/express-v5/instrumentation.js.map +0 -1
  42. package/build/cjs/integrations/tracing/express-v5/internal-types.js +0 -29
  43. package/build/cjs/integrations/tracing/express-v5/internal-types.js.map +0 -1
  44. package/build/cjs/integrations/tracing/express-v5/utils.js +0 -176
  45. package/build/cjs/integrations/tracing/express-v5/utils.js.map +0 -1
  46. package/build/esm/integrations/tracing/express-v5/enums/AttributeNames.js +0 -22
  47. package/build/esm/integrations/tracing/express-v5/enums/AttributeNames.js.map +0 -1
  48. package/build/esm/integrations/tracing/express-v5/enums/ExpressLayerType.js +0 -23
  49. package/build/esm/integrations/tracing/express-v5/enums/ExpressLayerType.js.map +0 -1
  50. package/build/esm/integrations/tracing/express-v5/instrumentation.js +0 -293
  51. package/build/esm/integrations/tracing/express-v5/instrumentation.js.map +0 -1
  52. package/build/esm/integrations/tracing/express-v5/internal-types.js +0 -26
  53. package/build/esm/integrations/tracing/express-v5/internal-types.js.map +0 -1
  54. package/build/esm/integrations/tracing/express-v5/utils.js +0 -169
  55. package/build/esm/integrations/tracing/express-v5/utils.js.map +0 -1
  56. package/build/types/integrations/tracing/express-v5/enums/AttributeNames.d.ts +0 -5
  57. package/build/types/integrations/tracing/express-v5/enums/AttributeNames.d.ts.map +0 -1
  58. package/build/types/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts +0 -6
  59. package/build/types/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts.map +0 -1
  60. package/build/types/integrations/tracing/express-v5/instrumentation.d.ts +0 -27
  61. package/build/types/integrations/tracing/express-v5/instrumentation.d.ts.map +0 -1
  62. package/build/types/integrations/tracing/express-v5/internal-types.d.ts +0 -38
  63. package/build/types/integrations/tracing/express-v5/internal-types.d.ts.map +0 -1
  64. package/build/types/integrations/tracing/express-v5/types.d.ts +0 -39
  65. package/build/types/integrations/tracing/express-v5/types.d.ts.map +0 -1
  66. package/build/types/integrations/tracing/express-v5/utils.d.ts +0 -51
  67. package/build/types/integrations/tracing/express-v5/utils.d.ts.map +0 -1
  68. package/build/types-ts3.8/integrations/tracing/express-v5/enums/AttributeNames.d.ts +0 -5
  69. package/build/types-ts3.8/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts +0 -6
  70. package/build/types-ts3.8/integrations/tracing/express-v5/instrumentation.d.ts +0 -27
  71. package/build/types-ts3.8/integrations/tracing/express-v5/internal-types.d.ts +0 -38
  72. package/build/types-ts3.8/integrations/tracing/express-v5/types.d.ts +0 -39
  73. package/build/types-ts3.8/integrations/tracing/express-v5/utils.d.ts +0 -57
@@ -1,40 +1,6 @@
1
1
  import type { Instrumentation, InstrumentationConfig } from '@opentelemetry/instrumentation';
2
2
  import type { FastifyInstance, FastifyReply, FastifyRequest } from './types';
3
3
  import { FastifyInstrumentationV3 } from './v3/instrumentation';
4
- /**
5
- * Options for the Fastify integration.
6
- *
7
- * `shouldHandleError` - Callback method deciding whether error should be captured and sent to Sentry
8
- * This is used on Fastify v5 where Sentry handles errors in the diagnostics channel.
9
- * Fastify v3 and v4 use `setupFastifyErrorHandler` instead.
10
- *
11
- * @example
12
- *
13
- * ```javascript
14
- * Sentry.init({
15
- * integrations: [
16
- * Sentry.fastifyIntegration({
17
- * shouldHandleError(_error, _request, reply) {
18
- * return reply.statusCode >= 500;
19
- * },
20
- * });
21
- * },
22
- * });
23
- * ```
24
- *
25
- */
26
- interface FastifyIntegrationOptions {
27
- /**
28
- * Callback method deciding whether error should be captured and sent to Sentry
29
- * This is used on Fastify v5 where Sentry handles errors in the diagnostics channel.
30
- * Fastify v3 and v4 use `setupFastifyErrorHandler` instead.
31
- *
32
- * @param error Captured Fastify error
33
- * @param request Fastify request (or any object containing at least method, routeOptions.url, and routerPath)
34
- * @param reply Fastify reply (or any object containing at least statusCode)
35
- */
36
- shouldHandleError: (error: Error, request: FastifyRequest, reply: FastifyReply) => boolean;
37
- }
38
4
  interface FastifyHandlerOptions {
39
5
  /**
40
6
  * Callback method deciding whether error should be captured and sent to Sentry
@@ -45,7 +11,6 @@ interface FastifyHandlerOptions {
45
11
  *
46
12
  * @example
47
13
  *
48
- *
49
14
  * ```javascript
50
15
  * setupFastifyErrorHandler(app, {
51
16
  * shouldHandleError(_error, _request, reply) {
@@ -54,7 +19,6 @@ interface FastifyHandlerOptions {
54
19
  * });
55
20
  * ```
56
21
  *
57
- *
58
22
  * If using TypeScript, you can cast the request and reply to get full type safety.
59
23
  *
60
24
  * ```typescript
@@ -74,7 +38,7 @@ interface FastifyHandlerOptions {
74
38
  export declare const instrumentFastifyV3: ((options?: unknown) => FastifyInstrumentationV3) & {
75
39
  id: string;
76
40
  };
77
- export declare const instrumentFastify: ((options?: unknown) => Instrumentation<InstrumentationConfig & FastifyIntegrationOptions>) & {
41
+ export declare const instrumentFastify: ((options?: unknown) => Instrumentation<InstrumentationConfig & FastifyHandlerOptions>) & {
78
42
  id: string;
79
43
  };
80
44
  /**
@@ -93,7 +57,7 @@ export declare const instrumentFastify: ((options?: unknown) => Instrumentation<
93
57
  * })
94
58
  * ```
95
59
  */
96
- export declare const fastifyIntegration: (options?: Partial<FastifyIntegrationOptions> | undefined) => import("@sentry/core").Integration;
60
+ export declare const fastifyIntegration: () => import("@sentry/core").Integration;
97
61
  /**
98
62
  * Add an Fastify error handler to capture errors to Sentry.
99
63
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/fastify/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAe7F,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,UAAU,yBAAyB;IACjC;;;;;;;;OAQG;IACH,iBAAiB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC;CAC5F;AAED,UAAU,qBAAqB;IAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,iBAAiB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC;CAC5F;AAMD,eAAO,MAAM,mBAAmB;;CAAoF,CAAC;AA0CrH,eAAO,MAAM,iBAAiB;;CAmC5B,CAAC;AAsBH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB,kGAE9B,CAAC;AAaF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAoBjH"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/fastify/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAe7F,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,UAAU,qBAAqB;IAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,iBAAiB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC;CAC5F;AAKD,eAAO,MAAM,mBAAmB;;CAAoF,CAAC;AAiCrH,eAAO,MAAM,iBAAiB;;CAqC5B,CAAC;AAYH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB,0CAAyC,CAAC;AAazE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAiBjH"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAwBhD;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,WAAW,EAAE,CAwB9D;AAED;;GAEG;AAEH,wBAAgB,wCAAwC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,CA2BzG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAwBhD;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,WAAW,EAAE,CAwB9D;AAED;;GAEG;AAEH,wBAAgB,wCAAwC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,CA0BzG"}
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/vercelai/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAC7G,OAAO,EAAE,mBAAmB,EAAuC,MAAM,gCAAgC,CAAC;AA+B1G,UAAU,gBAAgB;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,2BAA2B,EAAE,gBAAgB,GAAG,SAAS,EACzD,sBAAsB,EAAE,gBAAgB,EACxC,0BAA0B,EAAE,OAAO,GAAG,SAAS,EAC/C,uBAAuB,EAAE,OAAO,GAC/B;IAAE,YAAY,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,CAoBnD;AAED;;;;;GAKG;AACH,qBAAa,6BAA8B,SAAQ,mBAAmB;IACpE,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,UAAU,CAAsB;gBAErB,MAAM,GAAE,qBAA0B;IAIrD;;OAEG;IACI,IAAI,IAAI,+BAA+B;IAK9C;;;OAGG;IACI,eAAe,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAQlD;;OAEG;IACH,OAAO,CAAC,MAAM;CAoEf"}
1
+ {"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/vercelai/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAC7G,OAAO,EAAE,mBAAmB,EAAuC,MAAM,gCAAgC,CAAC;AAyB1G,UAAU,gBAAgB;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,2BAA2B,EAAE,gBAAgB,GAAG,SAAS,EACzD,sBAAsB,EAAE,gBAAgB,EACxC,0BAA0B,EAAE,OAAO,GAAG,SAAS,EAC/C,uBAAuB,EAAE,OAAO,GAC/B;IAAE,YAAY,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,CAoBnD;AAED;;;;;GAKG;AACH,qBAAa,6BAA8B,SAAQ,mBAAmB;IACpE,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,UAAU,CAAsB;gBAErB,MAAM,GAAE,qBAA0B;IAIrD;;OAEG;IACI,IAAI,IAAI,+BAA+B;IAK9C;;;OAGG;IACI,eAAe,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAQlD;;OAEG;IACH,OAAO,CAAC,MAAM;CAuDf"}
@@ -1 +1 @@
1
- {"version":3,"file":"initOtel.d.ts","sourceRoot":"","sources":["../../../src/sdk/initOtel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAOpE,OAAO,EAAE,KAAK,UAAU,EAAyD,MAAM,mBAAmB,CAAC;AAU3G,UAAU,8BAA8B;IACtC,8DAA8D;IAC9D,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,GAAE,8BAAmC,GAAG,IAAI,CAOxG;AAED,iCAAiC;AACjC,wBAAgB,wBAAwB,IAAI,IAAI,CAyB/C;AAED,UAAU,kBAAkB;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,kBAAuB,GAAG,IAAI,CAmB3E;AAYD,+BAA+B;AAC/B,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,GAAE,8BAAmC,GAAG,mBAAmB,CAyB/G;AAED,+BAA+B;AAC/B,wBAAgB,0BAA0B,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAiBtG"}
1
+ {"version":3,"file":"initOtel.d.ts","sourceRoot":"","sources":["../../../src/sdk/initOtel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAOpE,OAAO,EAAE,KAAK,UAAU,EAAyD,MAAM,mBAAmB,CAAC;AAU3G,UAAU,8BAA8B;IACtC,8DAA8D;IAC9D,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,GAAE,8BAAmC,GAAG,IAAI,CAOxG;AAED,iCAAiC;AACjC,wBAAgB,wBAAwB,IAAI,IAAI,CAyB/C;AAED,UAAU,kBAAkB;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,kBAAuB,GAAG,IAAI,CAmB3E;AAYD,+BAA+B;AAC/B,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,GAAE,8BAAmC,GAAG,mBAAmB,CA2B/G;AAED,+BAA+B;AAC/B,wBAAgB,0BAA0B,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAiBtG"}
@@ -1,13 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  import * as http from 'node:http';
3
3
  import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
4
- import { ExpressInstrumentationV5 } from './express-v5/instrumentation';
5
4
  export declare const instrumentExpress: ((options?: unknown) => ExpressInstrumentation) & {
6
5
  id: string;
7
6
  };
8
- export declare const instrumentExpressV5: ((options?: unknown) => ExpressInstrumentationV5) & {
9
- id: string;
10
- };
11
7
  /**
12
8
  * Adds Sentry tracing instrumentation for [Express](https://expressjs.com/).
13
9
  *
@@ -1,40 +1,6 @@
1
1
  import { Instrumentation, InstrumentationConfig } from '@opentelemetry/instrumentation';
2
2
  import { FastifyInstance, FastifyReply, FastifyRequest } from './types';
3
3
  import { FastifyInstrumentationV3 } from './v3/instrumentation';
4
- /**
5
- * Options for the Fastify integration.
6
- *
7
- * `shouldHandleError` - Callback method deciding whether error should be captured and sent to Sentry
8
- * This is used on Fastify v5 where Sentry handles errors in the diagnostics channel.
9
- * Fastify v3 and v4 use `setupFastifyErrorHandler` instead.
10
- *
11
- * @example
12
- *
13
- * ```javascript
14
- * Sentry.init({
15
- * integrations: [
16
- * Sentry.fastifyIntegration({
17
- * shouldHandleError(_error, _request, reply) {
18
- * return reply.statusCode >= 500;
19
- * },
20
- * });
21
- * },
22
- * });
23
- * ```
24
- *
25
- */
26
- interface FastifyIntegrationOptions {
27
- /**
28
- * Callback method deciding whether error should be captured and sent to Sentry
29
- * This is used on Fastify v5 where Sentry handles errors in the diagnostics channel.
30
- * Fastify v3 and v4 use `setupFastifyErrorHandler` instead.
31
- *
32
- * @param error Captured Fastify error
33
- * @param request Fastify request (or any object containing at least method, routeOptions.url, and routerPath)
34
- * @param reply Fastify reply (or any object containing at least statusCode)
35
- */
36
- shouldHandleError: (error: Error, request: FastifyRequest, reply: FastifyReply) => boolean;
37
- }
38
4
  interface FastifyHandlerOptions {
39
5
  /**
40
6
  * Callback method deciding whether error should be captured and sent to Sentry
@@ -45,7 +11,6 @@ interface FastifyHandlerOptions {
45
11
  *
46
12
  * @example
47
13
  *
48
- *
49
14
  * ```javascript
50
15
  * setupFastifyErrorHandler(app, {
51
16
  * shouldHandleError(_error, _request, reply) {
@@ -54,7 +19,6 @@ interface FastifyHandlerOptions {
54
19
  * });
55
20
  * ```
56
21
  *
57
- *
58
22
  * If using TypeScript, you can cast the request and reply to get full type safety.
59
23
  *
60
24
  * ```typescript
@@ -74,7 +38,7 @@ interface FastifyHandlerOptions {
74
38
  export declare const instrumentFastifyV3: ((options?: unknown) => FastifyInstrumentationV3) & {
75
39
  id: string;
76
40
  };
77
- export declare const instrumentFastify: ((options?: unknown) => Instrumentation<InstrumentationConfig & FastifyIntegrationOptions>) & {
41
+ export declare const instrumentFastify: ((options?: unknown) => Instrumentation<InstrumentationConfig & FastifyHandlerOptions>) & {
78
42
  id: string;
79
43
  };
80
44
  /**
@@ -93,7 +57,7 @@ export declare const instrumentFastify: ((options?: unknown) => Instrumentation<
93
57
  * })
94
58
  * ```
95
59
  */
96
- export declare const fastifyIntegration: (options?: Partial<FastifyIntegrationOptions> | undefined) => import("@sentry/core").Integration;
60
+ export declare const fastifyIntegration: () => import("@sentry/core").Integration;
97
61
  /**
98
62
  * Add an Fastify error handler to capture errors to Sentry.
99
63
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/node",
3
- "version": "9.41.0",
3
+ "version": "10.0.0-alpha.1",
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.41.0",
99
- "@sentry/node-core": "9.41.0",
100
- "@sentry/opentelemetry": "9.41.0",
98
+ "@sentry/core": "10.0.0-alpha.1",
99
+ "@sentry/node-core": "10.0.0-alpha.1",
100
+ "@sentry/opentelemetry": "10.0.0-alpha.1",
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