@sentry/node 9.31.0 → 9.33.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 (52) hide show
  1. package/build/cjs/index.js +2 -0
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/cjs/integrations/anr/index.js +1 -1
  4. package/build/cjs/integrations/local-variables/common.js +1 -1
  5. package/build/cjs/integrations/local-variables/common.js.map +1 -1
  6. package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
  7. package/build/cjs/integrations/tracing/fastify/index.js +42 -5
  8. package/build/cjs/integrations/tracing/fastify/index.js.map +1 -1
  9. package/build/cjs/integrations/tracing/index.js +3 -0
  10. package/build/cjs/integrations/tracing/index.js.map +1 -1
  11. package/build/cjs/integrations/tracing/postgresjs.js +283 -0
  12. package/build/cjs/integrations/tracing/postgresjs.js.map +1 -0
  13. package/build/cjs/integrations/tracing/vercelai/index.js +7 -183
  14. package/build/cjs/integrations/tracing/vercelai/index.js.map +1 -1
  15. package/build/esm/index.js +1 -0
  16. package/build/esm/index.js.map +1 -1
  17. package/build/esm/integrations/anr/index.js +1 -1
  18. package/build/esm/integrations/anr/worker-script.js +2 -2
  19. package/build/esm/integrations/local-variables/common.js +1 -1
  20. package/build/esm/integrations/local-variables/common.js.map +1 -1
  21. package/build/esm/integrations/local-variables/local-variables-async.js +1 -1
  22. package/build/esm/integrations/local-variables/worker-script.js +2 -2
  23. package/build/esm/integrations/tracing/fastify/index.js +43 -6
  24. package/build/esm/integrations/tracing/fastify/index.js.map +1 -1
  25. package/build/esm/integrations/tracing/index.js +3 -0
  26. package/build/esm/integrations/tracing/index.js.map +1 -1
  27. package/build/esm/integrations/tracing/postgresjs.js +279 -0
  28. package/build/esm/integrations/tracing/postgresjs.js.map +1 -0
  29. package/build/esm/integrations/tracing/vercelai/index.js +8 -184
  30. package/build/esm/integrations/tracing/vercelai/index.js.map +1 -1
  31. package/build/esm/package.json +1 -1
  32. package/build/types/index.d.ts +1 -0
  33. package/build/types/index.d.ts.map +1 -1
  34. package/build/types/integrations/tracing/fastify/index.d.ts +1 -1
  35. package/build/types/integrations/tracing/fastify/index.d.ts.map +1 -1
  36. package/build/types/integrations/tracing/index.d.ts.map +1 -1
  37. package/build/types/integrations/tracing/postgresjs.d.ts +81 -0
  38. package/build/types/integrations/tracing/postgresjs.d.ts.map +1 -0
  39. package/build/types/integrations/tracing/vercelai/index.d.ts +5 -7
  40. package/build/types/integrations/tracing/vercelai/index.d.ts.map +1 -1
  41. package/build/types-ts3.8/index.d.ts +1 -0
  42. package/build/types-ts3.8/integrations/tracing/fastify/index.d.ts +1 -1
  43. package/build/types-ts3.8/integrations/tracing/postgresjs.d.ts +81 -0
  44. package/build/types-ts3.8/integrations/tracing/vercelai/index.d.ts +5 -7
  45. package/package.json +5 -5
  46. package/build/cjs/integrations/tracing/vercelai/ai_sdk_attributes.js +0 -168
  47. package/build/cjs/integrations/tracing/vercelai/ai_sdk_attributes.js.map +0 -1
  48. package/build/esm/integrations/tracing/vercelai/ai_sdk_attributes.js +0 -152
  49. package/build/esm/integrations/tracing/vercelai/ai_sdk_attributes.js.map +0 -1
  50. package/build/types/integrations/tracing/vercelai/ai_sdk_attributes.d.ts +0 -669
  51. package/build/types/integrations/tracing/vercelai/ai_sdk_attributes.d.ts.map +0 -1
  52. package/build/types-ts3.8/integrations/tracing/vercelai/ai_sdk_attributes.d.ts +0 -669
