@sentry/node 9.39.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 (102) hide show
  1. package/build/cjs/index.js +9 -7
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/cjs/integrations/tracing/express.js +1 -14
  4. package/build/cjs/integrations/tracing/express.js.map +1 -1
  5. package/build/cjs/integrations/tracing/fastify/index.js +2 -2
  6. package/build/cjs/integrations/tracing/fastify/index.js.map +1 -1
  7. package/build/cjs/integrations/tracing/hapi/index.js +1 -1
  8. package/build/cjs/integrations/tracing/hapi/index.js.map +1 -1
  9. package/build/cjs/integrations/tracing/index.js +3 -1
  10. package/build/cjs/integrations/tracing/index.js.map +1 -1
  11. package/build/cjs/integrations/tracing/koa.js +1 -1
  12. package/build/cjs/integrations/tracing/koa.js.map +1 -1
  13. package/build/cjs/integrations/tracing/openai/index.js +79 -0
  14. package/build/cjs/integrations/tracing/openai/index.js.map +1 -0
  15. package/build/cjs/integrations/tracing/openai/instrumentation.js +81 -0
  16. package/build/cjs/integrations/tracing/openai/instrumentation.js.map +1 -0
  17. package/build/cjs/integrations/tracing/postgresjs.js +1 -1
  18. package/build/cjs/integrations/tracing/postgresjs.js.map +1 -1
  19. package/build/cjs/integrations/tracing/redis.js +4 -4
  20. package/build/cjs/integrations/tracing/redis.js.map +1 -1
  21. package/build/cjs/sdk/initOtel.js +13 -11
  22. package/build/cjs/sdk/initOtel.js.map +1 -1
  23. package/build/cjs/utils/redisCache.js +2 -2
  24. package/build/cjs/utils/redisCache.js.map +1 -1
  25. package/build/esm/index.js +1 -0
  26. package/build/esm/index.js.map +1 -1
  27. package/build/esm/integrations/tracing/express.js +3 -15
  28. package/build/esm/integrations/tracing/express.js.map +1 -1
  29. package/build/esm/integrations/tracing/fastify/index.js +3 -3
  30. package/build/esm/integrations/tracing/fastify/index.js.map +1 -1
  31. package/build/esm/integrations/tracing/hapi/index.js +2 -2
  32. package/build/esm/integrations/tracing/hapi/index.js.map +1 -1
  33. package/build/esm/integrations/tracing/index.js +4 -2
  34. package/build/esm/integrations/tracing/index.js.map +1 -1
  35. package/build/esm/integrations/tracing/koa.js +2 -2
  36. package/build/esm/integrations/tracing/koa.js.map +1 -1
  37. package/build/esm/integrations/tracing/openai/index.js +76 -0
  38. package/build/esm/integrations/tracing/openai/index.js.map +1 -0
  39. package/build/esm/integrations/tracing/openai/instrumentation.js +79 -0
  40. package/build/esm/integrations/tracing/openai/instrumentation.js.map +1 -0
  41. package/build/esm/integrations/tracing/postgresjs.js +2 -2
  42. package/build/esm/integrations/tracing/postgresjs.js.map +1 -1
  43. package/build/esm/integrations/tracing/redis.js +3 -3
  44. package/build/esm/integrations/tracing/redis.js.map +1 -1
  45. package/build/esm/package.json +1 -1
  46. package/build/esm/sdk/initOtel.js +18 -16
  47. package/build/esm/sdk/initOtel.js.map +1 -1
  48. package/build/esm/utils/redisCache.js +2 -2
  49. package/build/esm/utils/redisCache.js.map +1 -1
  50. package/build/types/index.d.ts +1 -0
  51. package/build/types/index.d.ts.map +1 -1
  52. package/build/types/integrations/tracing/express.d.ts +0 -4
  53. package/build/types/integrations/tracing/express.d.ts.map +1 -1
  54. package/build/types/integrations/tracing/index.d.ts.map +1 -1
  55. package/build/types/integrations/tracing/openai/index.d.ts +60 -0
  56. package/build/types/integrations/tracing/openai/index.d.ts.map +1 -0
  57. package/build/types/integrations/tracing/openai/instrumentation.d.ts +20 -0
  58. package/build/types/integrations/tracing/openai/instrumentation.d.ts.map +1 -0
  59. package/build/types/sdk/initOtel.d.ts.map +1 -1
  60. package/build/types-ts3.8/index.d.ts +1 -0
  61. package/build/types-ts3.8/integrations/tracing/express.d.ts +0 -4
  62. package/build/types-ts3.8/integrations/tracing/openai/index.d.ts +60 -0
  63. package/build/types-ts3.8/integrations/tracing/openai/instrumentation.d.ts +20 -0
  64. package/package.json +31 -31
  65. package/build/cjs/integrations/tracing/express-v5/enums/AttributeNames.js +0 -22
  66. package/build/cjs/integrations/tracing/express-v5/enums/AttributeNames.js.map +0 -1
  67. package/build/cjs/integrations/tracing/express-v5/enums/ExpressLayerType.js +0 -23
  68. package/build/cjs/integrations/tracing/express-v5/enums/ExpressLayerType.js.map +0 -1
  69. package/build/cjs/integrations/tracing/express-v5/instrumentation.js +0 -297
  70. package/build/cjs/integrations/tracing/express-v5/instrumentation.js.map +0 -1
  71. package/build/cjs/integrations/tracing/express-v5/internal-types.js +0 -29
  72. package/build/cjs/integrations/tracing/express-v5/internal-types.js.map +0 -1
  73. package/build/cjs/integrations/tracing/express-v5/utils.js +0 -176
  74. package/build/cjs/integrations/tracing/express-v5/utils.js.map +0 -1
  75. package/build/esm/integrations/tracing/express-v5/enums/AttributeNames.js +0 -22
  76. package/build/esm/integrations/tracing/express-v5/enums/AttributeNames.js.map +0 -1
  77. package/build/esm/integrations/tracing/express-v5/enums/ExpressLayerType.js +0 -23
  78. package/build/esm/integrations/tracing/express-v5/enums/ExpressLayerType.js.map +0 -1
  79. package/build/esm/integrations/tracing/express-v5/instrumentation.js +0 -293
  80. package/build/esm/integrations/tracing/express-v5/instrumentation.js.map +0 -1
  81. package/build/esm/integrations/tracing/express-v5/internal-types.js +0 -26
  82. package/build/esm/integrations/tracing/express-v5/internal-types.js.map +0 -1
  83. package/build/esm/integrations/tracing/express-v5/utils.js +0 -169
  84. package/build/esm/integrations/tracing/express-v5/utils.js.map +0 -1
  85. package/build/types/integrations/tracing/express-v5/enums/AttributeNames.d.ts +0 -5
  86. package/build/types/integrations/tracing/express-v5/enums/AttributeNames.d.ts.map +0 -1
  87. package/build/types/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts +0 -6
  88. package/build/types/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts.map +0 -1
  89. package/build/types/integrations/tracing/express-v5/instrumentation.d.ts +0 -27
  90. package/build/types/integrations/tracing/express-v5/instrumentation.d.ts.map +0 -1
  91. package/build/types/integrations/tracing/express-v5/internal-types.d.ts +0 -38
  92. package/build/types/integrations/tracing/express-v5/internal-types.d.ts.map +0 -1
  93. package/build/types/integrations/tracing/express-v5/types.d.ts +0 -39
  94. package/build/types/integrations/tracing/express-v5/types.d.ts.map +0 -1
  95. package/build/types/integrations/tracing/express-v5/utils.d.ts +0 -51
  96. package/build/types/integrations/tracing/express-v5/utils.d.ts.map +0 -1
  97. package/build/types-ts3.8/integrations/tracing/express-v5/enums/AttributeNames.d.ts +0 -5
  98. package/build/types-ts3.8/integrations/tracing/express-v5/enums/ExpressLayerType.d.ts +0 -6
  99. package/build/types-ts3.8/integrations/tracing/express-v5/instrumentation.d.ts +0 -27
  100. package/build/types-ts3.8/integrations/tracing/express-v5/internal-types.d.ts +0 -38
  101. package/build/types-ts3.8/integrations/tracing/express-v5/types.d.ts +0 -39
  102. package/build/types-ts3.8/integrations/tracing/express-v5/utils.d.ts +0 -57
@@ -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