@sentry/node 9.29.0 → 9.31.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 (42) hide show
  1. package/build/cjs/index.js +1 -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/local-variables-async.js +1 -1
  5. package/build/cjs/integrations/modules.js +49 -28
  6. package/build/cjs/integrations/modules.js.map +1 -1
  7. package/build/cjs/integrations/tracing/graphql.js +9 -1
  8. package/build/cjs/integrations/tracing/graphql.js.map +1 -1
  9. package/build/cjs/integrations/tracing/vercelai/ai_sdk_attributes.js +40 -0
  10. package/build/cjs/integrations/tracing/vercelai/ai_sdk_attributes.js.map +1 -1
  11. package/build/cjs/integrations/tracing/vercelai/index.js +41 -10
  12. package/build/cjs/integrations/tracing/vercelai/index.js.map +1 -1
  13. package/build/cjs/sdk/index.js +1 -5
  14. package/build/cjs/sdk/index.js.map +1 -1
  15. package/build/esm/index.js +1 -1
  16. package/build/esm/integrations/anr/index.js +1 -1
  17. package/build/esm/integrations/anr/worker-script.js +2 -2
  18. package/build/esm/integrations/local-variables/local-variables-async.js +1 -1
  19. package/build/esm/integrations/local-variables/worker-script.js +2 -2
  20. package/build/esm/integrations/modules.js +49 -28
  21. package/build/esm/integrations/modules.js.map +1 -1
  22. package/build/esm/integrations/tracing/graphql.js +9 -1
  23. package/build/esm/integrations/tracing/graphql.js.map +1 -1
  24. package/build/esm/integrations/tracing/vercelai/ai_sdk_attributes.js +37 -1
  25. package/build/esm/integrations/tracing/vercelai/ai_sdk_attributes.js.map +1 -1
  26. package/build/esm/integrations/tracing/vercelai/index.js +42 -11
  27. package/build/esm/integrations/tracing/vercelai/index.js.map +1 -1
  28. package/build/esm/package.json +1 -1
  29. package/build/esm/sdk/index.js +1 -5
  30. package/build/esm/sdk/index.js.map +1 -1
  31. package/build/types/index.d.ts +2 -2
  32. package/build/types/index.d.ts.map +1 -1
  33. package/build/types/integrations/modules.d.ts +13 -3
  34. package/build/types/integrations/modules.d.ts.map +1 -1
  35. package/build/types/integrations/tracing/graphql.d.ts.map +1 -1
  36. package/build/types/integrations/tracing/vercelai/index.d.ts +3 -0
  37. package/build/types/integrations/tracing/vercelai/index.d.ts.map +1 -1
  38. package/build/types/sdk/index.d.ts.map +1 -1
  39. package/build/types-ts3.8/index.d.ts +2 -2
  40. package/build/types-ts3.8/integrations/modules.d.ts +13 -3
  41. package/build/types-ts3.8/integrations/tracing/vercelai/index.d.ts +3 -0
  42. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"modules.js","sources":["../../../src/integrations/modules.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, logger } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { isCjs } from '../utils/commonjs';\n\nlet moduleCache: { [key: string]: string };\n\nconst INTEGRATION_NAME = 'Modules';\n\nconst _modulesIntegration = (() => {\n // This integration only works in CJS contexts\n if (!isCjs()) {\n DEBUG_BUILD &&\n logger.warn(\n 'modulesIntegration only works in CommonJS (CJS) environments. Remove this integration if you are using ESM.',\n );\n return {\n name: INTEGRATION_NAME,\n };\n }\n\n return {\n name: INTEGRATION_NAME,\n processEvent(event) {\n event.modules = {\n ...event.modules,\n ..._getModules(),\n };\n\n return event;\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Add node modules / packages to the event.\n *\n * Only works in CommonJS (CJS) environments.\n */\nexport const modulesIntegration = defineIntegration(_modulesIntegration);\n\n/** Extract information about paths */\nfunction getPaths(): string[] {\n try {\n return require.cache ? Object.keys(require.cache as Record<string, unknown>) : [];\n } catch (e) {\n return [];\n }\n}\n\n/** Extract information about package.json modules */\nfunction collectModules(): {\n [name: string]: string;\n} {\n const mainPaths = require.main?.paths || [];\n const paths = getPaths();\n const infos: {\n [name: string]: string;\n } = {};\n const seen: {\n [path: string]: boolean;\n } = {};\n\n paths.forEach(path => {\n let dir = path;\n\n /** Traverse directories upward in the search of package.json file */\n const updir = (): void | (() => void) => {\n const orig = dir;\n dir = dirname(orig);\n\n if (!dir || orig === dir || seen[orig]) {\n return undefined;\n }\n if (mainPaths.indexOf(dir) < 0) {\n return updir();\n }\n\n const pkgfile = join(orig, 'package.json');\n seen[orig] = true;\n\n if (!existsSync(pkgfile)) {\n return updir();\n }\n\n try {\n const info = JSON.parse(readFileSync(pkgfile, 'utf8')) as {\n name: string;\n version: string;\n };\n infos[info.name] = info.version;\n } catch (_oO) {\n // no-empty\n }\n };\n\n updir();\n });\n\n return infos;\n}\n\n/** Fetches the list of modules and the versions loaded by the entry file for your node.js app. */\nfunction _getModules(): { [key: string]: string } {\n if (!moduleCache) {\n moduleCache = collectModules();\n }\n return moduleCache;\n}\n"],"names":[],"mappings":";;;;;;AAOA,IAAI,WAAW;;AAEf,MAAM,gBAAA,GAAmB,SAAS;;AAElC,MAAM,mBAAoB,IAAG,MAAM;AACnC;AACA,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE;AAChB,IAAI,WAAY;AAChB,MAAM,MAAM,CAAC,IAAI;AACjB,QAAQ,6GAA6G;AACrH,OAAO;AACP,IAAI,OAAO;AACX,MAAM,IAAI,EAAE,gBAAgB;AAC5B,KAAK;AACL;;AAEA,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,YAAY,CAAC,KAAK,EAAE;AACxB,MAAM,KAAK,CAAC,OAAA,GAAU;AACtB,QAAQ,GAAG,KAAK,CAAC,OAAO;AACxB,QAAQ,GAAG,WAAW,EAAE;AACxB,OAAO;;AAEP,MAAM,OAAO,KAAK;AAClB,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;MACa,kBAAmB,GAAE,iBAAiB,CAAC,mBAAmB;;AAEvE;AACA,SAAS,QAAQ,GAAa;AAC9B,EAAE,IAAI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,OAAO;AACvC,OAAQ,CAAA,OAAO,GAAG,EAAE;AACpB;AACA;AACA,KAAK;;AAEL,IAAI,KAAK,EAAE;AACX,GAAG,CAAC;;AAEJ,EAAE,OAAO,KAAK;AACd;;AAEA;AACA,SAAS,WAAW,GAA8B;AAClD,EAAE,IAAI,CAAC,WAAW,EAAE;AACpB,IAAI,WAAY,GAAE,cAAc,EAAE;AAClC;AACA,EAAE,OAAO,WAAW;AACpB;;;;"}
1
+ {"version":3,"file":"modules.js","sources":["../../../src/integrations/modules.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport type { IntegrationFn } from '@sentry/core';\nimport { isCjs } from '../utils/commonjs';\n\ntype ModuleInfo = Record<string, string>;\n\nlet moduleCache: ModuleInfo | undefined;\n\nconst INTEGRATION_NAME = 'Modules';\n\ndeclare const __SENTRY_SERVER_MODULES__: Record<string, string>;\n\n/**\n * `__SENTRY_SERVER_MODULES__` can be replaced at build time with the modules loaded by the server.\n * Right now, we leverage this in Next.js to circumvent the problem that we do not get access to these things at runtime.\n */\nconst SERVER_MODULES = typeof __SENTRY_SERVER_MODULES__ === 'undefined' ? {} : __SENTRY_SERVER_MODULES__;\n\nconst _modulesIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n processEvent(event) {\n event.modules = {\n ...event.modules,\n ..._getModules(),\n };\n\n return event;\n },\n getModules: _getModules,\n };\n}) satisfies IntegrationFn;\n\n/**\n * Add node modules / packages to the event.\n * For this, multiple sources are used:\n * - They can be injected at build time into the __SENTRY_SERVER_MODULES__ variable (e.g. in Next.js)\n * - They are extracted from the dependencies & devDependencies in the package.json file\n * - They are extracted from the require.cache (CJS only)\n */\nexport const modulesIntegration = _modulesIntegration;\n\nfunction getRequireCachePaths(): string[] {\n try {\n return require.cache ? Object.keys(require.cache as Record<string, unknown>) : [];\n } catch (e) {\n return [];\n }\n}\n\n/** Extract information about package.json modules */\nfunction collectModules(): ModuleInfo {\n return {\n ...SERVER_MODULES,\n ...getModulesFromPackageJson(),\n ...(isCjs() ? collectRequireModules() : {}),\n };\n}\n\n/** Extract information about package.json modules from require.cache */\nfunction collectRequireModules(): ModuleInfo {\n const mainPaths = require.main?.paths || [];\n const paths = getRequireCachePaths();\n\n // We start with the modules from package.json (if possible)\n // These may be overwritten by more specific versions from the require.cache\n const infos: ModuleInfo = {};\n const seen = new Set<string>();\n\n paths.forEach(path => {\n let dir = path;\n\n /** Traverse directories upward in the search of package.json file */\n const updir = (): void | (() => void) => {\n const orig = dir;\n dir = dirname(orig);\n\n if (!dir || orig === dir || seen.has(orig)) {\n return undefined;\n }\n if (mainPaths.indexOf(dir) < 0) {\n return updir();\n }\n\n const pkgfile = join(orig, 'package.json');\n seen.add(orig);\n\n if (!existsSync(pkgfile)) {\n return updir();\n }\n\n try {\n const info = JSON.parse(readFileSync(pkgfile, 'utf8')) as {\n name: string;\n version: string;\n };\n infos[info.name] = info.version;\n } catch (_oO) {\n // no-empty\n }\n };\n\n updir();\n });\n\n return infos;\n}\n\n/** Fetches the list of modules and the versions loaded by the entry file for your node.js app. */\nfunction _getModules(): ModuleInfo {\n if (!moduleCache) {\n moduleCache = collectModules();\n }\n return moduleCache;\n}\n\ninterface PackageJson {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n}\n\nfunction getPackageJson(): PackageJson {\n try {\n const filePath = join(process.cwd(), 'package.json');\n const packageJson = JSON.parse(readFileSync(filePath, 'utf8')) as PackageJson;\n\n return packageJson;\n } catch (e) {\n return {};\n }\n}\n\nfunction getModulesFromPackageJson(): ModuleInfo {\n const packageJson = getPackageJson();\n\n return {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n}\n"],"names":[],"mappings":";;;;AAOA,IAAI,WAAW;;AAEf,MAAM,gBAAA,GAAmB,SAAS;;AAIlC;AACA;AACA;AACA;AACA,MAAM,cAAA,GAAiB,OAAO,yBAA0B,KAAI,cAAc,EAAG,GAAE,yBAAyB;;AAExG,MAAM,m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AAE;AACb;AACA;;AAEA,SAAS,yBAAyB,GAAe;AACjD,EAAE,MAAM,WAAA,GAAc,cAAc,EAAE;;AAEtC,EAAE,OAAO;AACT,IAAI,GAAG,WAAW,CAAC,YAAY;AAC/B,IAAI,GAAG,WAAW,CAAC,eAAe;AAClC,GAAG;AACH;;;;"}
@@ -1,3 +1,4 @@
1
+ import { SpanStatusCode } from '@opentelemetry/api';
1
2
  import { GraphQLInstrumentation } from '@opentelemetry/instrumentation-graphql';