@@ -1,7 +1,5 @@
1
- import { defineIntegration, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';
1
+ import { defineIntegration, addVercelAiProcessors } from '@sentry/core';
2
2
  import { generateInstrumentOnce } from '../../../otel/instrument.js';
3
- import { addOriginToSpan } from '../../../utils/addOriginToSpan.js';
4
- import { AI_TOOL_CALL_NAME_ATTRIBUTE, AI_TOOL_CALL_ID_ATTRIBUTE, AI_MODEL_ID_ATTRIBUTE, AI_MODEL_PROVIDER_ATTRIBUTE, AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE, AI_PROMPT_ATTRIBUTE, GEN_AI_RESPONSE_MODEL_ATTRIBUTE, GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE, AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE, AI_USAGE_PROMPT_TOKENS_ATTRIBUTE, AI_PROMPT_MESSAGES_ATTRIBUTE, AI_RESPONSE_TEXT_ATTRIBUTE, AI_RESPONSE_TOOL_CALLS_ATTRIBUTE, AI_PROMPT_TOOLS_ATTRIBUTE } from './ai_sdk_attributes.js';
5
3
  import { INTEGRATION_NAME } from './constants.js';
6
4
  import { SentryVercelAiInstrumentation } from './instrumentation.js';
7
5
 
@@ -26,175 +24,14 @@ const _vercelAIIntegration = ((options = {}) => {
26
24
  instrumentation = instrumentVercelAi();
27
25
  },
28
26
  afterAllSetup(client) {
29
- function registerProcessors() {
30
- client.on('spanStart', span => {
31
- const { data: attributes, description: name } = spanToJSON(span);
32
-
33
- if (!name) {
34
- return;
35
- }
36
-
37
- // Tool call spans
38
- // https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans
39
- if (
40
- attributes[AI_TOOL_CALL_NAME_ATTRIBUTE] &&
41
- attributes[AI_TOOL_CALL_ID_ATTRIBUTE] &&
42
- name === 'ai.toolCall'
43
- ) {
44
- addOriginToSpan(span, 'auto.vercelai.otel');
45
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.execute_tool');
46
- span.setAttribute('gen_ai.tool.call.id', attributes[AI_TOOL_CALL_ID_ATTRIBUTE]);
47
- span.setAttribute('gen_ai.tool.name', attributes[AI_TOOL_CALL_NAME_ATTRIBUTE]);
48
- span.updateName(`execute_tool ${attributes[AI_TOOL_CALL_NAME_ATTRIBUTE]}`);
49
- return;
50
- }
51
-
52
- // The AI and Provider must be defined for generate, stream, and embed spans.
53
- // The id of the model
54
- const aiModelId = attributes[AI_MODEL_ID_ATTRIBUTE];
55
- // the provider of the model
56
- const aiModelProvider = attributes[AI_MODEL_PROVIDER_ATTRIBUTE];
57
- if (typeof aiModelId !== 'string' || typeof aiModelProvider !== 'string' || !aiModelId || !aiModelProvider) {
58
- return;
59
- }
60
-
61
- addOriginToSpan(span, 'auto.vercelai.otel');
62
-
63
- const nameWthoutAi = name.replace('ai.', '');
64
- span.setAttribute('ai.pipeline.name', nameWthoutAi);
65
- span.updateName(nameWthoutAi);
66
-
67
- // If a Telemetry name is set and it is a pipeline span, use that as the operation name
68
- const functionId = attributes[AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE];
69
- if (functionId && typeof functionId === 'string' && name.split('.').length - 1 === 1) {
70
- span.updateName(`${nameWthoutAi} ${functionId}`);
71
- span.setAttribute('ai.pipeline.name', functionId);
72
- }
73
-
74
- if (attributes[AI_PROMPT_ATTRIBUTE]) {
75
- span.setAttribute('gen_ai.prompt', attributes[AI_PROMPT_ATTRIBUTE]);
76
- }
77
- if (attributes[AI_MODEL_ID_ATTRIBUTE] && !attributes[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]) {
78
- span.setAttribute(GEN_AI_RESPONSE_MODEL_ATTRIBUTE, attributes[AI_MODEL_ID_ATTRIBUTE]);
79
- }
80
- span.setAttribute('ai.streaming', name.includes('stream'));
81
-
82
- // Generate Spans
83
- if (name === 'ai.generateText') {
84
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.pipeline.generate_text');
85
- return;
86
- }
87
-
88
- if (name === 'ai.generateText.doGenerate') {
89
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.generate_text');
90
- span.updateName(`generate_text ${attributes[AI_MODEL_ID_ATTRIBUTE]}`);
91
- return;
92
- }
93
-
94
- if (name === 'ai.streamText') {
95
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.pipeline.stream_text');
96
- return;
97
- }
98
-
99
- if (name === 'ai.streamText.doStream') {
100
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.stream_text');
101
- span.updateName(`stream_text ${attributes[AI_MODEL_ID_ATTRIBUTE]}`);
102
- return;
103
- }
104
-
105
- if (name === 'ai.generateObject') {
106
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.pipeline.generate_object');
107
- return;
108
- }
109
-
110
- if (name === 'ai.generateObject.doGenerate') {
111
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.generate_object');
112
- span.updateName(`generate_object ${attributes[AI_MODEL_ID_ATTRIBUTE]}`);
113
- return;
114
- }
115
-
116
- if (name === 'ai.streamObject') {
117
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.pipeline.stream_object');
118
- return;
119
- }
120
-
121
- if (name === 'ai.streamObject.doStream') {
122
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.stream_object');
123
- span.updateName(`stream_object ${attributes[AI_MODEL_ID_ATTRIBUTE]}`);
124
- return;
125
- }
126
-
127
- if (name === 'ai.embed') {
128
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.pipeline.embed');
129
- return;
130
- }
131
-
132
- if (name === 'ai.embed.doEmbed') {
133
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.embed');
134
- span.updateName(`embed ${attributes[AI_MODEL_ID_ATTRIBUTE]}`);
135
- return;
136
- }
137
-
138
- if (name === 'ai.embedMany') {
139
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.pipeline.embed_many');
140
- return;
141
- }
142
-
143
- if (name === 'ai.embedMany.doEmbed') {
144
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.embed_many');
145
- span.updateName(`embed_many ${attributes[AI_MODEL_ID_ATTRIBUTE]}`);
146
- return;
147
- }
148
-
149
- if (name.startsWith('ai.stream')) {
150
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.run');
151
- return;
152
- }
153
- });
154
-
155
- client.addEventProcessor(event => {
156
- if (event.type === 'transaction' && event.spans?.length) {
157
- for (const span of event.spans) {
158
- const { data: attributes, description: name } = span;
159
-
160
- if (!name || span.origin !== 'auto.vercelai.otel') {
161
- continue;
162
- }
163
-
164
- renameAttributeKey(
165
- attributes,
166
- AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,
167
- GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,
168
- );
169
- renameAttributeKey(attributes, AI_USAGE_PROMPT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE);
170
- if (
171
- typeof attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] === 'number' &&
172
- typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] === 'number'
173
- ) {
174
- attributes['gen_ai.usage.total_tokens'] =
175
- attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] + attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE];
176
- }
177
-
178
- // Rename AI SDK attributes to standardized gen_ai attributes
179
- renameAttributeKey(attributes, AI_PROMPT_MESSAGES_ATTRIBUTE, 'gen_ai.request.messages');
180
- renameAttributeKey(attributes, AI_RESPONSE_TEXT_ATTRIBUTE, 'gen_ai.response.text');
181
- renameAttributeKey(attributes, AI_RESPONSE_TOOL_CALLS_ATTRIBUTE, 'gen_ai.response.tool_calls');
182
- renameAttributeKey(attributes, AI_PROMPT_TOOLS_ATTRIBUTE, 'gen_ai.request.available_tools');
183
- }
184
- }
185
-
186
- return event;
187
- });
188
- }
189
-
190
27
  // Auto-detect if we should force the integration when running with 'ai' package available
