@sentry/node 10.59.0 → 10.61.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.
- package/build/cjs/index.js +3 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/fs/index.js +8 -17
- package/build/cjs/integrations/fs/index.js.map +1 -1
- package/build/cjs/integrations/fs/vendored/instrumentation.js +110 -161
- package/build/cjs/integrations/fs/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/node-fetch/index.js +7 -8
- package/build/cjs/integrations/node-fetch/index.js.map +1 -1
- package/build/cjs/integrations/node-fetch/vendored/semconv.js +28 -0
- package/build/cjs/integrations/node-fetch/vendored/semconv.js.map +1 -0
- package/build/cjs/integrations/node-fetch/vendored/undici.js +90 -127
- package/build/cjs/integrations/node-fetch/vendored/undici.js.map +1 -1
- package/build/cjs/integrations/tracing/dataloader/vendored/instrumentation.js +5 -6
- package/build/cjs/integrations/tracing/dataloader/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/kafka/index.js +1 -11
- package/build/cjs/integrations/tracing/kafka/index.js.map +1 -1
- package/build/cjs/integrations/tracing/kafka/vendored/instrumentation.js +45 -247
- package/build/cjs/integrations/tracing/kafka/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/kafka/vendored/semconv.js +4 -8
- package/build/cjs/integrations/tracing/kafka/vendored/semconv.js.map +1 -1
- package/build/cjs/integrations/tracing/kafka/vendored/utils.js +113 -0
- package/build/cjs/integrations/tracing/kafka/vendored/utils.js.map +1 -0
- package/build/cjs/integrations/tracing/knex/vendored/instrumentation.js +1 -2
- package/build/cjs/integrations/tracing/knex/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/mongo/vendored/utils.js +1 -2
- package/build/cjs/integrations/tracing/mongo/vendored/utils.js.map +1 -1
- package/build/cjs/integrations/tracing/mongoose/vendored/mongoose.js +1 -2
- package/build/cjs/integrations/tracing/mongoose/vendored/mongoose.js.map +1 -1
- package/build/cjs/integrations/tracing/mysql2/vendored/instrumentation.js +1 -2
- package/build/cjs/integrations/tracing/mysql2/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/postgres/vendored/instrumentation.js +2 -3
- package/build/cjs/integrations/tracing/postgres/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/postgres/vendored/utils.js +1 -2
- package/build/cjs/integrations/tracing/postgres/vendored/utils.js.map +1 -1
- package/build/cjs/integrations/tracing/redis/index.js +4 -2
- package/build/cjs/integrations/tracing/redis/index.js.map +1 -1
- package/build/cjs/integrations/tracing/redis/vendored/ioredis-instrumentation.js +2 -3
- package/build/cjs/integrations/tracing/redis/vendored/ioredis-instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/redis/vendored/redis-instrumentation.js +3 -4
- package/build/cjs/integrations/tracing/redis/vendored/redis-instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/tedious/vendored/instrumentation.js +1 -2
- package/build/cjs/integrations/tracing/tedious/vendored/instrumentation.js.map +1 -1
- package/build/cjs/sdk/initOtel.js +2 -1
- package/build/cjs/sdk/initOtel.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/integrations/fs/index.js +9 -18
- package/build/esm/integrations/fs/index.js.map +1 -1
- package/build/esm/integrations/fs/vendored/instrumentation.js +111 -162
- package/build/esm/integrations/fs/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/node-fetch/index.js +8 -9
- package/build/esm/integrations/node-fetch/index.js.map +1 -1
- package/build/esm/integrations/node-fetch/vendored/semconv.js +15 -0
- package/build/esm/integrations/node-fetch/vendored/semconv.js.map +1 -0
- package/build/esm/integrations/node-fetch/vendored/undici.js +79 -116
- package/build/esm/integrations/node-fetch/vendored/undici.js.map +1 -1
- package/build/esm/integrations/tracing/dataloader/vendored/instrumentation.js +6 -7
- package/build/esm/integrations/tracing/dataloader/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/kafka/index.js +2 -12
- package/build/esm/integrations/tracing/kafka/index.js.map +1 -1
- package/build/esm/integrations/tracing/kafka/vendored/instrumentation.js +47 -249
- package/build/esm/integrations/tracing/kafka/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/kafka/vendored/semconv.js +3 -5
- package/build/esm/integrations/tracing/kafka/vendored/semconv.js.map +1 -1
- package/build/esm/integrations/tracing/kafka/vendored/utils.js +107 -0
- package/build/esm/integrations/tracing/kafka/vendored/utils.js.map +1 -0
- package/build/esm/integrations/tracing/knex/vendored/instrumentation.js +2 -3
- package/build/esm/integrations/tracing/knex/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/mongo/vendored/utils.js +2 -3
- package/build/esm/integrations/tracing/mongo/vendored/utils.js.map +1 -1
- package/build/esm/integrations/tracing/mongoose/vendored/mongoose.js +2 -3
- package/build/esm/integrations/tracing/mongoose/vendored/mongoose.js.map +1 -1
- package/build/esm/integrations/tracing/mysql2/vendored/instrumentation.js +2 -3
- package/build/esm/integrations/tracing/mysql2/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/postgres/vendored/instrumentation.js +3 -4
- package/build/esm/integrations/tracing/postgres/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/postgres/vendored/utils.js +2 -3
- package/build/esm/integrations/tracing/postgres/vendored/utils.js.map +1 -1
- package/build/esm/integrations/tracing/redis/index.js +4 -2
- package/build/esm/integrations/tracing/redis/index.js.map +1 -1
- package/build/esm/integrations/tracing/redis/vendored/ioredis-instrumentation.js +3 -4
- package/build/esm/integrations/tracing/redis/vendored/ioredis-instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/redis/vendored/redis-instrumentation.js +4 -5
- package/build/esm/integrations/tracing/redis/vendored/redis-instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/tedious/vendored/instrumentation.js +2 -3
- package/build/esm/integrations/tracing/tedious/vendored/instrumentation.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/sdk/initOtel.js +2 -1
- package/build/esm/sdk/initOtel.js.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/fs/index.d.ts +2 -14
- package/build/types/integrations/fs/index.d.ts.map +1 -1
- package/build/types/integrations/fs/vendored/instrumentation.d.ts +2 -10
- package/build/types/integrations/fs/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/fs/vendored/types.d.ts +1 -2
- package/build/types/integrations/fs/vendored/types.d.ts.map +1 -1
- package/build/types/integrations/node-fetch/index.d.ts.map +1 -1
- package/build/types/integrations/node-fetch/vendored/internal-types.d.ts.map +1 -1
- package/build/types/integrations/node-fetch/vendored/semconv.d.ts +13 -0
- package/build/types/integrations/node-fetch/vendored/semconv.d.ts.map +1 -0
- package/build/types/integrations/node-fetch/vendored/types.d.ts +2 -4
- package/build/types/integrations/node-fetch/vendored/types.d.ts.map +1 -1
- package/build/types/integrations/node-fetch/vendored/undici.d.ts +6 -7
- package/build/types/integrations/node-fetch/vendored/undici.d.ts.map +1 -1
- package/build/types/integrations/tracing/dataloader/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/kafka/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/kafka/vendored/instrumentation.d.ts +3 -13
- package/build/types/integrations/tracing/kafka/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/kafka/vendored/kafkajs-types.d.ts +0 -32
- package/build/types/integrations/tracing/kafka/vendored/kafkajs-types.d.ts.map +1 -1
- package/build/types/integrations/tracing/kafka/vendored/semconv.d.ts +9 -28
- package/build/types/integrations/tracing/kafka/vendored/semconv.d.ts.map +1 -1
- package/build/types/integrations/tracing/kafka/vendored/utils.d.ts +29 -0
- package/build/types/integrations/tracing/kafka/vendored/utils.d.ts.map +1 -0
- package/build/types/integrations/tracing/knex/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/mongo/vendored/utils.d.ts.map +1 -1
- package/build/types/integrations/tracing/mongoose/vendored/mongoose.d.ts.map +1 -1
- package/build/types/integrations/tracing/mysql2/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/postgres/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/postgres/vendored/utils.d.ts.map +1 -1
- package/build/types/integrations/tracing/redis/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/redis/vendored/redis-instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/tedious/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/sdk/initOtel.d.ts.map +1 -1
- package/build/types-ts3.8/index.d.ts +1 -1
- package/build/types-ts3.8/integrations/fs/index.d.ts +2 -14
- package/build/types-ts3.8/integrations/fs/vendored/instrumentation.d.ts +2 -10
- package/build/types-ts3.8/integrations/fs/vendored/types.d.ts +1 -2
- package/build/types-ts3.8/integrations/node-fetch/vendored/semconv.d.ts +13 -0
- package/build/types-ts3.8/integrations/node-fetch/vendored/types.d.ts +2 -4
- package/build/types-ts3.8/integrations/node-fetch/vendored/undici.d.ts +6 -7
- package/build/types-ts3.8/integrations/tracing/kafka/vendored/instrumentation.d.ts +3 -13
- package/build/types-ts3.8/integrations/tracing/kafka/vendored/kafkajs-types.d.ts +0 -32
- package/build/types-ts3.8/integrations/tracing/kafka/vendored/semconv.d.ts +9 -28
- package/build/types-ts3.8/integrations/tracing/kafka/vendored/utils.d.ts +29 -0
- package/package.json +5 -6
- package/build/cjs/integrations/tracing/kafka/vendored/internal-types.js +0 -6
- package/build/cjs/integrations/tracing/kafka/vendored/internal-types.js.map +0 -1
- package/build/cjs/integrations/tracing/kafka/vendored/propagator.js +0 -22
- package/build/cjs/integrations/tracing/kafka/vendored/propagator.js.map +0 -1
- package/build/esm/integrations/tracing/kafka/vendored/internal-types.js +0 -4
- package/build/esm/integrations/tracing/kafka/vendored/internal-types.js.map +0 -1
- package/build/esm/integrations/tracing/kafka/vendored/propagator.js +0 -20
- package/build/esm/integrations/tracing/kafka/vendored/propagator.js.map +0 -1
- package/build/types/integrations/tracing/kafka/vendored/internal-types.d.ts +0 -9
- package/build/types/integrations/tracing/kafka/vendored/internal-types.d.ts.map +0 -1
- package/build/types/integrations/tracing/kafka/vendored/propagator.d.ts +0 -3
- package/build/types/integrations/tracing/kafka/vendored/propagator.d.ts.map +0 -1
- package/build/types/integrations/tracing/kafka/vendored/types.d.ts +0 -26
- package/build/types/integrations/tracing/kafka/vendored/types.d.ts.map +0 -1
- package/build/types/integrations/tracing/utils/sql-common.d.ts +0 -3
- package/build/types/integrations/tracing/utils/sql-common.d.ts.map +0 -1
- package/build/types-ts3.8/integrations/tracing/kafka/vendored/internal-types.d.ts +0 -9
- package/build/types-ts3.8/integrations/tracing/kafka/vendored/propagator.d.ts +0 -3
- package/build/types-ts3.8/integrations/tracing/kafka/vendored/types.d.ts +0 -26
- package/build/types-ts3.8/integrations/tracing/utils/sql-common.d.ts +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/tedious/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-tedious\n * - Upstream version: @opentelemetry/instrumentation-tedious@0.37.0\n * - Minor TypeScript strictness adjustments\n * - Span creation migrated to the @sentry/core API; origin folded into span creation\n */\n\nimport * as api from '@opentelemetry/api';\nimport { EventEmitter } from 'events';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';\nimport {\n DB_SYSTEM_VALUE_MSSQL,\n ATTR_DB_NAME,\n ATTR_DB_SQL_TABLE,\n ATTR_DB_STATEMENT,\n ATTR_DB_SYSTEM,\n ATTR_DB_USER,\n ATTR_NET_PEER_NAME,\n ATTR_NET_PEER_PORT,\n} from './semconv';\nimport type * as tedious from './tedious-types';\nimport { getSpanName, once } from './utils';\nimport {\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-tedious';\n\nconst CURRENT_DATABASE = Symbol('opentelemetry.instrumentation-tedious.current-database');\n\nconst PATCHED_METHODS = ['callProcedure', 'execSql', 'execSqlBatch', 'execBulkLoad', 'prepare', 'execute'];\n\ntype UnknownFunction = (...args: any[]) => any;\ntype ApproxConnection = EventEmitter & {\n [CURRENT_DATABASE]: string;\n config: any;\n};\ntype ApproxRequest = EventEmitter & {\n sqlTextOrProcedure: string | undefined;\n callback: any;\n table: string | undefined;\n parametersByName: any;\n};\n\nfunction setDatabase(this: ApproxConnection, databaseName: string) {\n Object.defineProperty(this, CURRENT_DATABASE, {\n value: databaseName,\n writable: true,\n });\n}\n\nexport class TediousInstrumentation extends InstrumentationBase<InstrumentationConfig> {\n static readonly COMPONENT = 'tedious';\n\n constructor(config: InstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n protected init() {\n return [\n new InstrumentationNodeModuleDefinition(\n TediousInstrumentation.COMPONENT,\n ['>=1.11.0 <20'],\n (moduleExports: typeof tedious) => {\n const ConnectionPrototype: any = moduleExports.Connection.prototype;\n for (const method of PATCHED_METHODS) {\n if (isWrapped(ConnectionPrototype[method])) {\n this._unwrap(ConnectionPrototype, method);\n }\n this._wrap(ConnectionPrototype, method, this._patchQuery(method) as any);\n }\n\n if (isWrapped(ConnectionPrototype.connect)) {\n this._unwrap(ConnectionPrototype, 'connect');\n }\n // oxlint-disable-next-line typescript/unbound-method\n this._wrap(ConnectionPrototype, 'connect', this._patchConnect);\n\n return moduleExports;\n },\n (moduleExports: typeof tedious) => {\n if (moduleExports === undefined) return;\n const ConnectionPrototype: any = moduleExports.Connection.prototype;\n for (const method of PATCHED_METHODS) {\n this._unwrap(ConnectionPrototype, method);\n }\n this._unwrap(ConnectionPrototype, 'connect');\n },\n ),\n ];\n }\n\n private _patchConnect(original: UnknownFunction): UnknownFunction {\n return function patchedConnect(this: ApproxConnection) {\n setDatabase.call(this, this.config?.options?.database);\n\n // remove the listener first in case it's already added\n this.removeListener('databaseChange', setDatabase);\n this.on('databaseChange', setDatabase);\n\n this.once('end', () => {\n this.removeListener('databaseChange', setDatabase);\n });\n return original.apply(this, arguments as unknown as any[]);\n };\n }\n\n private _patchQuery(operation: string) {\n return (originalMethod: UnknownFunction): UnknownFunction => {\n const thisPlugin = this;\n\n function patchedMethod(this: ApproxConnection, request: ApproxRequest) {\n if (!(request instanceof EventEmitter)) {\n thisPlugin._diag.warn(`Unexpected invocation of patched ${operation} method. Span not recorded`);\n return originalMethod.apply(this, arguments as unknown as any[]);\n }\n let procCount = 0;\n let statementCount = 0;\n const incrementStatementCount = () => statementCount++;\n const incrementProcCount = () => procCount++;\n const databaseName = this[CURRENT_DATABASE];\n const sql = (request => {\n // Required for <11.0.9\n if (request.sqlTextOrProcedure === 'sp_prepare' && request.parametersByName?.stmt?.value) {\n return request.parametersByName.stmt.value;\n }\n return request.sqlTextOrProcedure;\n })(request);\n\n const attributes: api.Attributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.otel.tedious',\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_MSSQL,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_NAME]: databaseName,\n // >=4 uses `authentication` object; older versions just userName and password pair\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_USER]: this.config?.userName ?? this.config?.authentication?.options?.userName,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_STATEMENT]: sql,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_SQL_TABLE]: request.table,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_NET_PEER_NAME]: this.config?.server,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_NET_PEER_PORT]: this.config?.options?.port,\n };\n const span = startInactiveSpan({\n name: getSpanName(operation, databaseName, sql, request.table),\n kind: api.SpanKind.CLIENT,\n attributes,\n });\n\n const endSpan = once((err?: any) => {\n request.removeListener('done', incrementStatementCount);\n request.removeListener('doneInProc', incrementStatementCount);\n request.removeListener('doneProc', incrementProcCount);\n request.removeListener('error', endSpan);\n this.removeListener('end', endSpan);\n\n span.setAttribute('tedious.procedure_count', procCount);\n span.setAttribute('tedious.statement_count', statementCount);\n if (err) {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: err.message,\n });\n // TODO(3290): set `error.type` attribute?\n }\n span.end();\n });\n\n request.on('done', incrementStatementCount);\n request.on('doneInProc', incrementStatementCount);\n request.on('doneProc', incrementProcCount);\n request.once('error', endSpan);\n this.on('end', endSpan);\n\n if (typeof request.callback === 'function') {\n thisPlugin._wrap(request, 'callback', thisPlugin._patchCallbackQuery(endSpan));\n } else {\n thisPlugin._diag.error('Expected request.callback to be a function');\n }\n\n return withActiveSpan(span, () => originalMethod.apply(this, arguments as unknown as any[]));\n }\n\n Object.defineProperty(patchedMethod, 'length', {\n value: originalMethod.length,\n writable: false,\n });\n\n return patchedMethod;\n };\n }\n\n private _patchCallbackQuery(endSpan: Function) {\n return (originalCallback: Function) => {\n return function (this: any, err: Error | undefined | null, _rowCount?: number, _rows?: any) {\n endSpan(err);\n return originalCallback.apply(this, arguments);\n };\n };\n }\n}\n"],"names":["InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleDefinition","isWrapped","EventEmitter","request","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","ATTR_DB_SYSTEM","DB_SYSTEM_VALUE_MSSQL","ATTR_DB_NAME","ATTR_DB_USER","ATTR_DB_ST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,EAAY;AAC1C,UAAA,UAAA,CAAW,MAAM,OAAA,EAAS,UAAA,EAAY,UAAA,CAAW,mBAAA,CAAoB,OAAO,CAAC,CAAA;AAAA,QAC/E,CAAA,MAAO;AACL,UAAA,UAAA,CAAW,KAAA,CAAM,MAAM,4CAA4C,CAAA;AAAA,QACrE;AAEA,QAAA,OAAOC,oBAAe,IAAA,EAAM,MAAM,eAAe,KAAA,CAAM,IAAA,EAAM,SAA6B,CAAC,CAAA;AAAA,MAC7F;AAEA,MAAA,MAAA,CAAO,cAAA,CAAe,eAAe,QAAA,EAAU;AAAA,QAC7C,OAAO,cAAA,CAAe,MAAA;AAAA,QACtB,QAAA,EAAU;AAAA,OACX,CAAA;AAED,MAAA,OAAO,aAAA;AAAA,IACT,CAAA;AAAA,EACF;AAAA,EAEQ,oBAAoB,OAAA,EAAmB;AAC7C,IAAA,OAAO,CAAC,gBAAA,KAA+B;AACrC,MAAA,OAAO,SAAqB,GAAA,EAA+B,SAAA,EAAoB,KAAA,EAAa;AAC1F,QAAA,OAAA,CAAQ,GAAG,CAAA;AACX,QAAA,OAAO,gBAAA,CAAiB,KAAA,CAAM,IAAA,EAAM,SAAS,CAAA;AAAA,MAC/C,CAAA;AAAA,IACF,CAAA;AAAA,EACF;AACF,CAAA;AAzJa,uBAAA,CACK,SAAA,GAAY,SAAA;AADvB,IAAM,sBAAA,GAAN;;;;"}
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/tedious/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-tedious\n * - Upstream version: @opentelemetry/instrumentation-tedious@0.37.0\n * - Minor TypeScript strictness adjustments\n * - Span creation migrated to the @sentry/core API; origin folded into span creation\n */\n\nimport { EventEmitter } from 'events';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';\nimport {\n DB_SYSTEM_VALUE_MSSQL,\n ATTR_DB_NAME,\n ATTR_DB_SQL_TABLE,\n ATTR_DB_STATEMENT,\n ATTR_DB_SYSTEM,\n ATTR_DB_USER,\n ATTR_NET_PEER_NAME,\n ATTR_NET_PEER_PORT,\n} from './semconv';\nimport type * as tedious from './tedious-types';\nimport { getSpanName, once } from './utils';\nimport type { SpanAttributes } from '@sentry/core';\nimport {\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-tedious';\n\nconst CURRENT_DATABASE = Symbol('opentelemetry.instrumentation-tedious.current-database');\n\nconst PATCHED_METHODS = ['callProcedure', 'execSql', 'execSqlBatch', 'execBulkLoad', 'prepare', 'execute'];\n\ntype UnknownFunction = (...args: any[]) => any;\ntype ApproxConnection = EventEmitter & {\n [CURRENT_DATABASE]: string;\n config: any;\n};\ntype ApproxRequest = EventEmitter & {\n sqlTextOrProcedure: string | undefined;\n callback: any;\n table: string | undefined;\n parametersByName: any;\n};\n\nfunction setDatabase(this: ApproxConnection, databaseName: string) {\n Object.defineProperty(this, CURRENT_DATABASE, {\n value: databaseName,\n writable: true,\n });\n}\n\nexport class TediousInstrumentation extends InstrumentationBase<InstrumentationConfig> {\n static readonly COMPONENT = 'tedious';\n\n constructor(config: InstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n protected init() {\n return [\n new InstrumentationNodeModuleDefinition(\n TediousInstrumentation.COMPONENT,\n ['>=1.11.0 <20'],\n (moduleExports: typeof tedious) => {\n const ConnectionPrototype: any = moduleExports.Connection.prototype;\n for (const method of PATCHED_METHODS) {\n if (isWrapped(ConnectionPrototype[method])) {\n this._unwrap(ConnectionPrototype, method);\n }\n this._wrap(ConnectionPrototype, method, this._patchQuery(method) as any);\n }\n\n if (isWrapped(ConnectionPrototype.connect)) {\n this._unwrap(ConnectionPrototype, 'connect');\n }\n // oxlint-disable-next-line typescript/unbound-method\n this._wrap(ConnectionPrototype, 'connect', this._patchConnect);\n\n return moduleExports;\n },\n (moduleExports: typeof tedious) => {\n if (moduleExports === undefined) return;\n const ConnectionPrototype: any = moduleExports.Connection.prototype;\n for (const method of PATCHED_METHODS) {\n this._unwrap(ConnectionPrototype, method);\n }\n this._unwrap(ConnectionPrototype, 'connect');\n },\n ),\n ];\n }\n\n private _patchConnect(original: UnknownFunction): UnknownFunction {\n return function patchedConnect(this: ApproxConnection) {\n setDatabase.call(this, this.config?.options?.database);\n\n // remove the listener first in case it's already added\n this.removeListener('databaseChange', setDatabase);\n this.on('databaseChange', setDatabase);\n\n this.once('end', () => {\n this.removeListener('databaseChange', setDatabase);\n });\n return original.apply(this, arguments as unknown as any[]);\n };\n }\n\n private _patchQuery(operation: string) {\n return (originalMethod: UnknownFunction): UnknownFunction => {\n const thisPlugin = this;\n\n function patchedMethod(this: ApproxConnection, request: ApproxRequest) {\n if (!(request instanceof EventEmitter)) {\n thisPlugin._diag.warn(`Unexpected invocation of patched ${operation} method. Span not recorded`);\n return originalMethod.apply(this, arguments as unknown as any[]);\n }\n let procCount = 0;\n let statementCount = 0;\n const incrementStatementCount = () => statementCount++;\n const incrementProcCount = () => procCount++;\n const databaseName = this[CURRENT_DATABASE];\n const sql = (request => {\n // Required for <11.0.9\n if (request.sqlTextOrProcedure === 'sp_prepare' && request.parametersByName?.stmt?.value) {\n return request.parametersByName.stmt.value;\n }\n return request.sqlTextOrProcedure;\n })(request);\n\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.otel.tedious',\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_MSSQL,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_NAME]: databaseName,\n // >=4 uses `authentication` object; older versions just userName and password pair\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_USER]: this.config?.userName ?? this.config?.authentication?.options?.userName,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_STATEMENT]: sql,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_SQL_TABLE]: request.table,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_NET_PEER_NAME]: this.config?.server,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_NET_PEER_PORT]: this.config?.options?.port,\n };\n const span = startInactiveSpan({\n name: getSpanName(operation, databaseName, sql, request.table),\n kind: SPAN_KIND.CLIENT,\n attributes,\n });\n\n const endSpan = once((err?: any) => {\n request.removeListener('done', incrementStatementCount);\n request.removeListener('doneInProc', incrementStatementCount);\n request.removeListener('doneProc', incrementProcCount);\n request.removeListener('error', endSpan);\n this.removeListener('end', endSpan);\n\n span.setAttribute('tedious.procedure_count', procCount);\n span.setAttribute('tedious.statement_count', statementCount);\n if (err) {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: err.message,\n });\n // TODO(3290): set `error.type` attribute?\n }\n span.end();\n });\n\n request.on('done', incrementStatementCount);\n request.on('doneInProc', incrementStatementCount);\n request.on('doneProc', incrementProcCount);\n request.once('error', endSpan);\n this.on('end', endSpan);\n\n if (typeof request.callback === 'function') {\n thisPlugin._wrap(request, 'callback', thisPlugin._patchCallbackQuery(endSpan));\n } else {\n thisPlugin._diag.error('Expected request.callback to be a function');\n }\n\n return withActiveSpan(span, () => originalMethod.apply(this, arguments as unknown as any[]));\n }\n\n Object.defineProperty(patchedMethod, 'length', {\n value: originalMethod.length,\n writable: false,\n });\n\n return patchedMethod;\n };\n }\n\n private _patchCallbackQuery(endSpan: Function) {\n return (originalCallback: Function) => {\n return function (this: any, err: Error | undefined | null, _rowCount?: number, _rows?: any) {\n endSpan(err);\n return originalCallback.apply(this, arguments);\n };\n };\n }\n}\n"],"names":["InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleDefinition","isWrapped","EventEmitter","request","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","ATTR_DB_SYSTEM","DB_SYSTEM_VALUE_MSSQL","ATTR_DB_NAME","ATTR_DB_USER","ATTR_DB_STATEMENT","ATTR_DB_SQL_TABLE","ATTR_NET_PEER_NAME","ATTR_NET_PEER_PORT","startInactiveSpan","getSpanName","SPAN_KIND","once","SPAN_STATUS_ERROR","withActiveSpan"],"mappings":";;;;;;;;AAoCA,MAAM,YAAA,GAAe,iCAAA;AAErB,MAAM,gBAAA,0BAA0B,wDAAwD,CAAA;AAExF,MAAM,kBAAkB,CAAC,eAAA,EAAiB,WAAW,cAAA,EAAgB,cAAA,EAAgB,WAAW,SAAS,CAAA;AAczG,SAAS,YAAoC,YAAA,EAAsB;AACjE,EAAA,MAAA,CAAO,cAAA,CAAe,MAAM,gBAAA,EAAkB;AAAA,IAC5C,KAAA,EAAO,YAAA;AAAA,IACP,QAAA,EAAU;AAAA,GACX,CAAA;AACH;AAEO,MAAM,uBAAA,GAAN,MAAM,uBAAA,SAA+BA,mCAAA,CAA2C;AAAA,EAGrF,WAAA,CAAY,MAAA,GAAgC,EAAC,EAAG;AAC9C,IAAA,KAAA,CAAM,YAAA,EAAcC,kBAAa,MAAM,CAAA;AAAA,EACzC;AAAA,EAEU,IAAA,GAAO;AACf,IAAA,OAAO;AAAA,MACL,IAAIC,mDAAA;AAAA,QACF,uBAAA,CAAuB,SAAA;AAAA,QACvB,CAAC,cAAc,CAAA;AAAA,QACf,CAAC,aAAA,KAAkC;AACjC,UAAA,MAAM,mBAAA,GAA2B,cAAc,UAAA,CAAW,SAAA;AAC1D,UAAA,KAAA,MAAW,UAAU,eAAA,EAAiB;AACpC,YAAA,IAAIC,yBAAA,CAAU,mBAAA,CAAoB,MAAM,CAAC,CAAA,EAAG;AAC1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ySpanProcessor({
|
|
50
|
-
timeout: _clampSpanProcessorTimeout(client.getOptions().maxSpanWaitDuration)
|
|
50
|
+
timeout: _clampSpanProcessorTimeout(client.getOptions().maxSpanWaitDuration),
|
|
51
|
+
client
|
|
51
52
|
}),
|
|
52
53
|
...options.spanProcessors || []
|
|
53
54
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initOtel.js","sources":["../../../src/sdk/initOtel.ts"],"sourcesContent":["import { context, propagation, trace } from '@opentelemetry/api';\nimport type { SpanProcessor } from '@opentelemetry/sdk-trace-base';\nimport { BasicTracerProvider } from '@opentelemetry/sdk-trace-base';\nimport { debug as coreDebug } from '@sentry/core';\nimport {\n initializeEsmLoader,\n type NodeClient,\n SentryContextManager,\n setupOpenTelemetryLogger,\n} from '@sentry/node-core';\nimport {\n type AsyncLocalStorageLookup,\n getSentryResource,\n SentryPropagator,\n SentrySampler,\n SentrySpanProcessor,\n} from '@sentry/opentelemetry';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { getOpenTelemetryInstrumentationToPreload } from '../integrations/tracing';\n\n// About 277h - this must fit into new Array(len)!\nconst MAX_MAX_SPAN_WAIT_DURATION = 1_000_000;\n\ninterface AdditionalOpenTelemetryOptions {\n /** Additional SpanProcessor instances that should be used. */\n spanProcessors?: SpanProcessor[];\n}\n\n/**\n * Initialize OpenTelemetry for Node.\n */\nexport function initOpenTelemetry(client: NodeClient, options: AdditionalOpenTelemetryOptions = {}): void {\n if (client.getOptions().debug) {\n setupOpenTelemetryLogger();\n }\n\n const [provider, asyncLocalStorageLookup] = setupOtel(client, options);\n client.traceProvider = provider;\n client.asyncLocalStorageLookup = asyncLocalStorageLookup;\n}\n\ninterface NodePreloadOptions {\n debug?: boolean;\n integrations?: string[];\n}\n\n/**\n * Preload OpenTelemetry for Node.\n * This can be used to preload instrumentation early, but set up Sentry later.\n * By preloading the OTEL instrumentation wrapping still happens early enough that everything works.\n */\nexport function preloadOpenTelemetry(options: NodePreloadOptions = {}): void {\n const { debug } = options;\n\n if (debug) {\n coreDebug.enable();\n }\n\n initializeEsmLoader();\n\n // These are all integrations that we need to pre-load to ensure they are set up before any other code runs\n getPreloadMethods(options.integrations).forEach(fn => {\n fn();\n\n if (debug) {\n coreDebug.log(`[Sentry] Preloaded ${fn.id} instrumentation`);\n }\n });\n}\n\nfunction getPreloadMethods(integrationNames?: string[]): ((() => void) & { id: string })[] {\n const instruments = getOpenTelemetryInstrumentationToPreload();\n\n if (!integrationNames) {\n return instruments;\n }\n\n // We match exact matches of instrumentation, but also match prefixes, e.g. \"Fastify.v5\" will match \"Fastify\"\n return instruments.filter(instrumentation => {\n const id = instrumentation.id;\n return integrationNames.some(integrationName => id === integrationName || id.startsWith(`${integrationName}.`));\n });\n}\n\n/** Just exported for tests. */\nexport function setupOtel(\n client: NodeClient,\n options: AdditionalOpenTelemetryOptions = {},\n): [BasicTracerProvider, AsyncLocalStorageLookup] {\n // Create and configure NodeTracerProvider\n const provider = new BasicTracerProvider({\n sampler: new SentrySampler(client),\n resource: getSentryResource('node'),\n forceFlushTimeoutMillis: 500,\n spanProcessors: [\n new SentrySpanProcessor({\n timeout: _clampSpanProcessorTimeout(client.getOptions().maxSpanWaitDuration),\n }),\n ...(options.spanProcessors || []),\n ],\n });\n\n // Register as globals\n trace.setGlobalTracerProvider(provider);\n propagation.setGlobalPropagator(new SentryPropagator());\n\n const ctxManager = new SentryContextManager();\n context.setGlobalContextManager(ctxManager);\n\n return [provider, ctxManager.getAsyncLocalStorageLookup()];\n}\n\n/** Just exported for tests. */\nexport function _clampSpanProcessorTimeout(maxSpanWaitDuration: number | undefined): number | undefined {\n if (maxSpanWaitDuration == null) {\n return undefined;\n }\n\n // We guard for a max. value here, because we create an array with this length\n // So if this value is too large, this would fail\n if (maxSpanWaitDuration > MAX_MAX_SPAN_WAIT_DURATION) {\n DEBUG_BUILD &&\n coreDebug.warn(`\\`maxSpanWaitDuration\\` is too high, using the maximum value of ${MAX_MAX_SPAN_WAIT_DURATION}`);\n return MAX_MAX_SPAN_WAIT_DURATION;\n } else if (maxSpanWaitDuration <= 0 || Number.isNaN(maxSpanWaitDuration)) {\n DEBUG_BUILD && coreDebug.warn('`maxSpanWaitDuration` must be a positive number, using default value instead.');\n return undefined;\n }\n\n return maxSpanWaitDuration;\n}\n"],"names":["setupOpenTelemetryLogger","coreDebug","initializeEsmLoader","getOpenTelemetryInstrumentationToPreload","BasicTracerProvider","SentrySampler","getSentryResource","SentrySpanProcessor","trace","propagation","SentryPropagator","SentryContextManager","context","DEBUG_BUILD"],"mappings":";;;;;;;;;;AAqBA,MAAM,0BAAA,GAA6B,GAAA;AAU5B,SAAS,iBAAA,CAAkB,MAAA,EAAoB,OAAA,GAA0C,EAAC,EAAS;AACxG,EAAA,IAAI,MAAA,CAAO,UAAA,EAAW,CAAE,KAAA,EAAO;AAC7B,IAAAA,iCAAA,EAAyB;AAAA,EAC3B;AAEA,EAAA,MAAM,CAAC,QAAA,EAAU,uBAAuB,CAAA,GAAI,SAAA,CAAU,QAAQ,OAAO,CAAA;AACrE,EAAA,MAAA,CAAO,aAAA,GAAgB,QAAA;AACvB,EAAA,MAAA,CAAO,uBAAA,GAA0B,uBAAA;AACnC;AAYO,SAAS,oBAAA,CAAqB,OAAA,GAA8B,EAAC,EAAS;AAC3E,EAAA,MAAM,EAAE,OAAM,GAAI,OAAA;AAElB,EAAA,IAAI,KAAA,EAAO;AACT,IAAAC,UAAA,CAAU,MAAA,EAAO;AAAA,EACnB;AAEA,EAAAC,4BAAA,EAAoB;AAGpB,EAAA,iBAAA,CAAkB,OAAA,CAAQ,YAAY,CAAA,CAAE,OAAA,CAAQ,CAAA,EAAA,KAAM;AACpD,IAAA,EAAA,EAAG;AAEH,IAAA,IAAI,KAAA,EAAO;AACT,MAAAD,UAAA,CAAU,GAAA,CAAI,CAAA,mBAAA,EAAsB,EAAA,CAAG,EAAE,CAAA,gBAAA,CAAkB,CAAA;AAAA,IAC7D;AAAA,EACF,CAAC,CAAA;AACH;AAEA,SAAS,kBAAkB,gBAAA,EAAgE;AACzF,EAAA,MAAM,cAAcE,8CAAA,EAAyC;AAE7D,EAAA,IAAI,CAAC,gBAAA,EAAkB;AACrB,IAAA,OAAO,WAAA;AAAA,EACT;AAGA,EAAA,OAAO,WAAA,CAAY,OAAO,CAAA,eAAA,KAAmB;AAC3C,IAAA,MAAM,KAAK,eAAA,CAAgB,EAAA;AAC3B,IAAA,OAAO,gBAAA,CAAiB,IAAA,CAAK,CAAA,eAAA,KAAmB,EAAA,KAAO,eAAA,IAAmB,GAAG,UAAA,CAAW,CAAA,EAAG,eAAe,CAAA,CAAA,CAAG,CAAC,CAAA;AAAA,EAChH,CAAC,CAAA;AACH;AAGO,SAAS,SAAA,CACd,MAAA,EACA,OAAA,GAA0C,EAAC,EACK;AAEhD,EAAA,MAAM,QAAA,GAAW,IAAIC,gCAAA,CAAoB;AAAA,IACvC,OAAA,EAAS,IAAIC,2BAAA,CAAc,MAAM,CAAA;AAAA,IACjC,QAAA,EAAUC,gCAAkB,MAAM,CAAA;AAAA,IAClC,uBAAA,EAAyB,GAAA;AAAA,IACzB,cAAA,EAAgB;AAAA,MACd,IAAIC,iCAAA,CAAoB;AAAA,QACtB,OAAA,EAAS,0BAAA,CAA2B,MAAA,CAAO,UAAA,GAAa,mBAAmB;AAAA,
|
|
1
|
+
{"version":3,"file":"initOtel.js","sources":["../../../src/sdk/initOtel.ts"],"sourcesContent":["import { context, propagation, trace } from '@opentelemetry/api';\nimport type { SpanProcessor } from '@opentelemetry/sdk-trace-base';\nimport { BasicTracerProvider } from '@opentelemetry/sdk-trace-base';\nimport { debug as coreDebug } from '@sentry/core';\nimport {\n initializeEsmLoader,\n type NodeClient,\n SentryContextManager,\n setupOpenTelemetryLogger,\n} from '@sentry/node-core';\nimport {\n type AsyncLocalStorageLookup,\n getSentryResource,\n SentryPropagator,\n SentrySampler,\n SentrySpanProcessor,\n} from '@sentry/opentelemetry';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { getOpenTelemetryInstrumentationToPreload } from '../integrations/tracing';\n\n// About 277h - this must fit into new Array(len)!\nconst MAX_MAX_SPAN_WAIT_DURATION = 1_000_000;\n\ninterface AdditionalOpenTelemetryOptions {\n /** Additional SpanProcessor instances that should be used. */\n spanProcessors?: SpanProcessor[];\n}\n\n/**\n * Initialize OpenTelemetry for Node.\n */\nexport function initOpenTelemetry(client: NodeClient, options: AdditionalOpenTelemetryOptions = {}): void {\n if (client.getOptions().debug) {\n setupOpenTelemetryLogger();\n }\n\n const [provider, asyncLocalStorageLookup] = setupOtel(client, options);\n client.traceProvider = provider;\n client.asyncLocalStorageLookup = asyncLocalStorageLookup;\n}\n\ninterface NodePreloadOptions {\n debug?: boolean;\n integrations?: string[];\n}\n\n/**\n * Preload OpenTelemetry for Node.\n * This can be used to preload instrumentation early, but set up Sentry later.\n * By preloading the OTEL instrumentation wrapping still happens early enough that everything works.\n */\nexport function preloadOpenTelemetry(options: NodePreloadOptions = {}): void {\n const { debug } = options;\n\n if (debug) {\n coreDebug.enable();\n }\n\n initializeEsmLoader();\n\n // These are all integrations that we need to pre-load to ensure they are set up before any other code runs\n getPreloadMethods(options.integrations).forEach(fn => {\n fn();\n\n if (debug) {\n coreDebug.log(`[Sentry] Preloaded ${fn.id} instrumentation`);\n }\n });\n}\n\nfunction getPreloadMethods(integrationNames?: string[]): ((() => void) & { id: string })[] {\n const instruments = getOpenTelemetryInstrumentationToPreload();\n\n if (!integrationNames) {\n return instruments;\n }\n\n // We match exact matches of instrumentation, but also match prefixes, e.g. \"Fastify.v5\" will match \"Fastify\"\n return instruments.filter(instrumentation => {\n const id = instrumentation.id;\n return integrationNames.some(integrationName => id === integrationName || id.startsWith(`${integrationName}.`));\n });\n}\n\n/** Just exported for tests. */\nexport function setupOtel(\n client: NodeClient,\n options: AdditionalOpenTelemetryOptions = {},\n): [BasicTracerProvider, AsyncLocalStorageLookup] {\n // Create and configure NodeTracerProvider\n const provider = new BasicTracerProvider({\n sampler: new SentrySampler(client),\n resource: getSentryResource('node'),\n forceFlushTimeoutMillis: 500,\n spanProcessors: [\n new SentrySpanProcessor({\n timeout: _clampSpanProcessorTimeout(client.getOptions().maxSpanWaitDuration),\n client,\n }),\n ...(options.spanProcessors || []),\n ],\n });\n\n // Register as globals\n trace.setGlobalTracerProvider(provider);\n propagation.setGlobalPropagator(new SentryPropagator());\n\n const ctxManager = new SentryContextManager();\n context.setGlobalContextManager(ctxManager);\n\n return [provider, ctxManager.getAsyncLocalStorageLookup()];\n}\n\n/** Just exported for tests. */\nexport function _clampSpanProcessorTimeout(maxSpanWaitDuration: number | undefined): number | undefined {\n if (maxSpanWaitDuration == null) {\n return undefined;\n }\n\n // We guard for a max. value here, because we create an array with this length\n // So if this value is too large, this would fail\n if (maxSpanWaitDuration > MAX_MAX_SPAN_WAIT_DURATION) {\n DEBUG_BUILD &&\n coreDebug.warn(`\\`maxSpanWaitDuration\\` is too high, using the maximum value of ${MAX_MAX_SPAN_WAIT_DURATION}`);\n return MAX_MAX_SPAN_WAIT_DURATION;\n } else if (maxSpanWaitDuration <= 0 || Number.isNaN(maxSpanWaitDuration)) {\n DEBUG_BUILD && coreDebug.warn('`maxSpanWaitDuration` must be a positive number, using default value instead.');\n return undefined;\n }\n\n return maxSpanWaitDuration;\n}\n"],"names":["setupOpenTelemetryLogger","coreDebug","initializeEsmLoader","getOpenTelemetryInstrumentationToPreload","BasicTracerProvider","SentrySampler","getSentryResource","SentrySpanProcessor","trace","propagation","SentryPropagator","SentryContextManager","context","DEBUG_BUILD"],"mappings":";;;;;;;;;;AAqBA,MAAM,0BAAA,GAA6B,GAAA;AAU5B,SAAS,iBAAA,CAAkB,MAAA,EAAoB,OAAA,GAA0C,EAAC,EAAS;AACxG,EAAA,IAAI,MAAA,CAAO,UAAA,EAAW,CAAE,KAAA,EAAO;AAC7B,IAAAA,iCAAA,EAAyB;AAAA,EAC3B;AAEA,EAAA,MAAM,CAAC,QAAA,EAAU,uBAAuB,CAAA,GAAI,SA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AAUC,gCAAkB,MAAM,CAAA;AAAA,IAClC,uBAAA,EAAyB,GAAA;AAAA,IACzB,cAAA,EAAgB;AAAA,MACd,IAAIC,iCAAA,CAAoB;AAAA,QACtB,OAAA,EAAS,0BAAA,CAA2B,MAAA,CAAO,UAAA,GAAa,mBAAmB,CAAA;AAAA,QAC3E;AAAA,OACD,CAAA;AAAA,MACD,GAAI,OAAA,CAAQ,cAAA,IAAkB;AAAC;AACjC,GACD,CAAA;AAGD,EAAAC,SAAA,CAAM,wBAAwB,QAAQ,CAAA;AACtC,EAAAC,eAAA,CAAY,mBAAA,CAAoB,IAAIC,8BAAA,EAAkB,CAAA;AAEtD,EAAA,MAAM,UAAA,GAAa,IAAIC,6BAAA,EAAqB;AAC5C,EAAAC,WAAA,CAAQ,wBAAwB,UAAU,CAAA;AAE1C,EAAA,OAAO,CAAC,QAAA,EAAU,UAAA,CAAW,0BAAA,EAA4B,CAAA;AAC3D;AAGO,SAAS,2BAA2B,mBAAA,EAA6D;AACtG,EAAA,IAAI,uBAAuB,IAAA,EAAM;AAC/B,IAAA,OAAO,MAAA;AAAA,EACT;AAIA,EAAA,IAAI,sBAAsB,0BAAA,EAA4B;AACpD,IAAAC,sBAAA,IACEZ,UAAA,CAAU,IAAA,CAAK,CAAA,gEAAA,EAAmE,0BAA0B,CAAA,CAAE,CAAA;AAChH,IAAA,OAAO,0BAAA;AAAA,EACT,WAAW,mBAAA,IAAuB,CAAA,IAAK,MAAA,CAAO,KAAA,CAAM,mBAAmB,CAAA,EAAG;AACxE,IAAAY,sBAAA,IAAeZ,UAAA,CAAU,KAAK,+EAA+E,CAAA;AAC7G,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,OAAO,mBAAA;AACT;;;;;;;"}
|
package/build/esm/index.js
CHANGED
|
@@ -40,6 +40,6 @@ export { experimentalUseDiagnosticsChannelInjection } from './sdk/experimentalUs
|
|
|
40
40
|
export { initOpenTelemetry, preloadOpenTelemetry } from './sdk/initOtel.js';
|
|
41
41
|
export { getAutoPerformanceIntegrations } from './integrations/tracing/index.js';
|
|
42
42
|
export { setOpenTelemetryContextAsyncContextStrategy as setNodeAsyncContextStrategy } from '@sentry/opentelemetry';
|
|
43
|
-
export { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, captureCheckIn, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, consoleLoggingIntegration, continueTrace, createConsolaReporter, createLangChainCallbackHandler, createTransport, dedupeIntegration, endSession, eventFiltersIntegration, expressErrorHandler, extraErrorDataIntegration, featureFlagsIntegration, flush, functionToStringIntegration, getActiveSpan, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, httpHeadersToSpanAttributes, inboundFiltersIntegration, instrumentAnthropicAiClient, instrumentGoogleGenAIClient, instrumentLangChainEmbeddings, instrumentLangGraph, instrumentOpenAiClient, instrumentStateGraphCompile, instrumentSupabaseClient, isEnabled, isInitialized, lastEventId, linkedErrorsIntegration, parameterize, profiler, requestDataIntegration, rewriteFramesIntegration, setContext, setConversationId, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, spanStreamingIntegration, spanToBaggageHeader, spanToJSON, spanToTraceHeader, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, supabaseIntegration, suppressTracing, trpcMiddleware, updateSpanName, winterCGHeadersToDict, withActiveSpan, withIsolationScope, withMonitor, withScope, wrapMcpServerWithSentry, zodErrorsIntegration } from '@sentry/core';
|
|
43
|
+
export { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, bindScopeToEmitter, captureCheckIn, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, consoleLoggingIntegration, continueTrace, createConsolaReporter, createLangChainCallbackHandler, createTransport, dedupeIntegration, endSession, eventFiltersIntegration, expressErrorHandler, extraErrorDataIntegration, featureFlagsIntegration, flush, functionToStringIntegration, getActiveSpan, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, httpHeadersToSpanAttributes, inboundFiltersIntegration, instrumentAnthropicAiClient, instrumentGoogleGenAIClient, instrumentLangChainEmbeddings, instrumentLangGraph, instrumentOpenAiClient, instrumentStateGraphCompile, instrumentSupabaseClient, isEnabled, isInitialized, lastEventId, linkedErrorsIntegration, parameterize, profiler, requestDataIntegration, rewriteFramesIntegration, setAttribute, setAttributes, setContext, setConversationId, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, spanStreamingIntegration, spanToBaggageHeader, spanToJSON, spanToTraceHeader, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, supabaseIntegration, suppressTracing, trpcMiddleware, updateSpanName, winterCGHeadersToDict, withActiveSpan, withIsolationScope, withMonitor, withScope, wrapMcpServerWithSentry, zodErrorsIntegration } from '@sentry/core';
|
|
44
44
|
export { NODE_VERSION, NodeClient, SentryContextManager, _INTERNAL_normalizeCollectionInterval, anrIntegration, childProcessIntegration, consoleIntegration, contextLinesIntegration, createGetModuleFromFilename, createSentryWinstonTransport, cron, defaultStackParser, disableAnrDetectionForCallback, generateInstrumentOnce, getSentryRelease, httpServerIntegration, httpServerSpansIntegration, localVariablesIntegration, logger, makeNodeTransport, metrics, modulesIntegration, nodeContextIntegration, nodeRuntimeMetricsIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, pinoIntegration, processSessionIntegration, spotlightIntegration, systemErrorIntegration, validateOpenTelemetrySetup, withStreamedSpan } from '@sentry/node-core';
|
|
45
45
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import { defineIntegration } from '@sentry/core';
|
|
2
|
-
import {
|
|
3
|
-
import { FsInstrumentation } from './vendored/instrumentation.js';
|
|
2
|
+
import { enableFsInstrumentation } from './vendored/instrumentation.js';
|
|
4
3
|
|
|
5
4
|
const INTEGRATION_NAME = "FileSystem";
|
|
6
|
-
const fsIntegration = defineIntegration(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
recordFilePaths: options.recordFilePaths,
|
|
15
|
-
recordErrorMessagesAsSpanAttributes: options.recordErrorMessagesAsSpanAttributes
|
|
16
|
-
})
|
|
17
|
-
)();
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
);
|
|
5
|
+
const fsIntegration = defineIntegration((options = {}) => {
|
|
6
|
+
return {
|
|
7
|
+
name: INTEGRATION_NAME,
|
|
8
|
+
setupOnce() {
|
|
9
|
+
enableFsInstrumentation(options);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
});
|
|
22
13
|
|
|
23
14
|
export { fsIntegration };
|
|
24
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/integrations/fs/index.ts"],"sourcesContent":["import { defineIntegration } from '@sentry/core';\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/integrations/fs/index.ts"],"sourcesContent":["import { defineIntegration } from '@sentry/core';\nimport { enableFsInstrumentation } from './vendored/instrumentation';\nimport type { FsInstrumentationConfig } from './vendored/types';\n\nconst INTEGRATION_NAME = 'FileSystem';\n\n/**\n * This integration will create spans for `fs` API operations, like reading and writing files.\n *\n * **WARNING:** This integration may add significant overhead to your application. Especially in scenarios with a lot of\n * file I/O, like for example when running a framework dev server, including this integration can massively slow down\n * your application.\n *\n * @param options Configuration for this integration.\n */\nexport const fsIntegration = defineIntegration((options: FsInstrumentationConfig = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n enableFsInstrumentation(options);\n },\n };\n});\n"],"names":[],"mappings":";;;AAIA,MAAM,gBAAA,GAAmB,YAAA;AAWlB,MAAM,aAAA,GAAgB,iBAAA,CAAkB,CAAC,OAAA,GAAmC,EAAC,KAAM;AACxF,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,uBAAA,CAAwB,OAAO,CAAA;AAAA,IACjC;AAAA,GACF;AACF,CAAC;;;;"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { SDK_VERSION, startInactiveSpan, suppressTracing, SPAN_STATUS_ERROR, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP, startSpan } from '@sentry/core';
|
|
1
|
+
import { startInactiveSpan, getActiveSpan, withActiveSpan, suppressTracing, SPAN_STATUS_ERROR, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP, startSpan } from '@sentry/core';
|
|
2
|
+
import * as fs from 'fs';
|
|
4
3
|
import { promisify } from 'util';
|
|
5
4
|
import { SYNC_FUNCTIONS, CALLBACK_FUNCTIONS, PROMISE_FUNCTIONS } from './constants.js';
|
|
6
5
|
import { indexFs } from './utils.js';
|
|
7
6
|
|
|
8
|
-
const PACKAGE_NAME = "@sentry/instrumentation-fs";
|
|
9
7
|
const SPAN_ORIGIN = "auto.file.fs";
|
|
10
8
|
const SPAN_OP = "file";
|
|
11
9
|
const FS_OPERATIONS_WITH_OLD_PATH_NEW_PATH = ["rename", "renameSync"];
|
|
@@ -93,179 +91,130 @@ function getSpanAttributes(functionName, args, config) {
|
|
|
93
91
|
function patchedFunctionWithOriginalProperties(patchedFunction, original) {
|
|
94
92
|
return Object.assign(patchedFunction, original);
|
|
95
93
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
const _patched = /* @__PURE__ */ new WeakMap();
|
|
95
|
+
function _patchMethod(obj, name, wrapper) {
|
|
96
|
+
const original = obj[name];
|
|
97
|
+
if (typeof original !== "function") return;
|
|
98
|
+
let patched = _patched.get(obj);
|
|
99
|
+
if (!patched) {
|
|
100
|
+
patched = /* @__PURE__ */ new Set();
|
|
101
|
+
_patched.set(obj, patched);
|
|
99
102
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (isWrapped(objectToPatch[functionNameToPatch])) {
|
|
109
|
-
this._unwrap(objectToPatch, functionNameToPatch);
|
|
110
|
-
}
|
|
111
|
-
this._wrap(objectToPatch, functionNameToPatch, this._patchSyncFunction.bind(this, fName));
|
|
112
|
-
}
|
|
113
|
-
for (const fName of CALLBACK_FUNCTIONS) {
|
|
114
|
-
const { objectToPatch, functionNameToPatch } = indexFs(fs, fName);
|
|
115
|
-
if (isWrapped(objectToPatch[functionNameToPatch])) {
|
|
116
|
-
this._unwrap(objectToPatch, functionNameToPatch);
|
|
117
|
-
}
|
|
118
|
-
if (fName === "exists") {
|
|
119
|
-
this._wrap(objectToPatch, functionNameToPatch, this._patchExistsCallbackFunction.bind(this, fName));
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
this._wrap(objectToPatch, functionNameToPatch, this._patchCallbackFunction.bind(this, fName));
|
|
123
|
-
}
|
|
124
|
-
for (const fName of PROMISE_FUNCTIONS) {
|
|
125
|
-
if (isWrapped(fs.promises[fName])) {
|
|
126
|
-
this._unwrap(fs.promises, fName);
|
|
127
|
-
}
|
|
128
|
-
this._wrap(fs.promises, fName, this._patchPromiseFunction.bind(this, fName));
|
|
129
|
-
}
|
|
130
|
-
return fs;
|
|
131
|
-
},
|
|
132
|
-
(fs) => {
|
|
133
|
-
if (fs === void 0) return;
|
|
134
|
-
for (const fName of SYNC_FUNCTIONS) {
|
|
135
|
-
const { objectToPatch, functionNameToPatch } = indexFs(fs, fName);
|
|
136
|
-
if (isWrapped(objectToPatch[functionNameToPatch])) {
|
|
137
|
-
this._unwrap(objectToPatch, functionNameToPatch);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
for (const fName of CALLBACK_FUNCTIONS) {
|
|
141
|
-
const { objectToPatch, functionNameToPatch } = indexFs(fs, fName);
|
|
142
|
-
if (isWrapped(objectToPatch[functionNameToPatch])) {
|
|
143
|
-
this._unwrap(objectToPatch, functionNameToPatch);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
for (const fName of PROMISE_FUNCTIONS) {
|
|
147
|
-
if (isWrapped(fs.promises[fName])) {
|
|
148
|
-
this._unwrap(fs.promises, fName);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
),
|
|
153
|
-
new InstrumentationNodeModuleDefinition(
|
|
154
|
-
"fs/promises",
|
|
155
|
-
["*"],
|
|
156
|
-
(fsPromises) => {
|
|
157
|
-
for (const fName of PROMISE_FUNCTIONS) {
|
|
158
|
-
if (isWrapped(fsPromises[fName])) {
|
|
159
|
-
this._unwrap(fsPromises, fName);
|
|
160
|
-
}
|
|
161
|
-
this._wrap(fsPromises, fName, this._patchPromiseFunction.bind(this, fName));
|
|
162
|
-
}
|
|
163
|
-
return fsPromises;
|
|
164
|
-
},
|
|
165
|
-
(fsPromises) => {
|
|
166
|
-
if (fsPromises === void 0) return;
|
|
167
|
-
for (const fName of PROMISE_FUNCTIONS) {
|
|
168
|
-
if (isWrapped(fsPromises[fName])) {
|
|
169
|
-
this._unwrap(fsPromises, fName);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
)
|
|
174
|
-
];
|
|
175
|
-
}
|
|
176
|
-
_patchSyncFunction(functionName, original) {
|
|
177
|
-
const instrumentation = this;
|
|
178
|
-
const patchedFunction = function(...args) {
|
|
179
|
-
const config = instrumentation.getConfig();
|
|
180
|
-
const attributes = getSpanAttributes(functionName, args, config);
|
|
181
|
-
return startSpan({ name: `fs.${functionName}`, onlyIfParent: true, attributes }, (span) => {
|
|
182
|
-
try {
|
|
183
|
-
return suppressTracing(() => original.apply(this, args));
|
|
184
|
-
} catch (error) {
|
|
185
|
-
recordError(span, error, config);
|
|
186
|
-
throw error;
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
return patchedFunctionWithOriginalProperties(patchedFunction, original);
|
|
191
|
-
}
|
|
192
|
-
_patchCallbackFunction(functionName, original) {
|
|
193
|
-
const instrumentation = this;
|
|
194
|
-
const patchedFunction = function(...args) {
|
|
195
|
-
const config = instrumentation.getConfig();
|
|
196
|
-
const lastIdx = args.length - 1;
|
|
197
|
-
const cb = args[lastIdx];
|
|
198
|
-
if (typeof cb !== "function") {
|
|
199
|
-
return original.apply(this, args);
|
|
200
|
-
}
|
|
201
|
-
const attributes = getSpanAttributes(functionName, args, config);
|
|
202
|
-
const span = startInactiveSpan({ name: `fs.${functionName}`, onlyIfParent: true, attributes });
|
|
203
|
-
args[lastIdx] = context.bind(context.active(), function(...cbArgs) {
|
|
204
|
-
const error = cbArgs[0];
|
|
205
|
-
if (error) {
|
|
206
|
-
recordError(span, error, config);
|
|
207
|
-
}
|
|
208
|
-
span.end();
|
|
209
|
-
return cb.apply(this, cbArgs);
|
|
210
|
-
});
|
|
103
|
+
if (patched.has(name)) return;
|
|
104
|
+
patched.add(name);
|
|
105
|
+
obj[name] = wrapper(original);
|
|
106
|
+
}
|
|
107
|
+
function _patchSyncFunction(functionName, original, config) {
|
|
108
|
+
const patchedFunction = function(...args) {
|
|
109
|
+
const attributes = getSpanAttributes(functionName, args, config);
|
|
110
|
+
return startSpan({ name: `fs.${functionName}`, onlyIfParent: true, attributes }, (span) => {
|
|
211
111
|
try {
|
|
212
112
|
return suppressTracing(() => original.apply(this, args));
|
|
213
113
|
} catch (error) {
|
|
214
114
|
recordError(span, error, config);
|
|
215
|
-
span.end();
|
|
216
115
|
throw error;
|
|
217
116
|
}
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
return patchedFunctionWithOriginalProperties(patchedFunction, original);
|
|
120
|
+
}
|
|
121
|
+
function _patchCallbackFunction(functionName, original, config) {
|
|
122
|
+
const patchedFunction = function(...args) {
|
|
123
|
+
const lastIdx = args.length - 1;
|
|
124
|
+
const cb = args[lastIdx];
|
|
125
|
+
if (typeof cb !== "function") {
|
|
126
|
+
return original.apply(this, args);
|
|
127
|
+
}
|
|
128
|
+
const attributes = getSpanAttributes(functionName, args, config);
|
|
129
|
+
const span = startInactiveSpan({ name: `fs.${functionName}`, onlyIfParent: true, attributes });
|
|
130
|
+
const parentSpan = getActiveSpan();
|
|
131
|
+
args[lastIdx] = function(...cbArgs) {
|
|
132
|
+
const error = cbArgs[0];
|
|
133
|
+
if (error) {
|
|
134
|
+
recordError(span, error, config);
|
|
135
|
+
}
|
|
136
|
+
span.end();
|
|
137
|
+
if (parentSpan) {
|
|
138
|
+
return withActiveSpan(parentSpan, () => cb.apply(this, cbArgs));
|
|
139
|
+
}
|
|
140
|
+
return cb.apply(this, cbArgs);
|
|
218
141
|
};
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
142
|
+
try {
|
|
143
|
+
return suppressTracing(() => original.apply(this, args));
|
|
144
|
+
} catch (error) {
|
|
145
|
+
recordError(span, error, config);
|
|
146
|
+
span.end();
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
return patchedFunctionWithOriginalProperties(patchedFunction, original);
|
|
151
|
+
}
|
|
152
|
+
function _patchExistsCallbackFunction(original, config) {
|
|
153
|
+
const functionName = "exists";
|
|
154
|
+
const patchedFunction = function(...args) {
|
|
155
|
+
const lastIdx = args.length - 1;
|
|
156
|
+
const cb = args[lastIdx];
|
|
157
|
+
if (typeof cb !== "function") {
|
|
158
|
+
return original.apply(this, args);
|
|
159
|
+
}
|
|
160
|
+
const attributes = getSpanAttributes(functionName, args, config);
|
|
161
|
+
const span = startInactiveSpan({ name: `fs.${functionName}`, onlyIfParent: true, attributes });
|
|
162
|
+
const parentSpan = getActiveSpan();
|
|
163
|
+
args[lastIdx] = function(...cbArgs) {
|
|
164
|
+
span.end();
|
|
165
|
+
if (parentSpan) {
|
|
166
|
+
return withActiveSpan(parentSpan, () => cb.apply(this, cbArgs));
|
|
229
167
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
168
|
+
return cb.apply(this, cbArgs);
|
|
169
|
+
};
|
|
170
|
+
try {
|
|
171
|
+
return suppressTracing(() => original.apply(this, args));
|
|
172
|
+
} catch (error) {
|
|
173
|
+
recordError(span, error, config);
|
|
174
|
+
span.end();
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const functionWithOriginalProperties = patchedFunctionWithOriginalProperties(patchedFunction, original);
|
|
179
|
+
const promisified = function(path) {
|
|
180
|
+
return new Promise((resolve) => functionWithOriginalProperties(path, resolve));
|
|
181
|
+
};
|
|
182
|
+
Object.defineProperty(promisified, "name", { value: functionName });
|
|
183
|
+
Object.defineProperty(functionWithOriginalProperties, promisify.custom, {
|
|
184
|
+
value: promisified
|
|
185
|
+
});
|
|
186
|
+
return functionWithOriginalProperties;
|
|
187
|
+
}
|
|
188
|
+
function _patchPromiseFunction(functionName, original, config) {
|
|
189
|
+
const patchedFunction = async function(...args) {
|
|
190
|
+
const attributes = getSpanAttributes(functionName, args, config);
|
|
191
|
+
return startSpan({ name: `fs.${functionName}`, onlyIfParent: true, attributes }, async (span) => {
|
|
236
192
|
try {
|
|
237
|
-
return suppressTracing(() => original.apply(this, args));
|
|
193
|
+
return await suppressTracing(() => original.apply(this, args));
|
|
238
194
|
} catch (error) {
|
|
239
195
|
recordError(span, error, config);
|
|
240
|
-
span.end();
|
|
241
196
|
throw error;
|
|
242
197
|
}
|
|
243
|
-
};
|
|
244
|
-
const functionWithOriginalProperties = patchedFunctionWithOriginalProperties(patchedFunction, original);
|
|
245
|
-
const promisified = function(path) {
|
|
246
|
-
return new Promise((resolve) => functionWithOriginalProperties(path, resolve));
|
|
247
|
-
};
|
|
248
|
-
Object.defineProperty(promisified, "name", { value: functionName });
|
|
249
|
-
Object.defineProperty(functionWithOriginalProperties, promisify.custom, {
|
|
250
|
-
value: promisified
|
|
251
198
|
});
|
|
252
|
-
|
|
199
|
+
};
|
|
200
|
+
return patchedFunctionWithOriginalProperties(patchedFunction, original);
|
|
201
|
+
}
|
|
202
|
+
function enableFsInstrumentation(config = {}) {
|
|
203
|
+
for (const fName of SYNC_FUNCTIONS) {
|
|
204
|
+
const { objectToPatch, functionNameToPatch } = indexFs(fs, fName);
|
|
205
|
+
_patchMethod(objectToPatch, functionNameToPatch, (original) => _patchSyncFunction(fName, original, config));
|
|
253
206
|
}
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
};
|
|
268
|
-
return patchedFunctionWithOriginalProperties(patchedFunction, original);
|
|
207
|
+
for (const fName of CALLBACK_FUNCTIONS) {
|
|
208
|
+
const { objectToPatch, functionNameToPatch } = indexFs(fs, fName);
|
|
209
|
+
if (fName === "exists") {
|
|
210
|
+
_patchMethod(objectToPatch, functionNameToPatch, (original) => _patchExistsCallbackFunction(original, config));
|
|
211
|
+
} else {
|
|
212
|
+
_patchMethod(objectToPatch, functionNameToPatch, (original) => _patchCallbackFunction(fName, original, config));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const fsPromises = fs.promises;
|
|
216
|
+
for (const fName of PROMISE_FUNCTIONS) {
|
|
217
|
+
_patchMethod(fsPromises, fName, (original) => _patchPromiseFunction(fName, original, config));
|
|
269
218
|
}
|
|
270
219
|
}
|
|
271
220
|
function recordError(span, error, config) {
|
|
@@ -275,5 +224,5 @@ function recordError(span, error, config) {
|
|
|
275
224
|
}
|
|
276
225
|
}
|
|
277
226
|
|
|
278
|
-
export {
|
|
227
|
+
export { enableFsInstrumentation };
|
|
279
228
|
//# sourceMappingURL=instrumentation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/fs/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-fs\n * - Upstream version: @opentelemetry/instrumentation-fs@0.37.0\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n * - The OpenTelemetry tracer APIs were replaced with Sentry's `startSpan`/`startInactiveSpan`/`suppressTracing`\n * and the configurable `createHook`/`endHook`/`requireParentSpan` options were removed in favor of inlined,\n * Sentry-specific span attributes.\n */\n\nimport { context } from '@opentelemetry/api';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n startSpan,\n suppressTracing,\n} from '@sentry/core';\nimport type * as fs from 'fs';\nimport { promisify } from 'util';\nimport { CALLBACK_FUNCTIONS, PROMISE_FUNCTIONS, SYNC_FUNCTIONS } from './constants';\nimport type { FMember, FPMember, FsInstrumentationConfig, GenericFunction } from './types';\nimport { indexFs } from './utils';\n\ntype FS = typeof fs;\ntype FSPromises = (typeof fs)['promises'];\n\nconst PACKAGE_NAME = '@sentry/instrumentation-fs';\n\nconst SPAN_ORIGIN = 'auto.file.fs';\nconst SPAN_OP = 'file';\n\n// The following lists categorize `fs` functions by the shape of their leading path arguments, so we can\n// record meaningful span attributes for them. These are Sentry-specific additions (not part of upstream).\nconst FS_OPERATIONS_WITH_OLD_PATH_NEW_PATH = ['rename', 'renameSync'];\nconst FS_OPERATIONS_WITH_SRC_DEST = ['copyFile', 'cp', 'copyFileSync', 'cpSync'];\nconst FS_OPERATIONS_WITH_EXISTING_PATH_NEW_PATH = ['link', 'linkSync'];\nconst FS_OPERATIONS_WITH_PREFIX = ['mkdtemp', 'mkdtempSync'];\nconst FS_OPERATIONS_WITH_TARGET_PATH = ['symlink', 'symlinkSync'];\nconst FS_OPERATIONS_WITH_PATH_ARG = [\n 'access',\n 'appendFile',\n 'chmod',\n 'chown',\n 'exists',\n 'mkdir',\n 'lchown',\n 'lstat',\n 'lutimes',\n 'open',\n 'opendir',\n 'readdir',\n 'readFile',\n 'readlink',\n 'realpath',\n 'realpath.native',\n 'rm',\n 'rmdir',\n 'stat',\n 'truncate',\n 'unlink',\n 'utimes',\n 'writeFile',\n 'accessSync',\n 'appendFileSync',\n 'chmodSync',\n 'chownSync',\n 'existsSync',\n 'lchownSync',\n 'lstatSync',\n 'lutimesSync',\n 'opendirSync',\n 'mkdirSync',\n 'openSync',\n 'readdirSync',\n 'readFileSync',\n 'readlinkSync',\n 'realpathSync',\n 'realpathSync.native',\n 'rmdirSync',\n 'rmSync',\n 'statSync',\n 'truncateSync',\n 'unlinkSync',\n 'utimesSync',\n 'writeFileSync',\n];\n\n/**\n * Builds the span attributes for a given `fs` operation, optionally including the file path arguments.\n */\nfunction getSpanAttributes(\n functionName: FMember | FPMember,\n args: ArrayLike<unknown>,\n config: FsInstrumentationConfig,\n): SpanAttributes {\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: SPAN_OP,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: SPAN_ORIGIN,\n };\n\n if (!config.recordFilePaths) {\n return attributes;\n }\n\n if (typeof args[0] === 'string' && FS_OPERATIONS_WITH_PATH_ARG.includes(functionName)) {\n attributes['path_argument'] = args[0];\n } else if (typeof args[0] === 'string' && typeof args[1] === 'string') {\n if (FS_OPERATIONS_WITH_TARGET_PATH.includes(functionName)) {\n attributes['target_argument'] = args[0];\n attributes['path_argument'] = args[1];\n } else if (FS_OPERATIONS_WITH_EXISTING_PATH_NEW_PATH.includes(functionName)) {\n attributes['existing_path_argument'] = args[0];\n attributes['new_path_argument'] = args[1];\n } else if (FS_OPERATIONS_WITH_SRC_DEST.includes(functionName)) {\n attributes['src_argument'] = args[0];\n attributes['dest_argument'] = args[1];\n } else if (FS_OPERATIONS_WITH_OLD_PATH_NEW_PATH.includes(functionName)) {\n attributes['old_path_argument'] = args[0];\n attributes['new_path_argument'] = args[1];\n }\n } else if (typeof args[0] === 'string' && FS_OPERATIONS_WITH_PREFIX.includes(functionName)) {\n attributes['prefix_argument'] = args[0];\n }\n\n return attributes;\n}\n\n/**\n * This is important for 2-level functions like `realpath.native` to retain the 2nd-level\n * when patching the 1st-level.\n */\nfunction patchedFunctionWithOriginalProperties<T extends GenericFunction>(patchedFunction: T, original: T): T {\n return Object.assign(patchedFunction, original);\n}\n\nexport class FsInstrumentation extends InstrumentationBase<FsInstrumentationConfig> {\n public constructor(config: FsInstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n public init(): InstrumentationNodeModuleDefinition[] {\n return [\n new InstrumentationNodeModuleDefinition(\n 'fs',\n ['*'],\n (fs: FS) => {\n for (const fName of SYNC_FUNCTIONS) {\n const { objectToPatch, functionNameToPatch } = indexFs(fs, fName);\n\n if (isWrapped(objectToPatch[functionNameToPatch])) {\n this._unwrap(objectToPatch, functionNameToPatch);\n }\n this._wrap(objectToPatch, functionNameToPatch, this._patchSyncFunction.bind(this, fName));\n }\n for (const fName of CALLBACK_FUNCTIONS) {\n const { objectToPatch, functionNameToPatch } = indexFs(fs, fName);\n if (isWrapped(objectToPatch[functionNameToPatch])) {\n this._unwrap(objectToPatch, functionNameToPatch);\n }\n if (fName === 'exists') {\n // handling separately because of the inconsistent cb style:\n // `exists` doesn't have error as the first argument, but the result\n this._wrap(objectToPatch, functionNameToPatch, this._patchExistsCallbackFunction.bind(this, fName));\n continue;\n }\n this._wrap(objectToPatch, functionNameToPatch, this._patchCallbackFunction.bind(this, fName));\n }\n for (const fName of PROMISE_FUNCTIONS) {\n if (isWrapped(fs.promises[fName])) {\n this._unwrap(fs.promises, fName);\n }\n this._wrap(fs.promises, fName, this._patchPromiseFunction.bind(this, fName));\n }\n return fs;\n },\n (fs: FS) => {\n if (fs === undefined) return;\n for (const fName of SYNC_FUNCTIONS) {\n const { objectToPatch, functionNameToPatch } = indexFs(fs, fName);\n if (isWrapped(objectToPatch[functionNameToPatch])) {\n this._unwrap(objectToPatch, functionNameToPatch);\n }\n }\n for (const fName of CALLBACK_FUNCTIONS) {\n const { objectToPatch, functionNameToPatch } = indexFs(fs, fName);\n if (isWrapped(objectToPatch[functionNameToPatch])) {\n this._unwrap(objectToPatch, functionNameToPatch);\n }\n }\n for (const fName of PROMISE_FUNCTIONS) {\n if (isWrapped(fs.promises[fName])) {\n this._unwrap(fs.promises, fName);\n }\n }\n },\n ),\n new InstrumentationNodeModuleDefinition(\n 'fs/promises',\n ['*'],\n (fsPromises: FSPromises) => {\n for (const fName of PROMISE_FUNCTIONS) {\n if (isWrapped(fsPromises[fName])) {\n this._unwrap(fsPromises, fName);\n }\n this._wrap(fsPromises, fName, this._patchPromiseFunction.bind(this, fName));\n }\n return fsPromises;\n },\n (fsPromises: FSPromises) => {\n if (fsPromises === undefined) return;\n for (const fName of PROMISE_FUNCTIONS) {\n if (isWrapped(fsPromises[fName])) {\n this._unwrap(fsPromises, fName);\n }\n }\n },\n ),\n ];\n }\n\n protected _patchSyncFunction<T extends GenericFunction>(functionName: FMember, original: T): T {\n // oxlint-disable-next-line typescript/no-this-alias\n const instrumentation = this;\n const patchedFunction = function (this: unknown, ...args: Parameters<T>): ReturnType<T> {\n const config = instrumentation.getConfig();\n const attributes = getSpanAttributes(functionName, args, config);\n\n return startSpan({ name: `fs.${functionName}`, onlyIfParent: true, attributes }, span => {\n try {\n // Suppress tracing for internal fs calls\n return suppressTracing(() => original.apply(this, args)) as ReturnType<T>;\n } catch (error) {\n recordError(span, error, config);\n throw error;\n }\n });\n };\n return patchedFunctionWithOriginalProperties(patchedFunction as T, original);\n }\n\n protected _patchCallbackFunction<T extends GenericFunction>(functionName: FMember, original: T): T {\n // oxlint-disable-next-line typescript/no-this-alias\n const instrumentation = this;\n const patchedFunction = function (this: unknown, ...args: Parameters<T>): ReturnType<T> {\n const config = instrumentation.getConfig();\n\n const lastIdx = args.length - 1;\n const cb: unknown = args[lastIdx];\n if (typeof cb !== 'function') {\n // TODO: what to do if we are pretty sure it's going to throw\n return original.apply(this, args) as ReturnType<T>;\n }\n\n const attributes = getSpanAttributes(functionName, args, config);\n const span = startInactiveSpan({ name: `fs.${functionName}`, onlyIfParent: true, attributes });\n\n // Return to the context active during the call in the callback\n args[lastIdx] = context.bind(context.active(), function (this: unknown, ...cbArgs: unknown[]) {\n const error = cbArgs[0];\n if (error) {\n recordError(span, error, config);\n }\n span.end();\n return cb.apply(this, cbArgs);\n });\n\n try {\n // Suppress tracing for internal fs calls\n return suppressTracing(() => original.apply(this, args)) as ReturnType<T>;\n } catch (error) {\n recordError(span, error, config);\n span.end();\n throw error;\n }\n };\n return patchedFunctionWithOriginalProperties(patchedFunction as T, original);\n }\n\n protected _patchExistsCallbackFunction<T extends GenericFunction>(functionName: 'exists', original: T): T {\n // oxlint-disable-next-line typescript/no-this-alias\n const instrumentation = this;\n const patchedFunction = function (this: unknown, ...args: Parameters<T>): ReturnType<T> {\n const config = instrumentation.getConfig();\n\n const lastIdx = args.length - 1;\n const cb: unknown = args[lastIdx];\n if (typeof cb !== 'function') {\n return original.apply(this, args) as ReturnType<T>;\n }\n\n const attributes = getSpanAttributes(functionName, args, config);\n const span = startInactiveSpan({ name: `fs.${functionName}`, onlyIfParent: true, attributes });\n\n // Return to the context active during the call in the callback\n args[lastIdx] = context.bind(context.active(), function (this: unknown, ...cbArgs: unknown[]) {\n // `exists` never calls the callback with an error\n span.end();\n return cb.apply(this, cbArgs);\n });\n\n try {\n // Suppress tracing for internal fs calls\n return suppressTracing(() => original.apply(this, args)) as ReturnType<T>;\n } catch (error) {\n recordError(span, error, config);\n span.end();\n throw error;\n }\n };\n const functionWithOriginalProperties = patchedFunctionWithOriginalProperties(patchedFunction as T, original);\n\n // `exists` has a custom promisify function because of the inconsistent signature\n // replicating that on the patched function\n const promisified = function (path: unknown): Promise<unknown> {\n return new Promise(resolve => (functionWithOriginalProperties as GenericFunction)(path, resolve));\n };\n Object.defineProperty(promisified, 'name', { value: functionName });\n Object.defineProperty(functionWithOriginalProperties, promisify.custom, {\n value: promisified,\n });\n\n return functionWithOriginalProperties;\n }\n\n protected _patchPromiseFunction<T extends GenericFunction>(functionName: FPMember, original: T): T {\n // oxlint-disable-next-line typescript/no-this-alias\n const instrumentation = this;\n const patchedFunction = async function (this: unknown, ...args: Parameters<T>): Promise<unknown> {\n const config = instrumentation.getConfig();\n const attributes = getSpanAttributes(functionName, args, config);\n\n return startSpan({ name: `fs.${functionName}`, onlyIfParent: true, attributes }, async span => {\n try {\n // Suppress tracing for internal fs calls\n return await suppressTracing(() => original.apply(this, args) as Promise<unknown>);\n } catch (error) {\n recordError(span, error, config);\n throw error;\n }\n });\n };\n return patchedFunctionWithOriginalProperties(patchedFunction as unknown as T, original);\n }\n}\n\n/**\n * Sets the error status on the span and, if configured, records the error message as a span attribute.\n */\nfunction recordError(span: Span, error: unknown, config: FsInstrumentationConfig): void {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n if (config.recordErrorMessagesAsSpanAttributes && error instanceof Error) {\n span.setAttribute('fs_error', error.message);\n }\n}\n"],"names":[],"mappings":";;;;;;;AAkCA,MAAM,YAAA,GAAe,4BAAA;AAErB,MAAM,WAAA,GAAc,cAAA;AACpB,MAAM,OAAA,GAAU,MAAA;AAIhB,MAAM,oCAAA,GAAuC,CAAC,QAAA,EAAU,YAAY,CAAA;AACpE,MAAM,2BAAA,GAA8B,CAAC,UAAA,EAAY,IAAA,EAAM,gBAAgB,QAAQ,CAAA;AAC/E,MAAM,yCAAA,GAA4C,CAAC,MAAA,EAAQ,UAAU,CAAA;AACrE,MAAM,yBAAA,GAA4B,CAAC,SAAA,EAAW,aAAa,CAAA;AAC3D,MAAM,8BAAA,GAAiC,CAAC,SAAA,EAAW,aAAa,CAAA;AAChE,MAAM,2BAAA,GAA8B;AAAA,EAClC,QAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,iBAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA,EACA,gBAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,aAAA;AAAA,EACA,aAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAA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AAuC,KAAA,YAAiB,KAAA,EAAO;AACxE,IAAA,IAAA,CAAK,YAAA,CAAa,UAAA,EAAY,KAAA,CAAM,OAAO,CAAA;AAAA,EAC7C;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/fs/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-fs\n * - Upstream version: @opentelemetry/instrumentation-fs@0.37.0\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n * - The OpenTelemetry tracer APIs were replaced with Sentry's `startSpan`/`startInactiveSpan`/`suppressTracing`\n * and the configurable `createHook`/`endHook`/`requireParentSpan` options were removed in favor of inlined,\n * Sentry-specific span attributes.\n * - Completely reworked to no longer reference OpenTelemetry.\n */\n\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n getActiveSpan,\n startInactiveSpan,\n startSpan,\n suppressTracing,\n withActiveSpan,\n} from '@sentry/core';\nimport * as fs from 'fs';\nimport { promisify } from 'util';\nimport { CALLBACK_FUNCTIONS, PROMISE_FUNCTIONS, SYNC_FUNCTIONS } from './constants';\nimport type { FMember, FPMember, FsInstrumentationConfig, GenericFunction } from './types';\nimport { indexFs } from './utils';\n\nconst SPAN_ORIGIN = 'auto.file.fs';\nconst SPAN_OP = 'file';\n\n// The following lists categorize `fs` functions by the shape of their leading path arguments, so we can\n// record meaningful span attributes for them. These are Sentry-specific additions (not part of upstream).\nconst FS_OPERATIONS_WITH_OLD_PATH_NEW_PATH = ['rename', 'renameSync'];\nconst FS_OPERATIONS_WITH_SRC_DEST = ['copyFile', 'cp', 'copyFileSync', 'cpSync'];\nconst FS_OPERATIONS_WITH_EXISTING_PATH_NEW_PATH = ['link', 'linkSync'];\nconst FS_OPERATIONS_WITH_PREFIX = ['mkdtemp', 'mkdtempSync'];\nconst FS_OPERATIONS_WITH_TARGET_PATH = ['symlink', 'symlinkSync'];\nconst FS_OPERATIONS_WITH_PATH_ARG = [\n 'access',\n 'appendFile',\n 'chmod',\n 'chown',\n 'exists',\n 'mkdir',\n 'lchown',\n 'lstat',\n 'lutimes',\n 'open',\n 'opendir',\n 'readdir',\n 'readFile',\n 'readlink',\n 'realpath',\n 'realpath.native',\n 'rm',\n 'rmdir',\n 'stat',\n 'truncate',\n 'unlink',\n 'utimes',\n 'writeFile',\n 'accessSync',\n 'appendFileSync',\n 'chmodSync',\n 'chownSync',\n 'existsSync',\n 'lchownSync',\n 'lstatSync',\n 'lutimesSync',\n 'opendirSync',\n 'mkdirSync',\n 'openSync',\n 'readdirSync',\n 'readFileSync',\n 'readlinkSync',\n 'realpathSync',\n 'realpathSync.native',\n 'rmdirSync',\n 'rmSync',\n 'statSync',\n 'truncateSync',\n 'unlinkSync',\n 'utimesSync',\n 'writeFileSync',\n];\n\n/**\n * Builds the span attributes for a given `fs` operation, optionally including the file path arguments.\n */\nfunction getSpanAttributes(\n functionName: FMember | FPMember,\n args: ArrayLike<unknown>,\n config: FsInstrumentationConfig,\n): SpanAttributes {\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: SPAN_OP,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: SPAN_ORIGIN,\n };\n\n if (!config.recordFilePaths) {\n return attributes;\n }\n\n if (typeof args[0] === 'string' && FS_OPERATIONS_WITH_PATH_ARG.includes(functionName)) {\n attributes['path_argument'] = args[0];\n } else if (typeof args[0] === 'string' && typeof args[1] === 'string') {\n if (FS_OPERATIONS_WITH_TARGET_PATH.includes(functionName)) {\n attributes['target_argument'] = args[0];\n attributes['path_argument'] = args[1];\n } else if (FS_OPERATIONS_WITH_EXISTING_PATH_NEW_PATH.includes(functionName)) {\n attributes['existing_path_argument'] = args[0];\n attributes['new_path_argument'] = args[1];\n } else if (FS_OPERATIONS_WITH_SRC_DEST.includes(functionName)) {\n attributes['src_argument'] = args[0];\n attributes['dest_argument'] = args[1];\n } else if (FS_OPERATIONS_WITH_OLD_PATH_NEW_PATH.includes(functionName)) {\n attributes['old_path_argument'] = args[0];\n attributes['new_path_argument'] = args[1];\n }\n } else if (typeof args[0] === 'string' && FS_OPERATIONS_WITH_PREFIX.includes(functionName)) {\n attributes['prefix_argument'] = args[0];\n }\n\n return attributes;\n}\n\n/**\n * This is important for 2-level functions like `realpath.native` to retain the 2nd-level\n * when patching the 1st-level.\n */\nfunction patchedFunctionWithOriginalProperties<T extends GenericFunction>(patchedFunction: T, original: T): T {\n return Object.assign(patchedFunction, original);\n}\n\n// Tracks patched methods to prevent double-patching if `enableFsInstrumentation` is called more than once.\nconst _patched = new WeakMap<Record<string, GenericFunction>, Set<string>>();\n\nfunction _patchMethod(\n obj: Record<string, GenericFunction>,\n name: string,\n wrapper: (original: GenericFunction) => GenericFunction,\n): void {\n const original = obj[name];\n if (typeof original !== 'function') return;\n let patched = _patched.get(obj);\n if (!patched) {\n patched = new Set();\n _patched.set(obj, patched);\n }\n if (patched.has(name)) return;\n patched.add(name);\n obj[name] = wrapper(original);\n}\n\nfunction _patchSyncFunction<T extends GenericFunction>(\n functionName: FMember,\n original: T,\n config: FsInstrumentationConfig,\n): T {\n const patchedFunction = function (this: unknown, ...args: Parameters<T>): ReturnType<T> {\n const attributes = getSpanAttributes(functionName, args, config);\n return startSpan({ name: `fs.${functionName}`, onlyIfParent: true, attributes }, span => {\n try {\n return suppressTracing(() => original.apply(this, args)) as ReturnType<T>;\n } catch (error) {\n recordError(span, error, config);\n throw error;\n }\n });\n };\n return patchedFunctionWithOriginalProperties(patchedFunction as T, original);\n}\n\nfunction _patchCallbackFunction<T extends GenericFunction>(\n functionName: FMember,\n original: T,\n config: FsInstrumentationConfig,\n): T {\n const patchedFunction = function (this: unknown, ...args: Parameters<T>): ReturnType<T> {\n const lastIdx = args.length - 1;\n const cb: unknown = args[lastIdx];\n if (typeof cb !== 'function') {\n return original.apply(this, args) as ReturnType<T>;\n }\n\n const attributes = getSpanAttributes(functionName, args, config);\n const span = startInactiveSpan({ name: `fs.${functionName}`, onlyIfParent: true, attributes });\n const parentSpan = getActiveSpan();\n\n // Wrap the callback to end the span and restore the caller's active span context.\n // fs callbacks fire from Node's I/O event loop where the AsyncLocalStorage context\n // is lost, so any spans created inside the callback would otherwise have no parent.\n args[lastIdx] = function (this: unknown, ...cbArgs: unknown[]) {\n const error = cbArgs[0];\n if (error) {\n recordError(span, error, config);\n }\n span.end();\n if (parentSpan) {\n return withActiveSpan(parentSpan, () => (cb as GenericFunction).apply(this, cbArgs));\n }\n return (cb as GenericFunction).apply(this, cbArgs);\n };\n\n try {\n return suppressTracing(() => original.apply(this, args)) as ReturnType<T>;\n } catch (error) {\n recordError(span, error, config);\n span.end();\n throw error;\n }\n };\n return patchedFunctionWithOriginalProperties(patchedFunction as T, original);\n}\n\nfunction _patchExistsCallbackFunction<T extends GenericFunction>(original: T, config: FsInstrumentationConfig): T {\n const functionName = 'exists' as FMember;\n const patchedFunction = function (this: unknown, ...args: Parameters<T>): ReturnType<T> {\n const lastIdx = args.length - 1;\n const cb: unknown = args[lastIdx];\n if (typeof cb !== 'function') {\n return original.apply(this, args) as ReturnType<T>;\n }\n\n const attributes = getSpanAttributes(functionName, args, config);\n const span = startInactiveSpan({ name: `fs.${functionName}`, onlyIfParent: true, attributes });\n const parentSpan = getActiveSpan();\n\n // `exists` never calls the callback with an error\n args[lastIdx] = function (this: unknown, ...cbArgs: unknown[]) {\n span.end();\n if (parentSpan) {\n return withActiveSpan(parentSpan, () => (cb as GenericFunction).apply(this, cbArgs));\n }\n return (cb as GenericFunction).apply(this, cbArgs);\n };\n\n try {\n return suppressTracing(() => original.apply(this, args)) as ReturnType<T>;\n } catch (error) {\n recordError(span, error, config);\n span.end();\n throw error;\n }\n };\n const functionWithOriginalProperties = patchedFunctionWithOriginalProperties(patchedFunction as T, original);\n\n // `exists` has a custom promisify function because of the inconsistent signature\n // replicating that on the patched function\n const promisified = function (path: unknown): Promise<unknown> {\n return new Promise(resolve => (functionWithOriginalProperties as GenericFunction)(path, resolve));\n };\n Object.defineProperty(promisified, 'name', { value: functionName });\n Object.defineProperty(functionWithOriginalProperties, promisify.custom, {\n value: promisified,\n });\n\n return functionWithOriginalProperties;\n}\n\nfunction _patchPromiseFunction<T extends GenericFunction>(\n functionName: FPMember,\n original: T,\n config: FsInstrumentationConfig,\n): T {\n const patchedFunction = async function (this: unknown, ...args: Parameters<T>): Promise<unknown> {\n const attributes = getSpanAttributes(functionName, args, config);\n return startSpan({ name: `fs.${functionName}`, onlyIfParent: true, attributes }, async span => {\n try {\n return await suppressTracing(() => original.apply(this, args) as Promise<unknown>);\n } catch (error) {\n recordError(span, error, config);\n throw error;\n }\n });\n };\n return patchedFunctionWithOriginalProperties(patchedFunction as unknown as T, original);\n}\n\nexport function enableFsInstrumentation(config: FsInstrumentationConfig = {}): void {\n for (const fName of SYNC_FUNCTIONS) {\n const { objectToPatch, functionNameToPatch } = indexFs(fs, fName);\n _patchMethod(objectToPatch, functionNameToPatch, original => _patchSyncFunction(fName, original, config));\n }\n\n for (const fName of CALLBACK_FUNCTIONS) {\n const { objectToPatch, functionNameToPatch } = indexFs(fs, fName);\n if (fName === 'exists') {\n _patchMethod(objectToPatch, functionNameToPatch, original => _patchExistsCallbackFunction(original, config));\n } else {\n _patchMethod(objectToPatch, functionNameToPatch, original => _patchCallbackFunction(fName, original, config));\n }\n }\n\n // `fs.promises` and `import { readFile } from 'fs/promises'` share the same object in Node 14+,\n // so patching one covers both.\n const fsPromises = fs.promises as unknown as Record<string, GenericFunction>;\n for (const fName of PROMISE_FUNCTIONS) {\n _patchMethod(fsPromises, fName, original => _patchPromiseFunction(fName, original, config));\n }\n}\n\n/**\n * Sets the error status on the span and, if configured, records the error message as a span attribute.\n */\nfunction recordError(span: Span, error: unknown, config: FsInstrumentationConfig): void {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n if (config.recordErrorMessagesAsSpanAttributes && error instanceof Error) {\n span.setAttribute('fs_error', error.message);\n }\n}\n"],"names":[],"mappings":";;;;;;AA+BA,MAAM,WAAA,GAAc,cAAA;AACpB,MAAM,OAAA,GAAU,MAAA;AAIhB,MAAM,oCAAA,GAAuC,CAAC,QAAA,EAAU,YAAY,CAAA;AACpE,MAAM,2BAAA,GAA8B,CAAC,UAAA,EAAY,IAAA,EAAM,gBAAgB,QAAQ,CAAA;AAC/E,MAAM,yCAAA,GAA4C,CAAC,MAAA,EAAQ,UAAU,CAAA;AACrE,MAAM,yBAAA,GAA4B,CAAC,SAAA,EAAW,aAAa,CAAA;AAC3D,MAAM,8BAAA,GAAiC,CAAC,SAAA,EAAW,aAAa,CAAA;AAChE,MAAM,2BAAA,GAA8B;AAAA,EAClC,QAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,iBAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA,EACA,gBAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,aAAA;AAAA,EACA,aAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAAA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