2
3
  import { defineIntegration, spanToJSON, getRootSpan } from '@sentry/core';
3
4
  import { SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION } from '@sentry/opentelemetry';
@@ -14,9 +15,16 @@ const instrumentGraphql = generateInstrumentOnce(
14
15
 
15
16
  return {
16
17
  ...options,
17
- responseHook(span) {
18
+ responseHook(span, result) {
18
19
  addOriginToSpan(span, 'auto.graphql.otel.graphql');
19
20
 
21
+ // We want to ensure spans are marked as errored if there are errors in the result
22
+ // We only do that if the span is not already marked with a status
23
+ const resultWithMaybeError = result ;
24
+ if (resultWithMaybeError.errors?.length && !spanToJSON(span).status) {
25
+ span.setStatus({ code: SpanStatusCode.ERROR });
26
+ }
27
+
20
28
  const attributes = spanToJSON(span).data;
21
29
 
22
30
  // If operation.name is not set, we fall back to use operation.type only
@@ -1 +1 @@
1
- {"version":3,"file":"graphql.js","sources":["../../../../src/integrations/tracing/graphql.ts"],"sourcesContent":["import type { AttributeValue } from '@opentelemetry/api';\nimport { GraphQLInstrumentation } from '@opentelemetry/instrumentation-graphql';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, getRootSpan, spanToJSON } from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION } from '@sentry/opentelemetry';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\n\ninterface GraphqlOptions {\n /**\n * Do not create spans for resolvers.\n *\n * Defaults to true.\n */\n ignoreResolveSpans?: boolean;\n\n /**\n * Don't create spans for the execution of the default resolver on object properties.\n *\n * When a resolver function is not defined on the schema for a field, graphql will\n * use the default resolver which just looks for a property with that name on the object.\n * If the property is not a function, it's not very interesting to trace.\n * This option can reduce noise and number of spans created.\n *\n * Defaults to true.\n */\n ignoreTrivialResolveSpans?: boolean;\n\n /**\n * If this is enabled, a http.server root span containing this span will automatically be renamed to include the operation name.\n * Set this to `false` if you do not want this behavior, and want to keep the default http.server span name.\n *\n * Defaults to true.\n */\n useOperationNameForRootSpan?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Graphql';\n\nexport const instrumentGraphql = generateInstrumentOnce(\n INTEGRATION_NAME,\n GraphQLInstrumentation,\n (_options: GraphqlOptions) => {\n const options = getOptionsWithDefaults(_options);\n\n return {\n ...options,\n responseHook(span) {\n addOriginToSpan(span, 'auto.graphql.otel.graphql');\n\n const attributes = spanToJSON(span).data;\n\n // If operation.name is not set, we fall back to use operation.type only\n const operationType = attributes['graphql.operation.type'];\n const operationName = attributes['graphql.operation.name'];\n\n if (options.useOperationNameForRootSpan && operationType) {\n const rootSpan = getRootSpan(span);\n const rootSpanAttributes = spanToJSON(rootSpan).data;\n\n const existingOperations = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION] || [];\n\n const newOperation = operationName ? `${operationType} ${operationName}` : `${operationType}`;\n\n // We keep track of each operation on the root span\n // This can either be a string, or an array of strings (if there are multiple operations)\n if (Array.isArray(existingOperations)) {\n (existingOperations as string[]).push(newOperation);\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, existingOperations);\n } else if (typeof existingOperations === 'string') {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, [existingOperations, newOperation]);\n } else {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, newOperation);\n }\n\n if (!spanToJSON(rootSpan).data['original-description']) {\n rootSpan.setAttribute('original-description', spanToJSON(rootSpan).description);\n }\n // Important for e.g. @sentry/aws-serverless because this would otherwise overwrite the name again\n rootSpan.updateName(\n `${spanToJSON(rootSpan).data['original-description']} (${getGraphqlOperationNamesFromAttribute(\n existingOperations,\n )})`,\n );\n }\n },\n };\n },\n);\n\nconst _graphqlIntegration = ((options: GraphqlOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // We set defaults here, too, because otherwise we'd update the instrumentation config\n // to the config without defaults, as `generateInstrumentOnce` automatically calls `setConfig(options)`\n // when being called the second time\n instrumentGraphql(getOptionsWithDefaults(options));\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [graphql](https://www.npmjs.com/package/graphql) library.\n *\n * For more information, see the [`graphqlIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/graphql/).\n *\n * @param {GraphqlOptions} options Configuration options for the GraphQL integration.\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.graphqlIntegration()],\n * });\n */\nexport const graphqlIntegration = defineIntegration(_graphqlIntegration);\n\nfunction getOptionsWithDefaults(options?: GraphqlOptions): GraphqlOptions {\n return {\n ignoreResolveSpans: true,\n ignoreTrivialResolveSpans: true,\n useOperationNameForRootSpan: true,\n ...options,\n };\n}\n\n// copy from packages/opentelemetry/utils\nfunction getGraphqlOperationNamesFromAttribute(attr: AttributeValue): string {\n if (Array.isArray(attr)) {\n const sorted = attr.slice().sort();\n\n // Up to 5 items, we just add all of them\n if (sorted.length <= 5) {\n return sorted.join(', ');\n } else {\n // Else, we add the first 5 and the diff of other operations\n return `${sorted.slice(0, 5).join(', ')}, +${sorted.length - 5}`;\n }\n }\n\n return `${attr}`;\n}\n"],"names":[],"mappings":";;;;;;AAqCA,MAAM,gBAAA,GAAmB,SAAS;;AAE3B,MAAM,iBAAkB,GAAE,sBAAsB;AACvD,EAAE,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A,CAAA;AACA,KAAA,MAAA;AACA;AACA,MAAA,OAAA,CAAA,EAAA,MAAA,CAAA,KAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,IAAA,CAAA,IAAA,CAAA,CAAA,GAAA,EAAA,MAAA,CAAA,MAAA,GAAA,CAAA,CAAA,CAAA;AACA;AACA;;AAEA,EAAA,OAAA,CAAA,EAAA,IAAA,CAAA,CAAA;AACA;;;;"}
1
+ {"version":3,"file":"graphql.js","sources":["../../../../src/integrations/tracing/graphql.ts"],"sourcesContent":["import type { AttributeValue } from '@opentelemetry/api';\nimport { SpanStatusCode } from '@opentelemetry/api';\nimport { GraphQLInstrumentation } from '@opentelemetry/instrumentation-graphql';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, getRootSpan, spanToJSON } from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION } from '@sentry/opentelemetry';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\n\ninterface GraphqlOptions {\n /**\n * Do not create spans for resolvers.\n *\n * Defaults to true.\n */\n ignoreResolveSpans?: boolean;\n\n /**\n * Don't create spans for the execution of the default resolver on object properties.\n *\n * When a resolver function is not defined on the schema for a field, graphql will\n * use the default resolver which just looks for a property with that name on the object.\n * If the property is not a function, it's not very interesting to trace.\n * This option can reduce noise and number of spans created.\n *\n * Defaults to true.\n */\n ignoreTrivialResolveSpans?: boolean;\n\n /**\n * If this is enabled, a http.server root span containing this span will automatically be renamed to include the operation name.\n * Set this to `false` if you do not want this behavior, and want to keep the default http.server span name.\n *\n * Defaults to true.\n */\n useOperationNameForRootSpan?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Graphql';\n\nexport const instrumentGraphql = generateInstrumentOnce(\n INTEGRATION_NAME,\n GraphQLInstrumentation,\n (_options: GraphqlOptions) => {\n const options = getOptionsWithDefaults(_options);\n\n return {\n ...options,\n responseHook(span, result) {\n addOriginToSpan(span, 'auto.graphql.otel.graphql');\n\n // We want to ensure spans are marked as errored if there are errors in the result\n // We only do that if the span is not already marked with a status\n const resultWithMaybeError = result as { errors?: { message: string }[] };\n if (resultWithMaybeError.errors?.length && !spanToJSON(span).status) {\n span.setStatus({ code: SpanStatusCode.ERROR });\n }\n\n const attributes = spanToJSON(span).data;\n\n // If operation.name is not set, we fall back to use operation.type only\n const operationType = attributes['graphql.operation.type'];\n const operationName = attributes['graphql.operation.name'];\n\n if (options.useOperationNameForRootSpan && operationType) {\n const rootSpan = getRootSpan(span);\n const rootSpanAttributes = spanToJSON(rootSpan).data;\n\n const existingOperations = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION] || [];\n\n const newOperation = operationName ? `${operationType} ${operationName}` : `${operationType}`;\n\n // We keep track of each operation on the root span\n // This can either be a string, or an array of strings (if there are multiple operations)\n if (Array.isArray(existingOperations)) {\n (existingOperations as string[]).push(newOperation);\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, existingOperations);\n } else if (typeof existingOperations === 'string') {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, [existingOperations, newOperation]);\n } else {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, newOperation);\n }\n\n if (!spanToJSON(rootSpan).data['original-description']) {\n rootSpan.setAttribute('original-description', spanToJSON(rootSpan).description);\n }\n // Important for e.g. @sentry/aws-serverless because this would otherwise overwrite the name again\n rootSpan.updateName(\n `${spanToJSON(rootSpan).data['original-description']} (${getGraphqlOperationNamesFromAttribute(\n existingOperations,\n )})`,\n );\n }\n },\n };\n },\n);\n\nconst _graphqlIntegration = ((options: GraphqlOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // We set defaults here, too, because otherwise we'd update the instrumentation config\n // to the config without defaults, as `generateInstrumentOnce` automatically calls `setConfig(options)`\n // when being called the second time\n instrumentGraphql(getOptionsWithDefaults(options));\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [graphql](https://www.npmjs.com/package/graphql) library.\n *\n * For more information, see the [`graphqlIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/graphql/).\n *\n * @param {GraphqlOptions} options Configuration options for the GraphQL integration.\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.graphqlIntegration()],\n * });\n */\nexport const graphqlIntegration = defineIntegration(_graphqlIntegration);\n\nfunction getOptionsWithDefaults(options?: GraphqlOptions): GraphqlOptions {\n return {\n ignoreResolveSpans: true,\n ignoreTrivialResolveSpans: true,\n useOperationNameForRootSpan: true,\n ...options,\n };\n}\n\n// copy from packages/opentelemetry/utils\nfunction getGraphqlOperationNamesFromAttribute(attr: AttributeValue): string {\n if (Array.isArray(attr)) {\n const sorted = attr.slice().sort();\n\n // Up to 5 items, we just add all of them\n if (sorted.length <= 5) {\n return sorted.join(', ');\n } else {\n // Else, we add the first 5 and the diff of other operations\n return `${sorted.slice(0, 5).join(', ')}, +${sorted.length - 5}`;\n }\n }\n\n return `${attr}`;\n}\n"],"names":[],"mappings":";;;;;;;AAsCA,MAAM,gBAAA,GAAmB,SAAS;;AAE3B,MAAM,iBAAkB,GAAE,sBAAsB;AACvD,EAAE,gBAAgB;AAClB,EAAE,sBAAsB;AACxB,EAAE,CAAC,QAAQ,KAAqB;AAChC,IAAI,MAAM,OAAQ,GAAE,sBAAsB,CAAC,QAAQ,CAAC;;AAEpD,IAAI,OAAO;AACX,MAAM,GAAG,OAAO;AAChB,MAAM,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE;AACjC,QAAQ,eAAe,CAAC,IAAI,EAAE,2BAA2B,CAAC;;AAE1D;AACA;AACA,QAAQ,MAAM,oBAAqB,GAAE,MAAO;AAC5C,QAAQ,IAAI,oBAAoB,CAAC,MAAM,EAA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A,CAAA,CAAA,IAAA,CAAA,IAAA,CAAA,CAAA,GAAA,EAAA,MAAA,CAAA,MAAA,GAAA,CAAA,CAAA,CAAA;AACA;AACA;;AAEA,EAAA,OAAA,CAAA,EAAA,IAAA,CAAA,CAAA;AACA;;;;"}
@@ -18,6 +18,42 @@
18
18
  */
19
19
  const AI_PROMPT_ATTRIBUTE = 'ai.prompt';
20
20
 
21
+ // =============================================================================
22
+ // GENERATETEXT FUNCTION - UNIQUE ATTRIBUTES
23
+ // =============================================================================
24
+
25
+ /**
26
+ * `generateText` function - `ai.generateText` span
27
+ *
28
+ * The text that was generated
29
+ * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function
30
+ */
31
+ const AI_RESPONSE_TEXT_ATTRIBUTE = 'ai.response.text';
32
+
33
+ /**
34
+ * `generateText` function - `ai.generateText` span
35
+ *
36
+ * The tool calls that were made as part of the generation (stringified JSON)
37
+ * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function
38
+ */
39
+ const AI_RESPONSE_TOOL_CALLS_ATTRIBUTE = 'ai.response.toolCalls';
40
+
41
+ /**
42
+ * `generateText` function - `ai.generateText.doGenerate` span
43
+ *
44
+ * The messages that were passed into the provider
45
+ * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function
46
+ */
47
+ const AI_PROMPT_MESSAGES_ATTRIBUTE = 'ai.prompt.messages';
48
+
49
+ /**
50
+ * `generateText` function - `ai.generateText.doGenerate` span
51
+ *
52
+ * Array of stringified tool definitions
53
+ * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function
54
+ */
55
+ const AI_PROMPT_TOOLS_ATTRIBUTE = 'ai.prompt.tools';
56
+
21
57
  /**
22
58
  * Basic LLM span information
23
59
  * Multiple spans
@@ -112,5 +148,5 @@ const AI_TOOL_CALL_NAME_ATTRIBUTE = 'ai.toolCall.name';
112
148
  */
113
149
  const AI_TOOL_CALL_ID_ATTRIBUTE = 'ai.toolCall.id';
114
150
 
115
- export { AI_MODEL_ID_ATTRIBUTE, AI_MODEL_PROVIDER_ATTRIBUTE, AI_PROMPT_ATTRIBUTE, AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE, AI_TOOL_CALL_ID_ATTRIBUTE, AI_TOOL_CALL_NAME_ATTRIBUTE, AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE, AI_USAGE_PROMPT_TOKENS_ATTRIBUTE, GEN_AI_RESPONSE_MODEL_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE };
151
+ export { AI_MODEL_ID_ATTRIBUTE, AI_MODEL_PROVIDER_ATTRIBUTE, AI_PROMPT_ATTRIBUTE, AI_PROMPT_MESSAGES_ATTRIBUTE, AI_PROMPT_TOOLS_ATTRIBUTE, AI_RESPONSE_TEXT_ATTRIBUTE, AI_RESPONSE_TOOL_CALLS_ATTRIBUTE, AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE, AI_TOOL_CALL_ID_ATTRIBUTE, AI_TOOL_CALL_NAME_ATTRIBUTE, AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE, AI_USAGE_PROMPT_TOKENS_ATTRIBUTE, GEN_AI_RESPONSE_MODEL_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE };
116
152
  //# sourceMappingURL=ai_sdk_attributes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai_sdk_attributes.js","sources":["../../../../../src/integrations/tracing/vercelai/ai_sdk_attributes.ts"],"sourcesContent":["/**\n * AI SDK Telemetry Attributes\n * Based on https://ai-sdk.dev/docs/ai-sdk-core/telemetry#collected-data\n */\n\n// =============================================================================\n// COMMON ATTRIBUTES\n// =============================================================================\n\n/**\n * Common attribute for operation name across all functions and spans\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#collected-data\n */\nexport const OPERATION_NAME_ATTRIBUTE = 'operation.name';\n\n/**\n * Common attribute for AI operation ID across all functions and spans\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#collected-data\n */\nexport const AI_OPERATION_ID_ATTRIBUTE = 'ai.operationId';\n\n// =============================================================================\n// SHARED ATTRIBUTES\n// =============================================================================\n\n/**\n * `generateText` function - `ai.generateText` span\n * `streamText` function - `ai.streamText` span\n *\n * The prompt that was used when calling the function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamtext-function\n */\nexport const AI_PROMPT_ATTRIBUTE = 'ai.prompt';\n\n/**\n * `generateObject` function - `ai.generateObject` span\n * `streamObject` function - `ai.streamObject` span\n *\n * The JSON schema version of the schema that was passed into the function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generateobject-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamobject-function\n */\nexport const AI_SCHEMA_ATTRIBUTE = 'ai.schema';\n\n/**\n * `generateObject` function - `ai.generateObject` span\n * `streamObject` function - `ai.streamObject` span\n *\n * The name of the schema that was passed into the function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generateobject-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamobject-function\n */\nexport const AI_SCHEMA_NAME_ATTRIBUTE = 'ai.schema.name';\n\n/**\n * `generateObject` function - `ai.generateObject` span\n * `streamObject` function - `ai.streamObject` span\n *\n * The description of the schema that was passed into the function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generateobject-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamobject-function\n */\nexport const AI_SCHEMA_DESCRIPTION_ATTRIBUTE = 'ai.schema.description';\n\n/**\n * `generateObject` function - `ai.generateObject` span\n * `streamObject` function - `ai.streamObject` span\n *\n * The object that was generated (stringified JSON)\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generateobject-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamobject-function\n */\nexport const AI_RESPONSE_OBJECT_ATTRIBUTE = 'ai.response.object';\n\n/**\n * `generateObject` function - `ai.generateObject` span\n * `streamObject` function - `ai.streamObject` span\n *\n * The object generation mode, e.g. `json`\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generateobject-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamobject-function\n */\nexport const AI_SETTINGS_MODE_ATTRIBUTE = 'ai.settings.mode';\n\n/**\n * `generateObject` function - `ai.generateObject` span\n * `streamObject` function - `ai.streamObject` span\n *\n * The output type that was used, e.g. `object` or `no-schema`\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generateobject-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamobject-function\n */\nexport const AI_SETTINGS_OUTPUT_ATTRIBUTE = 'ai.settings.output';\n\n/**\n * `embed` function - `ai.embed.doEmbed` span\n * `embedMany` function - `ai.embedMany` span\n *\n * The values that were passed into the function (array)\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embed-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embedmany-function\n */\nexport const AI_VALUES_ATTRIBUTE = 'ai.values';\n\n/**\n * `embed` function - `ai.embed.doEmbed` span\n * `embedMany` function - `ai.embedMany` span\n *\n * An array of JSON-stringified embeddings\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embed-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embedmany-function\n */\nexport const AI_EMBEDDINGS_ATTRIBUTE = 'ai.embeddings';\n\n// =============================================================================\n// GENERATETEXT FUNCTION - UNIQUE ATTRIBUTES\n// =============================================================================\n\n/**\n * `generateText` function - `ai.generateText` span\n *\n * The text that was generated\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_RESPONSE_TEXT_ATTRIBUTE = 'ai.response.text';\n\n/**\n * `generateText` function - `ai.generateText` span\n *\n * The tool calls that were made as part of the generation (stringified JSON)\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_RESPONSE_TOOL_CALLS_ATTRIBUTE = 'ai.response.toolCalls';\n\n/**\n * `generateText` function - `ai.generateText` span\n *\n * The reason why the generation finished\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_RESPONSE_FINISH_REASON_ATTRIBUTE = 'ai.response.finishReason';\n\n/**\n * `generateText` function - `ai.generateText` span\n *\n * The maximum number of steps that were set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_SETTINGS_MAX_STEPS_ATTRIBUTE = 'ai.settings.maxSteps';\n\n/**\n * `generateText` function - `ai.generateText.doGenerate` span\n *\n * The format of the prompt\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_PROMPT_FORMAT_ATTRIBUTE = 'ai.prompt.format';\n\n/**\n * `generateText` function - `ai.generateText.doGenerate` span\n *\n * The messages that were passed into the provider\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_PROMPT_MESSAGES_ATTRIBUTE = 'ai.prompt.messages';\n\n/**\n * `generateText` function - `ai.generateText.doGenerate` span\n *\n * Array of stringified tool definitions\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_PROMPT_TOOLS_ATTRIBUTE = 'ai.prompt.tools';\n\n/**\n * `generateText` function - `ai.generateText.doGenerate` span\n *\n * The stringified tool choice setting (JSON)\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_PROMPT_TOOL_CHOICE_ATTRIBUTE = 'ai.prompt.toolChoice';\n\n// =============================================================================\n// STREAMTEXT FUNCTION - UNIQUE ATTRIBUTES\n// =============================================================================\n\n/**\n * `streamText` function - `ai.streamText.doStream` span\n *\n * The time it took to receive the first chunk in milliseconds\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamtext-function\n */\nexport const AI_RESPONSE_MS_TO_FIRST_CHUNK_ATTRIBUTE = 'ai.response.msToFirstChunk';\n\n/**\n * `streamText` function - `ai.streamText.doStream` span\n *\n * The time it took to receive the finish part of the LLM stream in milliseconds\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamtext-function\n */\nexport const AI_RESPONSE_MS_TO_FINISH_ATTRIBUTE = 'ai.response.msToFinish';\n\n/**\n * `streamText` function - `ai.streamText.doStream` span\n *\n * The average completion tokens per second\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamtext-function\n */\nexport const AI_RESPONSE_AVG_COMPLETION_TOKENS_PER_SECOND_ATTRIBUTE = 'ai.response.avgCompletionTokensPerSecond';\n\n// =============================================================================\n// EMBED FUNCTION - UNIQUE ATTRIBUTES\n// =============================================================================\n\n/**\n * `embed` function - `ai.embed` span\n *\n * The value that was passed into the `embed` function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embed-function\n */\nexport const AI_VALUE_ATTRIBUTE = 'ai.value';\n\n/**\n * `embed` function - `ai.embed` span\n *\n * A JSON-stringified embedding\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embed-function\n */\nexport const AI_EMBEDDING_ATTRIBUTE = 'ai.embedding';\n\n// =============================================================================\n// BASIC LLM SPAN INFORMATION\n// =============================================================================\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The functionId that was set through `telemetry.functionId`\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const RESOURCE_NAME_ATTRIBUTE = 'resource.name';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The id of the model\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_MODEL_ID_ATTRIBUTE = 'ai.model.id';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The provider of the model\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_MODEL_PROVIDER_ATTRIBUTE = 'ai.model.provider';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The request headers that were passed in through `headers`\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_REQUEST_HEADERS_ATTRIBUTE = 'ai.request.headers';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The maximum number of retries that were set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_SETTINGS_MAX_RETRIES_ATTRIBUTE = 'ai.settings.maxRetries';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The functionId that was set through `telemetry.functionId`\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE = 'ai.telemetry.functionId';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The metadata that was passed in through `telemetry.metadata`\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_TELEMETRY_METADATA_ATTRIBUTE = 'ai.telemetry.metadata';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The number of completion tokens that were used\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE = 'ai.usage.completionTokens';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The number of prompt tokens that were used\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_USAGE_PROMPT_TOKENS_ATTRIBUTE = 'ai.usage.promptTokens';\n\n// =============================================================================\n// CALL LLM SPAN INFORMATION\n// =============================================================================\n\n/**\n * Call LLM span information\n * Individual LLM call spans\n *\n * The model that was used to generate the response\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const AI_RESPONSE_MODEL_ATTRIBUTE = 'ai.response.model';\n\n/**\n * Call LLM span information\n * Individual LLM call spans\n *\n * The id of the response\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const AI_RESPONSE_ID_ATTRIBUTE = 'ai.response.id';\n\n/**\n * Call LLM span information\n * Individual LLM call spans\n *\n * The timestamp of the response\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const AI_RESPONSE_TIMESTAMP_ATTRIBUTE = 'ai.response.timestamp';\n\n// =============================================================================\n// SEMANTIC CONVENTIONS FOR GENAI OPERATIONS\n// =============================================================================\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The provider that was used\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_SYSTEM_ATTRIBUTE = 'gen_ai.system';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The model that was requested\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_MODEL_ATTRIBUTE = 'gen_ai.request.model';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The temperature that was set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE = 'gen_ai.request.temperature';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The maximum number of tokens that were set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE = 'gen_ai.request.max_tokens';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The frequency penalty that was set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE = 'gen_ai.request.frequency_penalty';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The presence penalty that was set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE = 'gen_ai.request.presence_penalty';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The topK parameter value that was set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_TOP_K_ATTRIBUTE = 'gen_ai.request.top_k';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The topP parameter value that was set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_TOP_P_ATTRIBUTE = 'gen_ai.request.top_p';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The stop sequences\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_STOP_SEQUENCES_ATTRIBUTE = 'gen_ai.request.stop_sequences';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The finish reasons that were returned by the provider\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE = 'gen_ai.response.finish_reasons';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The model that was used to generate the response\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_RESPONSE_MODEL_ATTRIBUTE = 'gen_ai.response.model';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The id of the response\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_RESPONSE_ID_ATTRIBUTE = 'gen_ai.response.id';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The number of prompt tokens that were used\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE = 'gen_ai.usage.input_tokens';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The number of completion tokens that were used\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE = 'gen_ai.usage.output_tokens';\n\n// =============================================================================\n// BASIC EMBEDDING SPAN INFORMATION\n// =============================================================================\n\n/**\n * Basic embedding span information\n * Embedding spans\n *\n * The number of tokens that were used\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-embedding-span-information\n */\nexport const AI_USAGE_TOKENS_ATTRIBUTE = 'ai.usage.tokens';\n\n// =============================================================================\n// TOOL CALL SPANS\n// =============================================================================\n\n/**\n * Tool call spans\n * `ai.toolCall` span\n *\n * The name of the tool\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n */\nexport const AI_TOOL_CALL_NAME_ATTRIBUTE = 'ai.toolCall.name';\n\n/**\n * Tool call spans\n * `ai.toolCall` span\n *\n * The id of the tool call\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n */\nexport const AI_TOOL_CALL_ID_ATTRIBUTE = 'ai.toolCall.id';\n\n/**\n * Tool call spans\n * `ai.toolCall` span\n *\n * The parameters of the tool call\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n */\nexport const AI_TOOL_CALL_ARGS_ATTRIBUTE = 'ai.toolCall.args';\n\n/**\n * Tool call spans\n * `ai.toolCall` span\n *\n * The result of the tool call\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n */\nexport const AI_TOOL_CALL_RESULT_ATTRIBUTE = 'ai.toolCall.result';\n\n// =============================================================================\n// SPAN ATTRIBUTE OBJECTS\n// =============================================================================\n\n/**\n * Attributes collected for `ai.generateText` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_GENERATE_TEXT_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_PROMPT: AI_PROMPT_ATTRIBUTE,\n AI_RESPONSE_TEXT: AI_RESPONSE_TEXT_ATTRIBUTE,\n AI_RESPONSE_TOOL_CALLS: AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n AI_RESPONSE_FINISH_REASON: AI_RESPONSE_FINISH_REASON_ATTRIBUTE,\n AI_SETTINGS_MAX_STEPS: AI_SETTINGS_MAX_STEPS_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS: AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS: AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.generateText.doGenerate` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_GENERATE_TEXT_DO_GENERATE_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_PROMPT_FORMAT: AI_PROMPT_FORMAT_ATTRIBUTE,\n AI_PROMPT_MESSAGES: AI_PROMPT_MESSAGES_ATTRIBUTE,\n AI_PROMPT_TOOLS: AI_PROMPT_TOOLS_ATTRIBUTE,\n AI_PROMPT_TOOL_CHOICE: AI_PROMPT_TOOL_CHOICE_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS: AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS: AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n // Call LLM span information\n AI_RESPONSE_MODEL: AI_RESPONSE_MODEL_ATTRIBUTE,\n AI_RESPONSE_ID: AI_RESPONSE_ID_ATTRIBUTE,\n AI_RESPONSE_TIMESTAMP: AI_RESPONSE_TIMESTAMP_ATTRIBUTE,\n // Semantic Conventions for GenAI operations\n GEN_AI_SYSTEM: GEN_AI_SYSTEM_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL: GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_REQUEST_TEMPERATURE: GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,\n GEN_AI_REQUEST_MAX_TOKENS: GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,\n GEN_AI_REQUEST_FREQUENCY_PENALTY: GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_PRESENCE_PENALTY: GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_K: GEN_AI_REQUEST_TOP_K_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_P: GEN_AI_REQUEST_TOP_P_ATTRIBUTE,\n GEN_AI_REQUEST_STOP_SEQUENCES: GEN_AI_REQUEST_STOP_SEQUENCES_ATTRIBUTE,\n GEN_AI_RESPONSE_FINISH_REASONS: GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL: GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_ID: GEN_AI_RESPONSE_ID_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS: GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS: GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.streamText` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamtext-function\n */\nexport const AI_STREAM_TEXT_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_PROMPT: AI_PROMPT_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS: AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS: AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.streamText.doStream` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamtext-function\n */\nexport const AI_STREAM_TEXT_DO_STREAM_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_RESPONSE_MS_TO_FIRST_CHUNK: AI_RESPONSE_MS_TO_FIRST_CHUNK_ATTRIBUTE,\n AI_RESPONSE_MS_TO_FINISH: AI_RESPONSE_MS_TO_FINISH_ATTRIBUTE,\n AI_RESPONSE_AVG_COMPLETION_TOKENS_PER_SECOND: AI_RESPONSE_AVG_COMPLETION_TOKENS_PER_SECOND_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS: AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS: AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n // Call LLM span information\n AI_RESPONSE_MODEL: AI_RESPONSE_MODEL_ATTRIBUTE,\n AI_RESPONSE_ID: AI_RESPONSE_ID_ATTRIBUTE,\n AI_RESPONSE_TIMESTAMP: AI_RESPONSE_TIMESTAMP_ATTRIBUTE,\n // Semantic Conventions for GenAI operations\n GEN_AI_SYSTEM: GEN_AI_SYSTEM_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL: GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_REQUEST_TEMPERATURE: GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,\n GEN_AI_REQUEST_MAX_TOKENS: GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,\n GEN_AI_REQUEST_FREQUENCY_PENALTY: GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_PRESENCE_PENALTY: GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_K: GEN_AI_REQUEST_TOP_K_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_P: GEN_AI_REQUEST_TOP_P_ATTRIBUTE,\n GEN_AI_REQUEST_STOP_SEQUENCES: GEN_AI_REQUEST_STOP_SEQUENCES_ATTRIBUTE,\n GEN_AI_RESPONSE_FINISH_REASONS: GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL: GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_ID: GEN_AI_RESPONSE_ID_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS: GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS: GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.generateObject` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generateobject-function\n */\nexport const AI_GENERATE_OBJECT_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_SCHEMA: AI_SCHEMA_ATTRIBUTE,\n AI_SCHEMA_NAME: AI_SCHEMA_NAME_ATTRIBUTE,\n AI_SCHEMA_DESCRIPTION: AI_SCHEMA_DESCRIPTION_ATTRIBUTE,\n AI_RESPONSE_OBJECT: AI_RESPONSE_OBJECT_ATTRIBUTE,\n AI_SETTINGS_MODE: AI_SETTINGS_MODE_ATTRIBUTE,\n AI_SETTINGS_OUTPUT: AI_SETTINGS_OUTPUT_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS: AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS: AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.streamObject` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamobject-function\n */\nexport const AI_STREAM_OBJECT_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_SCHEMA: AI_SCHEMA_ATTRIBUTE,\n AI_SCHEMA_NAME: AI_SCHEMA_NAME_ATTRIBUTE,\n AI_SCHEMA_DESCRIPTION: AI_SCHEMA_DESCRIPTION_ATTRIBUTE,\n AI_RESPONSE_OBJECT: AI_RESPONSE_OBJECT_ATTRIBUTE,\n AI_SETTINGS_MODE: AI_SETTINGS_MODE_ATTRIBUTE,\n AI_SETTINGS_OUTPUT: AI_SETTINGS_OUTPUT_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS: AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS: AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.embed` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embed-function\n */\nexport const AI_EMBED_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_VALUE: AI_VALUE_ATTRIBUTE,\n AI_EMBEDDING: AI_EMBEDDING_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n // Basic embedding span information\n AI_USAGE_TOKENS: AI_USAGE_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.embed.doEmbed` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embed-function\n */\nexport const AI_EMBED_DO_EMBED_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_VALUES: AI_VALUES_ATTRIBUTE,\n AI_EMBEDDINGS: AI_EMBEDDINGS_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n // Basic embedding span information\n AI_USAGE_TOKENS: AI_USAGE_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.embedMany` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embedmany-function\n */\nexport const AI_EMBED_MANY_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_VALUES: AI_VALUES_ATTRIBUTE,\n AI_EMBEDDINGS: AI_EMBEDDINGS_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n // Basic embedding span information\n AI_USAGE_TOKENS: AI_USAGE_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.toolCall` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n */\nexport const AI_TOOL_CALL_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_TOOL_CALL_NAME: AI_TOOL_CALL_NAME_ATTRIBUTE,\n AI_TOOL_CALL_ID: AI_TOOL_CALL_ID_ATTRIBUTE,\n AI_TOOL_CALL_ARGS: AI_TOOL_CALL_ARGS_ATTRIBUTE,\n AI_TOOL_CALL_RESULT: AI_TOOL_CALL_RESULT_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n} as const;\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;;;AAkBA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,mBAAoB,GAAE;;AAmNnC;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,qBAAsB,GAAE;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,2BAA4B,GAAE;;AAoB3C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,kCAAmC,GAAE;;AAWlD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,oCAAqC,GAAE;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,gCAAiC,GAAE;;AA+HhD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,+BAAgC,GAAE;;AAW/C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,mCAAoC,GAAE;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,oCAAqC,GAAE;;AAepD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,2BAA4B,GAAE;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,yBAA0B,GAAE;;;;"}
1
+ {"version":3,"file":"ai_sdk_attributes.js","sources":["../../../../../src/integrations/tracing/vercelai/ai_sdk_attributes.ts"],"sourcesContent":["/**\n * AI SDK Telemetry Attributes\n * Based on https://ai-sdk.dev/docs/ai-sdk-core/telemetry#collected-data\n */\n\n// =============================================================================\n// COMMON ATTRIBUTES\n// =============================================================================\n\n/**\n * Common attribute for operation name across all functions and spans\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#collected-data\n */\nexport const OPERATION_NAME_ATTRIBUTE = 'operation.name';\n\n/**\n * Common attribute for AI operation ID across all functions and spans\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#collected-data\n */\nexport const AI_OPERATION_ID_ATTRIBUTE = 'ai.operationId';\n\n// =============================================================================\n// SHARED ATTRIBUTES\n// =============================================================================\n\n/**\n * `generateText` function - `ai.generateText` span\n * `streamText` function - `ai.streamText` span\n *\n * The prompt that was used when calling the function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamtext-function\n */\nexport const AI_PROMPT_ATTRIBUTE = 'ai.prompt';\n\n/**\n * `generateObject` function - `ai.generateObject` span\n * `streamObject` function - `ai.streamObject` span\n *\n * The JSON schema version of the schema that was passed into the function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generateobject-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamobject-function\n */\nexport const AI_SCHEMA_ATTRIBUTE = 'ai.schema';\n\n/**\n * `generateObject` function - `ai.generateObject` span\n * `streamObject` function - `ai.streamObject` span\n *\n * The name of the schema that was passed into the function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generateobject-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamobject-function\n */\nexport const AI_SCHEMA_NAME_ATTRIBUTE = 'ai.schema.name';\n\n/**\n * `generateObject` function - `ai.generateObject` span\n * `streamObject` function - `ai.streamObject` span\n *\n * The description of the schema that was passed into the function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generateobject-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamobject-function\n */\nexport const AI_SCHEMA_DESCRIPTION_ATTRIBUTE = 'ai.schema.description';\n\n/**\n * `generateObject` function - `ai.generateObject` span\n * `streamObject` function - `ai.streamObject` span\n *\n * The object that was generated (stringified JSON)\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generateobject-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamobject-function\n */\nexport const AI_RESPONSE_OBJECT_ATTRIBUTE = 'ai.response.object';\n\n/**\n * `generateObject` function - `ai.generateObject` span\n * `streamObject` function - `ai.streamObject` span\n *\n * The object generation mode, e.g. `json`\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generateobject-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamobject-function\n */\nexport const AI_SETTINGS_MODE_ATTRIBUTE = 'ai.settings.mode';\n\n/**\n * `generateObject` function - `ai.generateObject` span\n * `streamObject` function - `ai.streamObject` span\n *\n * The output type that was used, e.g. `object` or `no-schema`\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generateobject-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamobject-function\n */\nexport const AI_SETTINGS_OUTPUT_ATTRIBUTE = 'ai.settings.output';\n\n/**\n * `embed` function - `ai.embed.doEmbed` span\n * `embedMany` function - `ai.embedMany` span\n *\n * The values that were passed into the function (array)\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embed-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embedmany-function\n */\nexport const AI_VALUES_ATTRIBUTE = 'ai.values';\n\n/**\n * `embed` function - `ai.embed.doEmbed` span\n * `embedMany` function - `ai.embedMany` span\n *\n * An array of JSON-stringified embeddings\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embed-function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embedmany-function\n */\nexport const AI_EMBEDDINGS_ATTRIBUTE = 'ai.embeddings';\n\n// =============================================================================\n// GENERATETEXT FUNCTION - UNIQUE ATTRIBUTES\n// =============================================================================\n\n/**\n * `generateText` function - `ai.generateText` span\n *\n * The text that was generated\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_RESPONSE_TEXT_ATTRIBUTE = 'ai.response.text';\n\n/**\n * `generateText` function - `ai.generateText` span\n *\n * The tool calls that were made as part of the generation (stringified JSON)\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_RESPONSE_TOOL_CALLS_ATTRIBUTE = 'ai.response.toolCalls';\n\n/**\n * `generateText` function - `ai.generateText` span\n *\n * The reason why the generation finished\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_RESPONSE_FINISH_REASON_ATTRIBUTE = 'ai.response.finishReason';\n\n/**\n * `generateText` function - `ai.generateText` span\n *\n * The maximum number of steps that were set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_SETTINGS_MAX_STEPS_ATTRIBUTE = 'ai.settings.maxSteps';\n\n/**\n * `generateText` function - `ai.generateText.doGenerate` span\n *\n * The format of the prompt\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_PROMPT_FORMAT_ATTRIBUTE = 'ai.prompt.format';\n\n/**\n * `generateText` function - `ai.generateText.doGenerate` span\n *\n * The messages that were passed into the provider\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_PROMPT_MESSAGES_ATTRIBUTE = 'ai.prompt.messages';\n\n/**\n * `generateText` function - `ai.generateText.doGenerate` span\n *\n * Array of stringified tool definitions\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_PROMPT_TOOLS_ATTRIBUTE = 'ai.prompt.tools';\n\n/**\n * `generateText` function - `ai.generateText.doGenerate` span\n *\n * The stringified tool choice setting (JSON)\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_PROMPT_TOOL_CHOICE_ATTRIBUTE = 'ai.prompt.toolChoice';\n\n// =============================================================================\n// STREAMTEXT FUNCTION - UNIQUE ATTRIBUTES\n// =============================================================================\n\n/**\n * `streamText` function - `ai.streamText.doStream` span\n *\n * The time it took to receive the first chunk in milliseconds\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamtext-function\n */\nexport const AI_RESPONSE_MS_TO_FIRST_CHUNK_ATTRIBUTE = 'ai.response.msToFirstChunk';\n\n/**\n * `streamText` function - `ai.streamText.doStream` span\n *\n * The time it took to receive the finish part of the LLM stream in milliseconds\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamtext-function\n */\nexport const AI_RESPONSE_MS_TO_FINISH_ATTRIBUTE = 'ai.response.msToFinish';\n\n/**\n * `streamText` function - `ai.streamText.doStream` span\n *\n * The average completion tokens per second\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamtext-function\n */\nexport const AI_RESPONSE_AVG_COMPLETION_TOKENS_PER_SECOND_ATTRIBUTE = 'ai.response.avgCompletionTokensPerSecond';\n\n// =============================================================================\n// EMBED FUNCTION - UNIQUE ATTRIBUTES\n// =============================================================================\n\n/**\n * `embed` function - `ai.embed` span\n *\n * The value that was passed into the `embed` function\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embed-function\n */\nexport const AI_VALUE_ATTRIBUTE = 'ai.value';\n\n/**\n * `embed` function - `ai.embed` span\n *\n * A JSON-stringified embedding\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embed-function\n */\nexport const AI_EMBEDDING_ATTRIBUTE = 'ai.embedding';\n\n// =============================================================================\n// BASIC LLM SPAN INFORMATION\n// =============================================================================\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The functionId that was set through `telemetry.functionId`\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const RESOURCE_NAME_ATTRIBUTE = 'resource.name';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The id of the model\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_MODEL_ID_ATTRIBUTE = 'ai.model.id';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The provider of the model\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_MODEL_PROVIDER_ATTRIBUTE = 'ai.model.provider';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The request headers that were passed in through `headers`\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_REQUEST_HEADERS_ATTRIBUTE = 'ai.request.headers';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The maximum number of retries that were set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_SETTINGS_MAX_RETRIES_ATTRIBUTE = 'ai.settings.maxRetries';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The functionId that was set through `telemetry.functionId`\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE = 'ai.telemetry.functionId';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The metadata that was passed in through `telemetry.metadata`\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_TELEMETRY_METADATA_ATTRIBUTE = 'ai.telemetry.metadata';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The number of completion tokens that were used\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE = 'ai.usage.completionTokens';\n\n/**\n * Basic LLM span information\n * Multiple spans\n *\n * The number of prompt tokens that were used\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-llm-span-information\n */\nexport const AI_USAGE_PROMPT_TOKENS_ATTRIBUTE = 'ai.usage.promptTokens';\n\n// =============================================================================\n// CALL LLM SPAN INFORMATION\n// =============================================================================\n\n/**\n * Call LLM span information\n * Individual LLM call spans\n *\n * The model that was used to generate the response\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const AI_RESPONSE_MODEL_ATTRIBUTE = 'ai.response.model';\n\n/**\n * Call LLM span information\n * Individual LLM call spans\n *\n * The id of the response\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const AI_RESPONSE_ID_ATTRIBUTE = 'ai.response.id';\n\n/**\n * Call LLM span information\n * Individual LLM call spans\n *\n * The timestamp of the response\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const AI_RESPONSE_TIMESTAMP_ATTRIBUTE = 'ai.response.timestamp';\n\n// =============================================================================\n// SEMANTIC CONVENTIONS FOR GENAI OPERATIONS\n// =============================================================================\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The provider that was used\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_SYSTEM_ATTRIBUTE = 'gen_ai.system';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The model that was requested\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_MODEL_ATTRIBUTE = 'gen_ai.request.model';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The temperature that was set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE = 'gen_ai.request.temperature';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The maximum number of tokens that were set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE = 'gen_ai.request.max_tokens';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The frequency penalty that was set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE = 'gen_ai.request.frequency_penalty';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The presence penalty that was set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE = 'gen_ai.request.presence_penalty';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The topK parameter value that was set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_TOP_K_ATTRIBUTE = 'gen_ai.request.top_k';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The topP parameter value that was set\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_TOP_P_ATTRIBUTE = 'gen_ai.request.top_p';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The stop sequences\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_REQUEST_STOP_SEQUENCES_ATTRIBUTE = 'gen_ai.request.stop_sequences';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The finish reasons that were returned by the provider\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE = 'gen_ai.response.finish_reasons';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The model that was used to generate the response\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_RESPONSE_MODEL_ATTRIBUTE = 'gen_ai.response.model';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The id of the response\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_RESPONSE_ID_ATTRIBUTE = 'gen_ai.response.id';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The number of prompt tokens that were used\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE = 'gen_ai.usage.input_tokens';\n\n/**\n * Semantic Conventions for GenAI operations\n * Individual LLM call spans\n *\n * The number of completion tokens that were used\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#call-llm-span-information\n */\nexport const GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE = 'gen_ai.usage.output_tokens';\n\n// =============================================================================\n// BASIC EMBEDDING SPAN INFORMATION\n// =============================================================================\n\n/**\n * Basic embedding span information\n * Embedding spans\n *\n * The number of tokens that were used\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#basic-embedding-span-information\n */\nexport const AI_USAGE_TOKENS_ATTRIBUTE = 'ai.usage.tokens';\n\n// =============================================================================\n// TOOL CALL SPANS\n// =============================================================================\n\n/**\n * Tool call spans\n * `ai.toolCall` span\n *\n * The name of the tool\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n */\nexport const AI_TOOL_CALL_NAME_ATTRIBUTE = 'ai.toolCall.name';\n\n/**\n * Tool call spans\n * `ai.toolCall` span\n *\n * The id of the tool call\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n */\nexport const AI_TOOL_CALL_ID_ATTRIBUTE = 'ai.toolCall.id';\n\n/**\n * Tool call spans\n * `ai.toolCall` span\n *\n * The parameters of the tool call\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n */\nexport const AI_TOOL_CALL_ARGS_ATTRIBUTE = 'ai.toolCall.args';\n\n/**\n * Tool call spans\n * `ai.toolCall` span\n *\n * The result of the tool call\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n */\nexport const AI_TOOL_CALL_RESULT_ATTRIBUTE = 'ai.toolCall.result';\n\n// =============================================================================\n// SPAN ATTRIBUTE OBJECTS\n// =============================================================================\n\n/**\n * Attributes collected for `ai.generateText` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_GENERATE_TEXT_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_PROMPT: AI_PROMPT_ATTRIBUTE,\n AI_RESPONSE_TEXT: AI_RESPONSE_TEXT_ATTRIBUTE,\n AI_RESPONSE_TOOL_CALLS: AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n AI_RESPONSE_FINISH_REASON: AI_RESPONSE_FINISH_REASON_ATTRIBUTE,\n AI_SETTINGS_MAX_STEPS: AI_SETTINGS_MAX_STEPS_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS: AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS: AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.generateText.doGenerate` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generatetext-function\n */\nexport const AI_GENERATE_TEXT_DO_GENERATE_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_PROMPT_FORMAT: AI_PROMPT_FORMAT_ATTRIBUTE,\n AI_PROMPT_MESSAGES: AI_PROMPT_MESSAGES_ATTRIBUTE,\n AI_PROMPT_TOOLS: AI_PROMPT_TOOLS_ATTRIBUTE,\n AI_PROMPT_TOOL_CHOICE: AI_PROMPT_TOOL_CHOICE_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS: AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS: AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n // Call LLM span information\n AI_RESPONSE_MODEL: AI_RESPONSE_MODEL_ATTRIBUTE,\n AI_RESPONSE_ID: AI_RESPONSE_ID_ATTRIBUTE,\n AI_RESPONSE_TIMESTAMP: AI_RESPONSE_TIMESTAMP_ATTRIBUTE,\n // Semantic Conventions for GenAI operations\n GEN_AI_SYSTEM: GEN_AI_SYSTEM_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL: GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_REQUEST_TEMPERATURE: GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,\n GEN_AI_REQUEST_MAX_TOKENS: GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,\n GEN_AI_REQUEST_FREQUENCY_PENALTY: GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_PRESENCE_PENALTY: GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_K: GEN_AI_REQUEST_TOP_K_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_P: GEN_AI_REQUEST_TOP_P_ATTRIBUTE,\n GEN_AI_REQUEST_STOP_SEQUENCES: GEN_AI_REQUEST_STOP_SEQUENCES_ATTRIBUTE,\n GEN_AI_RESPONSE_FINISH_REASONS: GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL: GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_ID: GEN_AI_RESPONSE_ID_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS: GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS: GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.streamText` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamtext-function\n */\nexport const AI_STREAM_TEXT_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_PROMPT: AI_PROMPT_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS: AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS: AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.streamText.doStream` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamtext-function\n */\nexport const AI_STREAM_TEXT_DO_STREAM_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_RESPONSE_MS_TO_FIRST_CHUNK: AI_RESPONSE_MS_TO_FIRST_CHUNK_ATTRIBUTE,\n AI_RESPONSE_MS_TO_FINISH: AI_RESPONSE_MS_TO_FINISH_ATTRIBUTE,\n AI_RESPONSE_AVG_COMPLETION_TOKENS_PER_SECOND: AI_RESPONSE_AVG_COMPLETION_TOKENS_PER_SECOND_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS: AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS: AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n // Call LLM span information\n AI_RESPONSE_MODEL: AI_RESPONSE_MODEL_ATTRIBUTE,\n AI_RESPONSE_ID: AI_RESPONSE_ID_ATTRIBUTE,\n AI_RESPONSE_TIMESTAMP: AI_RESPONSE_TIMESTAMP_ATTRIBUTE,\n // Semantic Conventions for GenAI operations\n GEN_AI_SYSTEM: GEN_AI_SYSTEM_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL: GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_REQUEST_TEMPERATURE: GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,\n GEN_AI_REQUEST_MAX_TOKENS: GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,\n GEN_AI_REQUEST_FREQUENCY_PENALTY: GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_PRESENCE_PENALTY: GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_K: GEN_AI_REQUEST_TOP_K_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_P: GEN_AI_REQUEST_TOP_P_ATTRIBUTE,\n GEN_AI_REQUEST_STOP_SEQUENCES: GEN_AI_REQUEST_STOP_SEQUENCES_ATTRIBUTE,\n GEN_AI_RESPONSE_FINISH_REASONS: GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL: GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_ID: GEN_AI_RESPONSE_ID_ATTRIBUTE,\n GEN_AI_USAGE_INPUT_TOKENS: GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,\n GEN_AI_USAGE_OUTPUT_TOKENS: GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.generateObject` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#generateobject-function\n */\nexport const AI_GENERATE_OBJECT_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_SCHEMA: AI_SCHEMA_ATTRIBUTE,\n AI_SCHEMA_NAME: AI_SCHEMA_NAME_ATTRIBUTE,\n AI_SCHEMA_DESCRIPTION: AI_SCHEMA_DESCRIPTION_ATTRIBUTE,\n AI_RESPONSE_OBJECT: AI_RESPONSE_OBJECT_ATTRIBUTE,\n AI_SETTINGS_MODE: AI_SETTINGS_MODE_ATTRIBUTE,\n AI_SETTINGS_OUTPUT: AI_SETTINGS_OUTPUT_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS: AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS: AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.streamObject` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#streamobject-function\n */\nexport const AI_STREAM_OBJECT_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_SCHEMA: AI_SCHEMA_ATTRIBUTE,\n AI_SCHEMA_NAME: AI_SCHEMA_NAME_ATTRIBUTE,\n AI_SCHEMA_DESCRIPTION: AI_SCHEMA_DESCRIPTION_ATTRIBUTE,\n AI_RESPONSE_OBJECT: AI_RESPONSE_OBJECT_ATTRIBUTE,\n AI_SETTINGS_MODE: AI_SETTINGS_MODE_ATTRIBUTE,\n AI_SETTINGS_OUTPUT: AI_SETTINGS_OUTPUT_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n AI_USAGE_COMPLETION_TOKENS: AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE,\n AI_USAGE_PROMPT_TOKENS: AI_USAGE_PROMPT_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.embed` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embed-function\n */\nexport const AI_EMBED_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_VALUE: AI_VALUE_ATTRIBUTE,\n AI_EMBEDDING: AI_EMBEDDING_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n // Basic embedding span information\n AI_USAGE_TOKENS: AI_USAGE_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.embed.doEmbed` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embed-function\n */\nexport const AI_EMBED_DO_EMBED_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_VALUES: AI_VALUES_ATTRIBUTE,\n AI_EMBEDDINGS: AI_EMBEDDINGS_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n // Basic embedding span information\n AI_USAGE_TOKENS: AI_USAGE_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.embedMany` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#embedmany-function\n */\nexport const AI_EMBED_MANY_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_VALUES: AI_VALUES_ATTRIBUTE,\n AI_EMBEDDINGS: AI_EMBEDDINGS_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n // Basic embedding span information\n AI_USAGE_TOKENS: AI_USAGE_TOKENS_ATTRIBUTE,\n} as const;\n\n/**\n * Attributes collected for `ai.toolCall` span\n * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry#tool-call-spans\n */\nexport const AI_TOOL_CALL_SPAN_ATTRIBUTES = {\n OPERATION_NAME: OPERATION_NAME_ATTRIBUTE,\n AI_OPERATION_ID: AI_OPERATION_ID_ATTRIBUTE,\n AI_TOOL_CALL_NAME: AI_TOOL_CALL_NAME_ATTRIBUTE,\n AI_TOOL_CALL_ID: AI_TOOL_CALL_ID_ATTRIBUTE,\n AI_TOOL_CALL_ARGS: AI_TOOL_CALL_ARGS_ATTRIBUTE,\n AI_TOOL_CALL_RESULT: AI_TOOL_CALL_RESULT_ATTRIBUTE,\n // Basic LLM span information\n RESOURCE_NAME: RESOURCE_NAME_ATTRIBUTE,\n AI_MODEL_ID: AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER: AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_REQUEST_HEADERS: AI_REQUEST_HEADERS_ATTRIBUTE,\n AI_SETTINGS_MAX_RETRIES: AI_SETTINGS_MAX_RETRIES_ATTRIBUTE,\n AI_TELEMETRY_FUNCTION_ID: AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE,\n AI_TELEMETRY_METADATA: AI_TELEMETRY_METADATA_ATTRIBUTE,\n} as const;\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;;;AAkBA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,mBAAoB,GAAE;;AAkFnC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,0BAA2B,GAAE;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,gCAAiC,GAAE;;AA0BhD;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,4BAA6B,GAAE;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,yBAA0B,GAAE;;AAuEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,qBAAsB,GAAE;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,2BAA4B,GAAE;;AAoB3C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,kCAAmC,GAAE;;AAWlD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,oCAAqC,GAAE;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,gCAAiC,GAAE;;AA+HhD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,+BAAgC,GAAE;;AAW/C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,mCAAoC,GAAE;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,oCAAqC,GAAE;;AAepD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,2BAA4B,GAAE;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,yBAA0B,GAAE;;;;"}
@@ -1,12 +1,21 @@
1
1
  import { defineIntegration, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';
2
2
  import { generateInstrumentOnce } from '../../../otel/instrument.js';
3
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, AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE, GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE, AI_USAGE_PROMPT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE } from './ai_sdk_attributes.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
5
  import { INTEGRATION_NAME } from './constants.js';
6
6
  import { SentryVercelAiInstrumentation } from './instrumentation.js';
7
7
 
8
8
  const instrumentVercelAi = generateInstrumentOnce(INTEGRATION_NAME, () => new SentryVercelAiInstrumentation({}));
9
9
 
10
+ /**
11
+ * Determines if the integration should be forced based on environment and package availability.
12
+ * Returns true if the 'ai' package is available.
13
+ */
14
+ function shouldForceIntegration(client) {
15
+ const modules = client.getIntegrationByName('Modules');
16
+ return !!modules?.getModules?.()?.ai;
17
+ }
18
+
10
19
  const _vercelAIIntegration = ((options = {}) => {
11
20
  let instrumentation;
12
21
 
@@ -16,7 +25,7 @@ const _vercelAIIntegration = ((options = {}) => {
16
25
  setupOnce() {
17
26
  instrumentation = instrumentVercelAi();
18
27
  },
19
- setup(client) {
28
+ afterAllSetup(client) {
20
29
  function registerProcessors() {
21
30
  client.on('spanStart', span => {
22
31
  const { data: attributes, description: name } = spanToJSON(span);
@@ -152,14 +161,12 @@ const _vercelAIIntegration = ((options = {}) => {
152
161
  continue;
153
162
  }
154
163
 
155
- if (attributes[AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE] != undefined) {
156
- attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] = attributes[AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE];
157
- delete attributes[AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE];
158
- }
159
- if (attributes[AI_USAGE_PROMPT_TOKENS_ATTRIBUTE] != undefined) {
160
- attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] = attributes[AI_USAGE_PROMPT_TOKENS_ATTRIBUTE];
161
- delete attributes[AI_USAGE_PROMPT_TOKENS_ATTRIBUTE];
162
- }
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);
163
170
  if (
164
171
  typeof attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] === 'number' &&
165
172
  typeof attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] === 'number'
@@ -167,6 +174,12 @@ const _vercelAIIntegration = ((options = {}) => {
167
174
  attributes['gen_ai.usage.total_tokens'] =
168
175
  attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] + attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE];
169
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');
170
183
  }
171
184
  }
172
185
 
@@ -174,7 +187,11 @@ const _vercelAIIntegration = ((options = {}) => {
174
187
  });
175
188
  }
176
189
 
177
- if (options.force) {
190
+ // Auto-detect if we should force the integration when running with 'ai' package available
191
+ // Note that this can only be detected if the 'Modules' integration is available, and running in CJS mode
192
+ const shouldForce = options.force ?? shouldForceIntegration(client);
193
+
194
+ if (shouldForce) {
178
195
  registerProcessors();
179
196
  } else {
180
197
  instrumentation?.callWhenPatched(registerProcessors);
@@ -197,6 +214,9 @@ const _vercelAIIntegration = ((options = {}) => {
197
214
  * });
198
215
  * ```
199
216
  *
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
+ *
200
220
  * By default this integration adds tracing support to all `ai` function calls. If you need to disable
201
221
  * collecting spans for a specific call, you can do so by setting `experimental_telemetry.isEnabled` to
202
222
  * `false` in the first argument of the function call.
@@ -220,5 +240,16 @@ const _vercelAIIntegration = ((options = {}) => {
220
240
  */
221
241
  const vercelAIIntegration = defineIntegration(_vercelAIIntegration);
222
242
 
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
+
223
254
  export { instrumentVercelAi, vercelAIIntegration };
224
255
  //# 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 { 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 {\n AI_MODEL_ID_ATTRIBUTE,\n AI_MODEL_PROVIDER_ATTRIBUTE,\n AI_PROMPT_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\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 setup(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 if (attributes[AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE] != undefined) {\n attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE] = attributes[AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE];\n delete attributes[AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE];\n }\n if (attributes[AI_USAGE_PROMPT_TOKENS_ATTRIBUTE] != undefined) {\n attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE] = attributes[AI_USAGE_PROMPT_TOKENS_ATTRIBUTE];\n delete attributes[AI_USAGE_PROMPT_TOKENS_ATTRIBUTE];\n }\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 }\n\n return event;\n });\n }\n\n if (options.force) {\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 * 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"],"names":[],"mappings":";;;;;;;MAuBa,kBAAmB,GAAE,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,IAAI,6BAA6B,CAAC,EAAE,CAAC;;AAEtH,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,KAAK,CAAC,MAAM,EAAE;AAClB,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,I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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,MAAA,mBAAA,GAAA,iBAAA,CAAA,oBAAA;;;;"}
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,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AAA;AACA;AACA;;AAEA,UAAA,OAAA,KAAA;AACA,SAAA,CAAA;AACA;;AAEA;AACA;AACA,MAAA,MAAA,WAAA,GAAA,OAAA,CAAA,KAAA,IAAA,sBAAA,CAAA,MAAA,CAAA;;AAEA,MAAA,IAAA,WAAA,EAAA;AACA,QAAA,kBAAA,EAAA;AACA,OAAA,MAAA;AACA,QAAA,eAAA,EAAA,eAAA,CAAA,kBAAA,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 +1 @@
1
- {"type":"module","version":"9.29.0","sideEffects":false}
1
+ {"type":"module","version":"9.31.0","sideEffects":false}
@@ -20,10 +20,6 @@ import { defaultStackParser, getSentryRelease } from './api.js';
20
20
  import { NodeClient } from './client.js';
21
21
  import { maybeInitializeEsmLoader, initOpenTelemetry } from './initOtel.js';
22
22
 
23
- function getCjsOnlyIntegrations() {
24
- return isCjs() ? [modulesIntegration()] : [];
25
- }
26
-
27
23
  /**
28
24
  * Get default integrations, excluding performance.
29
25
  */
@@ -49,7 +45,7 @@ function getDefaultIntegrationsWithoutPerformance() {
49
45
  nodeContextIntegration(),
50
46
  childProcessIntegration(),
51
47
  processSessionIntegration(),
52
- ...getCjsOnlyIntegrations(),
48
+ modulesIntegration(),
53
49
  ];
54
50
  }
55
51
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/sdk/index.ts"],"sourcesContent":["import type { Integration, Options } from '@sentry/core';\nimport {\n consoleIntegration,\n consoleSandbox,\n functionToStringIntegration,\n getCurrentScope,\n getIntegrationsToSetup,\n hasSpansEnabled,\n inboundFiltersIntegration,\n linkedErrorsIntegration,\n logger,\n propagationContextFromHeaders,\n requestDataIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport {\n enhanceDscWithOpenTelemetryRootSpanName,\n openTelemetrySetupCheck,\n setOpenTelemetryContextAsyncContextStrategy,\n setupEventContextTrace,\n} from '@sentry/opentelemetry';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { childProcessIntegration } from '../integrations/childProcess';\nimport { nodeContextIntegration } from '../integrations/context';\nimport { contextLinesIntegration } from '../integrations/contextlines';\nimport { httpIntegration } from '../integrations/http';\nimport { localVariablesIntegration } from '../integrations/local-variables';\nimport { modulesIntegration } from '../integrations/modules';\nimport { nativeNodeFetchIntegration } from '../integrations/node-fetch';\nimport { onUncaughtExceptionIntegration } from '../integrations/onuncaughtexception';\nimport { onUnhandledRejectionIntegration } from '../integrations/onunhandledrejection';\nimport { processSessionIntegration } from '../integrations/processSession';\nimport { INTEGRATION_NAME as SPOTLIGHT_INTEGRATION_NAME, spotlightIntegration } from '../integrations/spotlight';\nimport { getAutoPerformanceIntegrations } from '../integrations/tracing';\nimport { makeNodeTransport } from '../transports';\nimport type { NodeClientOptions, NodeOptions } from '../types';\nimport { isCjs } from '../utils/commonjs';\nimport { envToBool } from '../utils/envToBool';\nimport { defaultStackParser, getSentryRelease } from './api';\nimport { NodeClient } from './client';\nimport { initOpenTelemetry, maybeInitializeEsmLoader } from './initOtel';\n\nfunction getCjsOnlyIntegrations(): Integration[] {\n return isCjs() ? [modulesIntegration()] : [];\n}\n\n/**\n * Get default integrations, excluding performance.\n */\nexport function getDefaultIntegrationsWithoutPerformance(): Integration[] {\n return [\n // Common\n // TODO(v10): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line deprecation/deprecation\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n linkedErrorsIntegration(),\n requestDataIntegration(),\n // Native Wrappers\n consoleIntegration(),\n httpIntegration(),\n nativeNodeFetchIntegration(),\n // Global Handlers\n onUncaughtExceptionIntegration(),\n onUnhandledRejectionIntegration(),\n // Event Info\n contextLinesIntegration(),\n localVariablesIntegration(),\n nodeContextIntegration(),\n childProcessIntegration(),\n processSessionIntegration(),\n ...getCjsOnlyIntegrations(),\n ];\n}\n\n/** Get the default integrations for the Node SDK. */\nexport function getDefaultIntegrations(options: Options): Integration[] {\n return [\n ...getDefaultIntegrationsWithoutPerformance(),\n // We only add performance integrations if tracing is enabled\n // Note that this means that without tracing enabled, e.g. `expressIntegration()` will not be added\n // This means that generally request isolation will work (because that is done by httpIntegration)\n // But `transactionName` will not be set automatically\n ...(hasSpansEnabled(options) ? getAutoPerformanceIntegrations() : []),\n ];\n}\n\n/**\n * Initialize Sentry for Node.\n */\nexport function init(options: NodeOptions | undefined = {}): NodeClient | undefined {\n return _init(options, getDefaultIntegrations);\n}\n\n/**\n * Initialize Sentry for Node, without any integrations added by default.\n */\nexport function initWithoutDefaultIntegrations(options: NodeOptions | undefined = {}): NodeClient {\n return _init(options, () => []);\n}\n\n/**\n * Initialize Sentry for Node, without performance instrumentation.\n */\nfunction _init(\n _options: NodeOptions | undefined = {},\n getDefaultIntegrationsImpl: (options: Options) => Integration[],\n): NodeClient {\n const options = getClientOptions(_options, getDefaultIntegrationsImpl);\n\n if (options.debug === true) {\n if (DEBUG_BUILD) {\n logger.enable();\n } else {\n // use `console.warn` rather than `logger.warn` since by non-debug bundles have all `logger.x` statements stripped\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn('[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.');\n });\n }\n }\n\n if (!isCjs() && options.registerEsmLoaderHooks !== false) {\n maybeInitializeEsmLoader();\n }\n\n setOpenTelemetryContextAsyncContextStrategy();\n\n const scope = getCurrentScope();\n scope.update(options.initialScope);\n\n if (options.spotlight && !options.integrations.some(({ name }) => name === SPOTLIGHT_INTEGRATION_NAME)) {\n options.integrations.push(\n spotlightIntegration({\n sidecarUrl: typeof options.spotlight === 'string' ? options.spotlight : undefined,\n }),\n );\n }\n\n const client = new NodeClient(options);\n // The client is on the current scope, from where it generally is inherited\n getCurrentScope().setClient(client);\n\n client.init();\n\n logger.log(`Running in ${isCjs() ? 'CommonJS' : 'ESM'} mode.`);\n\n client.startClientReportTracking();\n\n updateScopeFromEnvVariables();\n\n // If users opt-out of this, they _have_ to set up OpenTelemetry themselves\n // There is no way to use this SDK without OpenTelemetry!\n if (!options.skipOpenTelemetrySetup) {\n initOpenTelemetry(client, {\n spanProcessors: options.openTelemetrySpanProcessors,\n });\n validateOpenTelemetrySetup();\n }\n\n enhanceDscWithOpenTelemetryRootSpanName(client);\n setupEventContextTrace(client);\n\n return client;\n}\n\n/**\n * Validate that your OpenTelemetry setup is correct.\n */\nexport function validateOpenTelemetrySetup(): void {\n if (!DEBUG_BUILD) {\n return;\n }\n\n const setup = openTelemetrySetupCheck();\n\n const required: ReturnType<typeof openTelemetrySetupCheck> = ['SentryContextManager', 'SentryPropagator'];\n\n if (hasSpansEnabled()) {\n required.push('SentrySpanProcessor');\n }\n\n for (const k of required) {\n if (!setup.includes(k)) {\n logger.error(\n `You have to set up the ${k}. Without this, the OpenTelemetry & Sentry integration will not work properly.`,\n );\n }\n }\n\n if (!setup.includes('SentrySampler')) {\n logger.warn(\n 'You have to set up the SentrySampler. Without this, the OpenTelemetry & Sentry integration may still work, but sample rates set for the Sentry SDK will not be respected. If you use a custom sampler, make sure to use `wrapSamplingDecision`.',\n );\n }\n}\n\nfunction getClientOptions(\n options: NodeOptions,\n getDefaultIntegrationsImpl: (options: Options) => Integration[],\n): NodeClientOptions {\n const release = getRelease(options.release);\n const spotlight =\n options.spotlight ?? envToBool(process.env.SENTRY_SPOTLIGHT, { strict: true }) ?? process.env.SENTRY_SPOTLIGHT;\n const tracesSampleRate = getTracesSampleRate(options.tracesSampleRate);\n\n const mergedOptions = {\n ...options,\n dsn: options.dsn ?? process.env.SENTRY_DSN,\n environment: options.environment ?? process.env.SENTRY_ENVIRONMENT,\n sendClientReports: options.sendClientReports ?? true,\n transport: options.transport ?? makeNodeTransport,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n release,\n tracesSampleRate,\n spotlight,\n debug: envToBool(options.debug ?? process.env.SENTRY_DEBUG),\n };\n\n const integrations = options.integrations;\n const defaultIntegrations = options.defaultIntegrations ?? getDefaultIntegrationsImpl(mergedOptions);\n\n return {\n ...mergedOptions,\n integrations: getIntegrationsToSetup({\n defaultIntegrations,\n integrations,\n }),\n };\n}\n\nfunction getRelease(release: NodeOptions['release']): string | undefined {\n if (release !== undefined) {\n return release;\n }\n\n const detectedRelease = getSentryRelease();\n if (detectedRelease !== undefined) {\n return detectedRelease;\n }\n\n return undefined;\n}\n\nfunction getTracesSampleRate(tracesSampleRate: NodeOptions['tracesSampleRate']): number | undefined {\n if (tracesSampleRate !== undefined) {\n return tracesSampleRate;\n }\n\n const sampleRateFromEnv = process.env.SENTRY_TRACES_SAMPLE_RATE;\n if (!sampleRateFromEnv) {\n return undefined;\n }\n\n const parsed = parseFloat(sampleRateFromEnv);\n return isFinite(parsed) ? parsed : undefined;\n}\n\n/**\n * Update scope and propagation context based on environmental variables.\n *\n * See https://github.com/getsentry/rfcs/blob/main/text/0071-continue-trace-over-process-boundaries.md\n * for more details.\n */\nfunction updateScopeFromEnvVariables(): void {\n if (envToBool(process.env.SENTRY_USE_ENVIRONMENT) !== false) {\n const sentryTraceEnv = process.env.SENTRY_TRACE;\n const baggageEnv = process.env.SENTRY_BAGGAGE;\n const propagationContext = propagationContextFromHeaders(sentryTraceEnv, bagg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AAM,eAAA,GAAkB,gBAAgB,EAAE;AAC5C,EAAE,IAAI,eAAgB,KAAI,SAAS,EAAE;AACrC,IAAI,OAAO,eAAe;AAC1B;;AAEA,EAAE,OAAO,SAAS;AAClB;;AAEA,SAAS,mBAAmB,CAAC,gBAAgB,EAAuD;AACpG,EAAE,IAAI,gBAAiB,KAAI,SAAS,EAAE;AACtC,IAAI,OAAO,gBAAgB;AAC3B;;AAEA,EAAE,MAAM,iBAAkB,GAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB;AACjE,EAAE,IAAI,CAAC,iBAAiB,EAAE;AAC1B,IAAI,OAAO,SAAS;AACpB;;AAEA,EAAE,MAAM,MAAO,GAAE,UAAU,CAAC,iBAAiB,CAAC;AAC9C,EAAE,OAAO,QAAQ,CAAC,MAAM,IAAI,MAAA,GAAS,SAAS;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,2BAA2B,GAAS;AAC7C,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAA,KAAM,KAAK,EAAE;AAC/D,IAAI,MAAM,cAAe,GAAE,OAAO,CAAC,GAAG,CAAC,YAAY;AACnD,IAAI,MAAM,UAAW,GAAE,OAAO,CAAC,GAAG,CAAC,cAAc;AACjD,IAAI,MAAM,qBAAqB,6BAA6B,CAAC,cAAc,EAAE,UAAU,CAAC;AACxF,IAAI,eAAe,EAAE,CAAC,qBAAqB,CAAC,kBAAkB,CAAC;AAC/D;AACA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/sdk/index.ts"],"sourcesContent":["import type { Integration, Options } from '@sentry/core';\nimport {\n consoleIntegration,\n consoleSandbox,\n functionToStringIntegration,\n getCurrentScope,\n getIntegrationsToSetup,\n hasSpansEnabled,\n inboundFiltersIntegration,\n linkedErrorsIntegration,\n logger,\n propagationContextFromHeaders,\n requestDataIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport {\n enhanceDscWithOpenTelemetryRootSpanName,\n openTelemetrySetupCheck,\n setOpenTelemetryContextAsyncContextStrategy,\n setupEventContextTrace,\n} from '@sentry/opentelemetry';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { childProcessIntegration } from '../integrations/childProcess';\nimport { nodeContextIntegration } from '../integrations/context';\nimport { contextLinesIntegration } from '../integrations/contextlines';\nimport { httpIntegration } from '../integrations/http';\nimport { localVariablesIntegration } from '../integrations/local-variables';\nimport { modulesIntegration } from '../integrations/modules';\nimport { nativeNodeFetchIntegration } from '../integrations/node-fetch';\nimport { onUncaughtExceptionIntegration } from '../integrations/onuncaughtexception';\nimport { onUnhandledRejectionIntegration } from '../integrations/onunhandledrejection';\nimport { processSessionIntegration } from '../integrations/processSession';\nimport { INTEGRATION_NAME as SPOTLIGHT_INTEGRATION_NAME, spotlightIntegration } from '../integrations/spotlight';\nimport { getAutoPerformanceIntegrations } from '../integrations/tracing';\nimport { makeNodeTransport } from '../transports';\nimport type { NodeClientOptions, NodeOptions } from '../types';\nimport { isCjs } from '../utils/commonjs';\nimport { envToBool } from '../utils/envToBool';\nimport { defaultStackParser, getSentryRelease } from './api';\nimport { NodeClient } from './client';\nimport { initOpenTelemetry, maybeInitializeEsmLoader } from './initOtel';\n\n/**\n * Get default integrations, excluding performance.\n */\nexport function getDefaultIntegrationsWithoutPerformance(): Integration[] {\n return [\n // Common\n // TODO(v10): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line deprecation/deprecation\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n linkedErrorsIntegration(),\n requestDataIntegration(),\n // Native Wrappers\n consoleIntegration(),\n httpIntegration(),\n nativeNodeFetchIntegration(),\n // Global Handlers\n onUncaughtExceptionIntegration(),\n onUnhandledRejectionIntegration(),\n // Event Info\n contextLinesIntegration(),\n localVariablesIntegration(),\n nodeContextIntegration(),\n childProcessIntegration(),\n processSessionIntegration(),\n modulesIntegration(),\n ];\n}\n\n/** Get the default integrations for the Node SDK. */\nexport function getDefaultIntegrations(options: Options): Integration[] {\n return [\n ...getDefaultIntegrationsWithoutPerformance(),\n // We only add performance integrations if tracing is enabled\n // Note that this means that without tracing enabled, e.g. `expressIntegration()` will not be added\n // This means that generally request isolation will work (because that is done by httpIntegration)\n // But `transactionName` will not be set automatically\n ...(hasSpansEnabled(options) ? getAutoPerformanceIntegrations() : []),\n ];\n}\n\n/**\n * Initialize Sentry for Node.\n */\nexport function init(options: NodeOptions | undefined = {}): NodeClient | undefined {\n return _init(options, getDefaultIntegrations);\n}\n\n/**\n * Initialize Sentry for Node, without any integrations added by default.\n */\nexport function initWithoutDefaultIntegrations(options: NodeOptions | undefined = {}): NodeClient {\n return _init(options, () => []);\n}\n\n/**\n * Initialize Sentry for Node, without performance instrumentation.\n */\nfunction _init(\n _options: NodeOptions | undefined = {},\n getDefaultIntegrationsImpl: (options: Options) => Integration[],\n): NodeClient {\n const options = getClientOptions(_options, getDefaultIntegrationsImpl);\n\n if (options.debug === true) {\n if (DEBUG_BUILD) {\n logger.enable();\n } else {\n // use `console.warn` rather than `logger.warn` since by non-debug bundles have all `logger.x` statements stripped\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn('[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.');\n });\n }\n }\n\n if (!isCjs() && options.registerEsmLoaderHooks !== false) {\n maybeInitializeEsmLoader();\n }\n\n setOpenTelemetryContextAsyncContextStrategy();\n\n const scope = getCurrentScope();\n scope.update(options.initialScope);\n\n if (options.spotlight && !options.integrations.some(({ name }) => name === SPOTLIGHT_INTEGRATION_NAME)) {\n options.integrations.push(\n spotlightIntegration({\n sidecarUrl: typeof options.spotlight === 'string' ? options.spotlight : undefined,\n }),\n );\n }\n\n const client = new NodeClient(options);\n // The client is on the current scope, from where it generally is inherited\n getCurrentScope().setClient(client);\n\n client.init();\n\n logger.log(`Running in ${isCjs() ? 'CommonJS' : 'ESM'} mode.`);\n\n client.startClientReportTracking();\n\n updateScopeFromEnvVariables();\n\n // If users opt-out of this, they _have_ to set up OpenTelemetry themselves\n // There is no way to use this SDK without OpenTelemetry!\n if (!options.skipOpenTelemetrySetup) {\n initOpenTelemetry(client, {\n spanProcessors: options.openTelemetrySpanProcessors,\n });\n validateOpenTelemetrySetup();\n }\n\n enhanceDscWithOpenTelemetryRootSpanName(client);\n setupEventContextTrace(client);\n\n return client;\n}\n\n/**\n * Validate that your OpenTelemetry setup is correct.\n */\nexport function validateOpenTelemetrySetup(): void {\n if (!DEBUG_BUILD) {\n return;\n }\n\n const setup = openTelemetrySetupCheck();\n\n const required: ReturnType<typeof openTelemetrySetupCheck> = ['SentryContextManager', 'SentryPropagator'];\n\n if (hasSpansEnabled()) {\n required.push('SentrySpanProcessor');\n }\n\n for (const k of required) {\n if (!setup.includes(k)) {\n logger.error(\n `You have to set up the ${k}. Without this, the OpenTelemetry & Sentry integration will not work properly.`,\n );\n }\n }\n\n if (!setup.includes('SentrySampler')) {\n logger.warn(\n 'You have to set up the SentrySampler. Without this, the OpenTelemetry & Sentry integration may still work, but sample rates set for the Sentry SDK will not be respected. If you use a custom sampler, make sure to use `wrapSamplingDecision`.',\n );\n }\n}\n\nfunction getClientOptions(\n options: NodeOptions,\n getDefaultIntegrationsImpl: (options: Options) => Integration[],\n): NodeClientOptions {\n const release = getRelease(options.release);\n const spotlight =\n options.spotlight ?? envToBool(process.env.SENTRY_SPOTLIGHT, { strict: true }) ?? process.env.SENTRY_SPOTLIGHT;\n const tracesSampleRate = getTracesSampleRate(options.tracesSampleRate);\n\n const mergedOptions = {\n ...options,\n dsn: options.dsn ?? process.env.SENTRY_DSN,\n environment: options.environment ?? process.env.SENTRY_ENVIRONMENT,\n sendClientReports: options.sendClientReports ?? true,\n transport: options.transport ?? makeNodeTransport,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n release,\n tracesSampleRate,\n spotlight,\n debug: envToBool(options.debug ?? process.env.SENTRY_DEBUG),\n };\n\n const integrations = options.integrations;\n const defaultIntegrations = options.defaultIntegrations ?? getDefaultIntegrationsImpl(mergedOptions);\n\n return {\n ...mergedOptions,\n integrations: getIntegrationsToSetup({\n defaultIntegrations,\n integrations,\n }),\n };\n}\n\nfunction getRelease(release: NodeOptions['release']): string | undefined {\n if (release !== undefined) {\n return release;\n }\n\n const detectedRelease = getSentryRelease();\n if (detectedRelease !== undefined) {\n return detectedRelease;\n }\n\n return undefined;\n}\n\nfunction getTracesSampleRate(tracesSampleRate: NodeOptions['tracesSampleRate']): number | undefined {\n if (tracesSampleRate !== undefined) {\n return tracesSampleRate;\n }\n\n const sampleRateFromEnv = process.env.SENTRY_TRACES_SAMPLE_RATE;\n if (!sampleRateFromEnv) {\n return undefined;\n }\n\n const parsed = parseFloat(sampleRateFromEnv);\n return isFinite(parsed) ? parsed : undefined;\n}\n\n/**\n * Update scope and propagation context based on environmental variables.\n *\n * See https://github.com/getsentry/rfcs/blob/main/text/0071-continue-trace-over-process-boundaries.md\n * for more details.\n */\nfunction updateScopeFromEnvVariables(): void {\n if (envToBool(process.env.SENTRY_USE_ENVIRONMENT) !== false) {\n const sentryTraceEnv = process.env.SENTRY_TRACE;\n const baggageEnv = process.env.SENTRY_BAGGAGE;\n const propagationContext = propagationContextFromHeaders(sentryTraceEnv, baggageEnv);\n getCurrentScope().setPropagationContext(propagationContext);\n }\n}\n"],"names":["SPOTLIGHT_INTEGRATION_NAME"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0CA;AACA;AACA;AACO,SAAS,wCAAwC,GAAkB;AAC1E,EAAE,OAAO;AACT;AACA;AACA;AACA,IAAI,yBAAyB,EAAE;AAC/B,IAAI,2BAA2B,EAAE;AACjC,IAAI,uBAAuB,EAAE;AAC7B,IAAI,sBAAsB,EAAE;AAC5B;AACA,IAAI,kBAAkB,EAAE;AACxB,IAAI,eAAe,EAAE;AACrB,IAAI,0BAA0B,EAAE;AAChC;AACA,IAAI,8BAA8B,EAAE;AACpC,IAAI,+BAA+B,EAAE;AACrC;AACA,IAAI,uB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