191
28
  // Note that this can only be detected if the 'Modules' integration is available, and running in CJS mode
192
29
  const shouldForce = options.force ?? shouldForceIntegration(client);
193
30
 
194
31
  if (shouldForce) {
195
- registerProcessors();
32
+ addVercelAiProcessors(client);
196
33
  } else {
197
- instrumentation?.callWhenPatched(registerProcessors);
34
+ instrumentation?.callWhenPatched(() => addVercelAiProcessors(client));
198
35
  }
199
36
  },
200
37
  };
@@ -202,6 +39,7 @@ const _vercelAIIntegration = ((options = {}) => {
202
39
 
203
40
  /**
204
41
  * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.
42
+ * This integration is not enabled by default, you need to manually add it.
205
43
  *
206
44
  * For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).
207
45
  *
@@ -214,17 +52,14 @@ const _vercelAIIntegration = ((options = {}) => {
214
52
  * });
215
53
  * ```
216
54
  *
217
- * The integration automatically detects when to force registration in CommonJS environments
218
- * when the 'ai' package is available. You can still manually set the `force` option if needed.
219
- *
220
- * By default this integration adds tracing support to all `ai` function calls. If you need to disable
221
- * collecting spans for a specific call, you can do so by setting `experimental_telemetry.isEnabled` to
222
- * `false` in the first argument of the function call.
55
+ * This integration adds tracing support to all `ai` function calls.
56
+ * You need to opt-in to collecting spans for a specific call,
57
+ * you can do so by setting `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.
223
58
  *
224
59
  * ```javascript
225
60
  * const result = await generateText({
226
61
  * model: openai('gpt-4-turbo'),
227
- * experimental_telemetry: { isEnabled: false },
62
+ * experimental_telemetry: { isEnabled: true },
228
63
  * });
229
64
  * ```
230
65
  *
@@ -240,16 +75,5 @@ const _vercelAIIntegration = ((options = {}) => {
240
75
  */
241
76
  const vercelAIIntegration = defineIntegration(_vercelAIIntegration);
242
77
 
243
- /**
244
- * Renames an attribute key in the provided attributes object if the old key exists.
245
- * This function safely handles null and undefined values.
246
- */
247
- function renameAttributeKey(attributes, oldKey, newKey) {
248
- if (attributes[oldKey] != null) {
249
- attributes[newKey] = attributes[oldKey];
250
- delete attributes[oldKey];
251
- }
252
- }
253
-
254
78
  export { instrumentVercelAi, vercelAIIntegration };
255
79
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/vercelai/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-dynamic-delete */\n/* eslint-disable complexity */\nimport type { Client, IntegrationFn } from '@sentry/core';\nimport { defineIntegration, SEMANTIC_ATTRIBUTE_SENTRY_OP, spanToJSON } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../../otel/instrument';\nimport { addOriginToSpan } from '../../../utils/addOriginToSpan';\nimport type { modulesIntegration } from '../../modules';\nimport {\n AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_PROMPT_ATTRIBUTE,\n AI_PROMPT_MESSAGES_ATTRIBUTE,\n AI_PROMPT_TOOLS_ATTRIBUTE,\n AI_RESPONSE_TEXT_ATTRIBUTE,\n AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TOOL_CALL_ID_ATTRIBUTE,\n AI_TOOL_CALL_NAME_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n} from './ai_sdk_attributes';\nimport { INTEGRATION_NAME } from './constants';\nimport { SentryVercelAiInstrumentation } from './instrumentation';\nimport type { VercelAiOptions } from './types';\n\nexport const instrumentVercelAi = generateInstrumentOnce(INTEGRATION_NAME, () => new SentryVercelAiInstrumentation({}));\n\n/**\n * Determines if the integration should be forced based on environment and package availability.\n * Returns true if the 'ai' package is available.\n */\nfunction shouldForceIntegration(client: Client): boolean {\n const modules = client.getIntegrationByName<ReturnType<typeof modulesIntegration>>('Modules');\n return !!modules?.getModules?.()?.ai;\n}\n\nconst _vercelAIIntegration = ((options: VercelAiOptions = {}) => {\n let instrumentation: undefined | SentryVercelAiInstrumentation;\n\n return {\n name: INTEGRATION_NAME,\n options,\n setupOnce() {\n instrumentation = instrumentVercelAi();\n },\n afterAllSetup(client) {\n function registerProcessors(): void {\n client.on('spanStart', span => {\n const { data: attributes, description: name } = spanToJSON(span);\n\n if (!name) {\n return;\n }\n\n // Tool call spans\n // https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n if (\n attributes[AI_TOOL_CALL_NAME_ATTRIBUTE] &&\n attributes[AI_TOOL_CALL_ID_ATTRIBUTE] &&\n name === 'ai.toolCall'\n ) {\n addOriginToSpan(span, 'auto.vercelai.otel');\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.execute_tool');\n span.setAttribute('gen_ai.tool.call.id', attributes[AI_TOOL_CALL_ID_ATTRIBUTE]);\n span.setAttribute('gen_ai.tool.name', attributes[AI_TOOL_CALL_NAME_ATTRIBUTE]);\n span.updateName(`execute_tool ${attributes[AI_TOOL_CALL_NAME_ATTRIBUTE]}`);\n return;\n }\n\n // The AI and Provider must be defined for generate, stream, and embed spans.\n // The id of the model\n const aiModelId = attributes[AI_MODEL_ID_ATTRIBUTE];\n // the provider of the model\n const aiModelProvider = attributes[AI_MODEL_PROVIDER_ATTRIBUTE];\n if (typeof aiModelId !== 'string' || typeof aiModelProvider !== 'string' || !aiModelId || !aiModelProvider) {\n return;\n }\n\n addOriginToSpan(span, 'auto.vercelai.otel');\n\n const nameWthoutAi = name.replace('ai.', '');\n span.setAttribute('ai.pipeline.name', nameWthoutAi);\n span.updateName(nameWthoutAi);\n\n // If a Telemetry name is set and it is a pipeline span, use that as the operation name\n const functionId = attributes[AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE];\n if (functionId && typeof functionId === 'string' && name.split('.').length - 1 === 1) {\n span.updateName(`${nameWthoutAi} ${functionId}`);\n span.setAttribute('ai.pipeline.name', functionId);\n }\n\n if (attributes[AI_PROMPT_ATTRIBUTE]) {\n span.setAttribute('gen_ai.prompt', attributes[AI_PROMPT_ATTRIBUTE]);\n }\n if (attributes[AI_MODEL_ID_ATTRIBUTE] && !attributes[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]) {\n span.setAttribute(GEN_AI_RESPONSE_MODEL_ATTRIBUTE, attributes[AI_MODEL_ID_ATTRIBUTE]);\n }\n span.setAttribute('ai.streaming', name.includes('stream'));\n\n // Generate Spans\n if (name === 'ai.generateText') {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.pipeline.generate_text');\n return;\n }\n\n if (name === 'ai.generateText.doGenerate') {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.generate_text');\n span.updateName(`generate_text ${attributes[AI_MODEL_ID_ATTRIBUTE]}`);\n return;\n }\n\n if (name === 'ai.streamText') {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.pipeline.stream_text');\n return;\n }\n\n if (name === 'ai.streamText.doStream') {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.stream_text');\n span.updateName(`stream_text ${attributes[AI_MODEL_ID_ATTRIBUTE]}`);\n return;\n }\n\n if (name === 'ai.generateObject') {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.pipeline.generate_object');\n return;\n }\n\n if (name === 'ai.generateObject.doGenerate') {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.generate_object');\n span.updateName(`generate_object ${attributes[AI_MODEL_ID_ATTRIBUTE]}`);\n return;\n }\n\n if (name === 'ai.streamObject') {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.pipeline.stream_object');\n return;\n }\n\n if (name === 'ai.streamObject.doStream') {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.stream_object');\n span.updateName(`stream_object ${attributes[AI_MODEL_ID_ATTRIBUTE]}`);\n return;\n }\n\n if (name === 'ai.embed') {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.pipeline.embed');\n return;\n }\n\n if (name === 'ai.embed.doEmbed') {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.embed');\n span.updateName(`embed ${attributes[AI_MODEL_ID_ATTRIBUTE]}`);\n return;\n }\n\n if (name === 'ai.embedMany') {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.pipeline.embed_many');\n return;\n }\n\n if (name === 'ai.embedMany.doEmbed') {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.embed_many');\n span.updateName(`embed_many ${attributes[AI_MODEL_ID_ATTRIBUTE]}`);\n return;\n }\n\n if (name.startsWith('ai.stream')) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.run');\n return;\n }\n });\n\n client.addEventProcessor(event => {\n if (event.type === 'transaction' && event.spans?.length) {\n for (const span of event.spans) {\n const { data: attributes, description: name } = span;\n\n if (!name || span.origin !== 'auto.vercelai.otel') {\n continue;\n }\n\n renameAttributeKey(\n attributes,\n AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n );\n renameAttributeKey(attributes, AI_USAGE_PROMPT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE);\n if (\n typeof attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] === 'number' &&\n typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] === 'number'\n ) {\n attributes['gen_ai.usage.total_tokens'] =\n attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] + attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE];\n }\n\n // Rename AI SDK attributes to standardized gen_ai attributes\n renameAttributeKey(attributes, AI_PROMPT_MESSAGES_ATTRIBUTE, 'gen_ai.request.messages');\n renameAttributeKey(attributes, AI_RESPONSE_TEXT_ATTRIBUTE, 'gen_ai.response.text');\n renameAttributeKey(attributes, AI_RESPONSE_TOOL_CALLS_ATTRIBUTE, 'gen_ai.response.tool_calls');\n renameAttributeKey(attributes, AI_PROMPT_TOOLS_ATTRIBUTE, 'gen_ai.request.available_tools');\n }\n }\n\n return event;\n });\n }\n\n // Auto-detect if we should force the integration when running with 'ai' package available\n // Note that this can only be detected if the 'Modules' integration is available, and running in CJS mode\n const shouldForce = options.force ?? shouldForceIntegration(client);\n\n if (shouldForce) {\n registerProcessors();\n } else {\n instrumentation?.callWhenPatched(registerProcessors);\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.\n *\n * For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.vercelAIIntegration()],\n * });\n * ```\n *\n * The integration automatically detects when to force registration in CommonJS environments\n * when the 'ai' package is available. You can still manually set the `force` option if needed.\n *\n * By default this integration adds tracing support to all `ai` function calls. If you need to disable\n * collecting spans for a specific call, you can do so by setting `experimental_telemetry.isEnabled` to\n * `false` in the first argument of the function call.\n *\n * ```javascript\n * const result = await generateText({\n * model: openai('gpt-4-turbo'),\n * experimental_telemetry: { isEnabled: false },\n * });\n * ```\n *\n * If you want to collect inputs and outputs for a specific call, you must specifically opt-in to each\n * function call by setting `experimental_telemetry.recordInputs` and `experimental_telemetry.recordOutputs`\n * to `true`.\n *\n * ```javascript\n * const result = await generateText({\n * model: openai('gpt-4-turbo'),\n * experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },\n * });\n */\nexport const vercelAIIntegration = defineIntegration(_vercelAIIntegration);\n\n/**\n * Renames an attribute key in the provided attributes object if the old key exists.\n * This function safely handles null and undefined values.\n */\nfunction renameAttributeKey(attributes: Record<string, unknown>, oldKey: string, newKey: string): void {\n if (attributes[oldKey] != null) {\n attributes[newKey] = attributes[oldKey];\n delete attributes[oldKey];\n }\n}\n"],"names":[],"mappings":";;;;;;;MA4Ba,kBAAmB,GAAE,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,IAAI,6BAA6B,CAAC,EAAE,CAAC;;AAEtH;AACA;AACA;AACA;AACA,SAAS,sBAAsB,CAAC,MAAM,EAAmB;AACzD,EAAE,MAAM,UAAU,MAAM,CAAC,oBAAoB,CAAwC,SAAS,CAAC;AAC/F,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,UAAU,IAAI,EAAE,EAAE;AACtC;;AAEA,MAAM,oBAAA,IAAwB,CAAC,OAAO,GAAoB,EAAE,KAAK;AACjE,EAAE,IAAI,eAAe;;AAErB,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,OAAO;AACX,IAAI,SAAS,GAAG;AAChB,MAAM,eAAgB,GAAE,kBAAkB,EAAE;AAC5C,KAAK;AACL,IAAI,aAAa,CAAC,MAAM,EAAE;AAC1B,MAAM,SAAS,kBAAkB,GAAS;AAC1C,QAAQ,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,QAAQ;AACvC,UAAU,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,IAAA,EAAO,GAAE,UAAU,CAAC,IAAI,CAAC;;AAE1E,UAAU,IAAI,CAAC,IAAI,EAAE;AACrB,YAAY;AACZ;;AAEA;AACA;AACA,UAAU;AACV,YAAY,UAAU,CAAC,2BAA2B,CAAE;AACpD,YAAY,UAAU,CAAC,yBAAyB,CAAE;AAClD,YAAY,SAAS;AACrB,YAAY;AACZ,YAAY,eAAe,CAAC,IAAI,EAAE,oBAAoB,CAAC;AACvD,YAAY,IAAI,CAAC,YAAY,CAAC,4BAA4B,EAAE,qBAAqB,CAAC;AAClF,YAAY,IAAI,CAAC,YAAY,CAAC,qBAAqB,EAAE,UAAU,CAAC,y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AA,CAAA;AACA;AACA,KAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAA,mBAAA,GAAA,iBAAA,CAAA,oBAAA;;AAEA;AACA;AACA;AACA;AACA,SAAA,kBAAA,CAAA,UAAA,EAAA,MAAA,EAAA,MAAA,EAAA;AACA,EAAA,IAAA,UAAA,CAAA,MAAA,CAAA,IAAA,IAAA,EAAA;AACA,IAAA,UAAA,CAAA,MAAA,CAAA,GAAA,UAAA,CAAA,MAAA,CAAA;AACA,IAAA,OAAA,UAAA,CAAA,MAAA,CAAA;AACA;AACA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/vercelai/index.ts"],"sourcesContent":["import type { Client, IntegrationFn } from '@sentry/core';\nimport { addVercelAiProcessors, defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../../otel/instrument';\nimport type { modulesIntegration } from '../../modules';\nimport { INTEGRATION_NAME } from './constants';\nimport { SentryVercelAiInstrumentation } from './instrumentation';\nimport type { VercelAiOptions } from './types';\n\nexport const instrumentVercelAi = generateInstrumentOnce(INTEGRATION_NAME, () => new SentryVercelAiInstrumentation({}));\n\n/**\n * Determines if the integration should be forced based on environment and package availability.\n * Returns true if the 'ai' package is available.\n */\nfunction shouldForceIntegration(client: Client): boolean {\n const modules = client.getIntegrationByName<ReturnType<typeof modulesIntegration>>('Modules');\n return !!modules?.getModules?.()?.ai;\n}\n\nconst _vercelAIIntegration = ((options: VercelAiOptions = {}) => {\n let instrumentation: undefined | SentryVercelAiInstrumentation;\n\n return {\n name: INTEGRATION_NAME,\n options,\n setupOnce() {\n instrumentation = instrumentVercelAi();\n },\n afterAllSetup(client) {\n // Auto-detect if we should force the integration when running with 'ai' package available\n // Note that this can only be detected if the 'Modules' integration is available, and running in CJS mode\n const shouldForce = options.force ?? shouldForceIntegration(client);\n\n if (shouldForce) {\n addVercelAiProcessors(client);\n } else {\n instrumentation?.callWhenPatched(() => addVercelAiProcessors(client));\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.\n * This integration is not enabled by default, you need to manually add it.\n *\n * For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.vercelAIIntegration()],\n * });\n * ```\n *\n * This integration adds tracing support to all `ai` function calls.\n * You need to opt-in to collecting spans for a specific call,\n * you can do so by setting `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.\n *\n * ```javascript\n * const result = await generateText({\n * model: openai('gpt-4-turbo'),\n * experimental_telemetry: { isEnabled: true },\n * });\n * ```\n *\n * If you want to collect inputs and outputs for a specific call, you must specifically opt-in to each\n * function call by setting `experimental_telemetry.recordInputs` and `experimental_telemetry.recordOutputs`\n * to `true`.\n *\n * ```javascript\n * const result = await generateText({\n * model: openai('gpt-4-turbo'),\n * experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },\n * });\n */\nexport const vercelAIIntegration = defineIntegration(_vercelAIIntegration);\n"],"names":[],"mappings":";;;;;MAQa,kBAAmB,GAAE,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,IAAI,6BAA6B,CAAC,EAAE,CAAC;;AAEtH;AACA;AACA;AACA;AACA,SAAS,sBAAsB,CAAC,MAAM,EAAmB;AACzD,EAAE,MAAM,UAAU,MAAM,CAAC,oBAAoB,CAAwC,SAAS,CAAC;AAC/F,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,UAAU,IAAI,EAAE,EAAE;AACtC;;AAEA,MAAM,oBAAA,IAAwB,CAAC,OAAO,GAAoB,EAAE,KAAK;AACjE,EAAE,IAAI,eAAe;;AAErB,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,OAAO;AACX,IAAI,SAAS,GAAG;AAChB,MAAM,eAAgB,GAAE,kBAAkB,EAAE;AAC5C,KAAK;AACL,IAAI,aAAa,CAAC,MAAM,EAAE;AAC1B;AACA;AACA,MAAM,MAAM,WAAY,GAAE,OAAO,CAAC,SAAS,sBAAsB,CAAC,MAAM,CAAC;;AAEzE,MAAM,IAAI,WAAW,EAAE;AACvB,QAAQ,qBAAqB,CAAC,MAAM,CAAC;AACrC,aAAa;AACb,QAAQ,eAAe,EAAE,eAAe,CAAC,MAAM,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAC7E;AACA,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,mBAAoB,GAAE,iBAAiB,CAAC,oBAAoB;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"9.31.0","sideEffects":false}
1
+ {"type":"module","version":"9.33.0","sideEffects":false}
@@ -20,6 +20,7 @@ export { mysqlIntegration } from './integrations/tracing/mysql';
20
20
  export { mysql2Integration } from './integrations/tracing/mysql2';
21
21
  export { redisIntegration } from './integrations/tracing/redis';
22
22
  export { postgresIntegration } from './integrations/tracing/postgres';
23
+ export { postgresJsIntegration } from './integrations/tracing/postgresjs';
23
24
  export { prismaIntegration } from './integrations/tracing/prisma';
24
25
  export { hapiIntegration, setupHapiErrorHandler } from './integrations/tracing/hapi';
25
26
  export { koaIntegration, setupKoaErrorHandler } from './integrations/tracing/koa';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA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AiB,EACjB,yBAAyB,EACzB,wBAAwB,EACxB,YAAY,EACZ,cAAc,EACd,UAAU,EACV,cAAc,EACd,SAAS,EACT,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,aAAa,EACb,cAAc,EACd,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,QAAQ,EACR,yBAAyB,EACzB,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,OAAO,EACP,aAAa,EACb,UAAU,EACV,UAAU,EACV,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -38,7 +38,7 @@ interface FastifyHandlerOptions {
38
38
  export declare const instrumentFastifyV3: ((options?: unknown) => FastifyInstrumentationV3) & {
39
39
  id: string;
40
40
  };
41
- export declare const instrumentFastify: ((options?: unknown) => Instrumentation<InstrumentationConfig>) & {
41
+ export declare const instrumentFastify: ((options?: unknown) => Instrumentation<InstrumentationConfig & FastifyHandlerOptions>) & {
42
42
  id: string;
43
43
  };
44
44
  /**
@@ -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,UAAU,qBAAqB;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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;AAsBhD;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,WAAW,EAAE,CAsB9D;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,CAyBzG"}
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;AAuBhD;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,WAAW,EAAE,CAuB9D;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"}
@@ -0,0 +1,81 @@
1
+ import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
2
+ import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
3
+ import type { Span } from '@sentry/core';
4
+ type PostgresConnectionContext = {
5
+ ATTR_DB_NAMESPACE?: string;
6
+ ATTR_SERVER_ADDRESS?: string;
7
+ ATTR_SERVER_PORT?: string;
8
+ };
9
+ type PostgresJsInstrumentationConfig = InstrumentationConfig & {
10
+ /**
11
+ * Whether to require a parent span for the instrumentation.
12
+ * If set to true, the instrumentation will only create spans if there is a parent span
13
+ * available in the current scope.
14
+ * @default true
15
+ */
16
+ requireParentSpan?: boolean;
17
+ /**
18
+ * Hook to modify the span before it is started.
19
+ * This can be used to set additional attributes or modify the span in any way.
20
+ */
21
+ requestHook?: (span: Span, sanitizedSqlQuery: string, postgresConnectionContext?: PostgresConnectionContext) => void;
22
+ };
23
+ export declare const instrumentPostgresJs: ((options?: PostgresJsInstrumentationConfig | undefined) => PostgresJsInstrumentation) & {
24
+ id: string;
25
+ };
26
+ /**
27
+ * Instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.
28
+ * This instrumentation captures postgresjs queries and their attributes,
29
+ */
30
+ export declare class PostgresJsInstrumentation extends InstrumentationBase<PostgresJsInstrumentationConfig> {
31
+ constructor(config: PostgresJsInstrumentationConfig);
32
+ /**
33
+ * Initializes the instrumentation.
34
+ */
35
+ init(): InstrumentationNodeModuleDefinition[];
36
+ /**
37
+ * Determines whether a span should be created based on the current context.
38
+ * If `requireParentSpan` is set to true in the configuration, a span will
39
+ * only be created if there is a parent span available.
40
+ */
41
+ private _shouldCreateSpans;
42
+ /**
43
+ * Patches the reject method of the Query class to set the span status and end it
44
+ */
45
+ private _patchReject;
46
+ /**
47
+ * Patches the resolve method of the Query class to end the span when the query is resolved.
48
+ */
49
+ private _patchResolve;
50
+ /**
51
+ * Patches the Query class to instrument the handle method.
52
+ */
53
+ private _patchQuery;
54
+ /**
55
+ * Patches the Connection class to set the database, host, and port attributes
56
+ * when a new connection is created.
57
+ */
58
+ private _patchConnection;
59
+ /**
60
+ * Sanitize SQL query as per the OTEL semantic conventions
61
+ * https://opentelemetry.io/docs/specs/semconv/database/database-spans/#sanitization-of-dbquerytext
62
+ */
63
+ private _sanitizeSqlQuery;
64
+ }
65
+ /**
66
+ * Adds Sentry tracing instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.
67
+ *
68
+ * For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).
69
+ *
70
+ * @example
71
+ * ```javascript
72
+ * const Sentry = require('@sentry/node');
73
+ *
74
+ * Sentry.init({
75
+ * integrations: [Sentry.postgresJsIntegration()],
76
+ * });
77
+ * ```
78
+ */
79
+ export declare const postgresJsIntegration: () => import("@sentry/core").Integration;
80
+ export {};
81
+ //# sourceMappingURL=postgresjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgresjs.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/postgresjs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EACL,mBAAmB,EACnB,mCAAmC,EAGpC,MAAM,gCAAgC,CAAC;AAWxC,OAAO,KAAK,EAAiB,IAAI,EAAE,MAAM,cAAc,CAAC;AAexD,KAAK,yBAAyB,GAAG;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,KAAK,+BAA+B,GAAG,qBAAqB,GAAG;IAC7D;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,yBAAyB,CAAC,EAAE,yBAAyB,KAAK,IAAI,CAAC;CACtH,CAAC;AAEF,eAAO,MAAM,oBAAoB;;CAOhC,CAAC;AAEF;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,+BAA+B,CAAC;gBAC9E,MAAM,EAAE,+BAA+B;IAI1D;;OAEG;IACI,IAAI,IAAI,mCAAmC,EAAE;IA0BpD;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAM1B;;OAEG;IACH,OAAO,CAAC,YAAY;IAgCpB;;OAEG;IACH,OAAO,CAAC,aAAa;IAgBrB;;OAEG;IACH,OAAO,CAAC,WAAW;IAkFnB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAmBxB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;CAqB1B;AAWD;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,qBAAqB,0CAA4C,CAAC"}
@@ -5,6 +5,7 @@ export declare const instrumentVercelAi: ((options?: unknown) => SentryVercelAiI
5
5
  };
6
6
  /**
7
7
  * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.
8
+ * This integration is not enabled by default, you need to manually add it.
8
9
  *
9
10
  * For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).
10
11
  *
@@ -17,17 +18,14 @@ export declare const instrumentVercelAi: ((options?: unknown) => SentryVercelAiI
17
18
  * });
18
19
  * ```
19
20
  *
20
- * The integration automatically detects when to force registration in CommonJS environments
21
- * when the 'ai' package is available. You can still manually set the `force` option if needed.
22
- *
23
- * By default this integration adds tracing support to all `ai` function calls. If you need to disable
24
- * collecting spans for a specific call, you can do so by setting `experimental_telemetry.isEnabled` to
25
- * `false` in the first argument of the function call.
21
+ * This integration adds tracing support to all `ai` function calls.
22
+ * You need to opt-in to collecting spans for a specific call,
23
+ * you can do so by setting `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.
26
24
  *
27
25
  * ```javascript
28
26
  * const result = await generateText({
29
27
  * model: openai('gpt-4-turbo'),
30
- * experimental_telemetry: { isEnabled: false },
28
+ * experimental_telemetry: { isEnabled: true },
31
29
  * });
32
30
  * ```
33
31
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/vercelai/index.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,kBAAkB;;CAAwF,CAAC;AAmMxH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,mBAAmB,+EAA0C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/vercelai/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,kBAAkB;;CAAwF,CAAC;AAkCxH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,mBAAmB,+EAA0C,CAAC"}
@@ -20,6 +20,7 @@ export { mysqlIntegration } from './integrations/tracing/mysql';
20
20
  export { mysql2Integration } from './integrations/tracing/mysql2';
21
21
  export { redisIntegration } from './integrations/tracing/redis';
22
22
  export { postgresIntegration } from './integrations/tracing/postgres';
23
+ export { postgresJsIntegration } from './integrations/tracing/postgresjs';
23
24
  export { prismaIntegration } from './integrations/tracing/prisma';
24
25
  export { hapiIntegration, setupHapiErrorHandler } from './integrations/tracing/hapi';
25
26
  export { koaIntegration, setupKoaErrorHandler } from './integrations/tracing/koa';
@@ -38,7 +38,7 @@ interface FastifyHandlerOptions {
38
38
  export declare const instrumentFastifyV3: ((options?: unknown) => FastifyInstrumentationV3) & {
39
39
  id: string;
40
40
  };
41
- export declare const instrumentFastify: ((options?: unknown) => Instrumentation<InstrumentationConfig>) & {
41
+ export declare const instrumentFastify: ((options?: unknown) => Instrumentation<InstrumentationConfig & FastifyHandlerOptions>) & {
42
42
  id: string;
43
43
  };
44
44
  /**
@@ -0,0 +1,81 @@
1
+ import { InstrumentationConfig } from '@opentelemetry/instrumentation';
2
+ import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
3
+ import { Span } from '@sentry/core';
4
+ type PostgresConnectionContext = {
5
+ ATTR_DB_NAMESPACE?: string;
6
+ ATTR_SERVER_ADDRESS?: string;
7
+ ATTR_SERVER_PORT?: string;
8
+ };
9
+ type PostgresJsInstrumentationConfig = InstrumentationConfig & {
10
+ /**
11
+ * Whether to require a parent span for the instrumentation.
12
+ * If set to true, the instrumentation will only create spans if there is a parent span
13
+ * available in the current scope.
14
+ * @default true
15
+ */
16
+ requireParentSpan?: boolean;
17
+ /**
18
+ * Hook to modify the span before it is started.
19
+ * This can be used to set additional attributes or modify the span in any way.
20
+ */
21
+ requestHook?: (span: Span, sanitizedSqlQuery: string, postgresConnectionContext?: PostgresConnectionContext) => void;
22
+ };
23
+ export declare const instrumentPostgresJs: ((options?: PostgresJsInstrumentationConfig | undefined) => PostgresJsInstrumentation) & {
24
+ id: string;
25
+ };
26
+ /**
27
+ * Instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.
28
+ * This instrumentation captures postgresjs queries and their attributes,
29
+ */
30
+ export declare class PostgresJsInstrumentation extends InstrumentationBase<PostgresJsInstrumentationConfig> {
31
+ constructor(config: PostgresJsInstrumentationConfig);
32
+ /**
33
+ * Initializes the instrumentation.
34
+ */
35
+ init(): InstrumentationNodeModuleDefinition[];
36
+ /**
37
+ * Determines whether a span should be created based on the current context.
38
+ * If `requireParentSpan` is set to true in the configuration, a span will
39
+ * only be created if there is a parent span available.
40
+ */
41
+ private _shouldCreateSpans;
42
+ /**
43
+ * Patches the reject method of the Query class to set the span status and end it
44
+ */
45
+ private _patchReject;
46
+ /**
47
+ * Patches the resolve method of the Query class to end the span when the query is resolved.
48
+ */
49
+ private _patchResolve;
50
+ /**
51
+ * Patches the Query class to instrument the handle method.
52
+ */
53
+ private _patchQuery;
54
+ /**
55
+ * Patches the Connection class to set the database, host, and port attributes
56
+ * when a new connection is created.
57
+ */
58
+ private _patchConnection;
59
+ /**
60
+ * Sanitize SQL query as per the OTEL semantic conventions
61
+ * https://opentelemetry.io/docs/specs/semconv/database/database-spans/#sanitization-of-dbquerytext
62
+ */
63
+ private _sanitizeSqlQuery;
64
+ }
65
+ /**
66
+ * Adds Sentry tracing instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.
67
+ *
68
+ * For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).
69
+ *
70
+ * @example
71
+ * ```javascript
72
+ * const Sentry = require('@sentry/node');
73
+ *
74
+ * Sentry.init({
75
+ * integrations: [Sentry.postgresJsIntegration()],
76
+ * });
77
+ * ```
78
+ */
79
+ export declare const postgresJsIntegration: () => import("@sentry/core").Integration;
80
+ export {};
81
+ //# sourceMappingURL=postgresjs.d.ts.map
@@ -5,6 +5,7 @@ export declare const instrumentVercelAi: ((options?: unknown) => SentryVercelAiI
5
5
  };
6
6
  /**
7
7
  * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.
8
+ * This integration is not enabled by default, you need to manually add it.
8
9
  *
9
10
  * For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).
10
11
  *
@@ -17,17 +18,14 @@ export declare const instrumentVercelAi: ((options?: unknown) => SentryVercelAiI
17
18
  * });
18
19
  * ```
19
20
  *
20
- * The integration automatically detects when to force registration in CommonJS environments
21
- * when the 'ai' package is available. You can still manually set the `force` option if needed.
22
- *
23
- * By default this integration adds tracing support to all `ai` function calls. If you need to disable
24
- * collecting spans for a specific call, you can do so by setting `experimental_telemetry.isEnabled` to
25
- * `false` in the first argument of the function call.
21
+ * This integration adds tracing support to all `ai` function calls.
22
+ * You need to opt-in to collecting spans for a specific call,
23
+ * you can do so by setting `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.
26
24
  *
27
25
  * ```javascript
28
26
  * const result = await generateText({
29
27
  * model: openai('gpt-4-turbo'),
30
- * experimental_telemetry: { isEnabled: false },
28
+ * experimental_telemetry: { isEnabled: true },
31
29
  * });
32
30
  * ```
33
31
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/node",
3
- "version": "9.31.0",
3
+ "version": "9.33.0",
4
4
  "description": "Sentry Node SDK using OpenTelemetry for performance instrumentation",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/node",
@@ -94,10 +94,10 @@
94
94
  "@opentelemetry/resources": "^1.30.1",
95
95
  "@opentelemetry/sdk-trace-base": "^1.30.1",
96
96
  "@opentelemetry/semantic-conventions": "^1.34.0",
97
- "@prisma/instrumentation": "6.9.0",
98
- "@sentry/core": "9.31.0",
99
- "@sentry/opentelemetry": "9.31.0",
100
- "import-in-the-middle": "^1.13.1",
97
+ "@prisma/instrumentation": "6.10.1",
98
+ "@sentry/core": "9.33.0",
99
+ "@sentry/opentelemetry": "9.33.0",
100
+ "import-in-the-middle": "^1.14.2",
101
101
  "minimatch": "^9.0.0"
102
102
  },
103
103
  "devDependencies": {