{"version":3,"file":"knex.js","sources":["../../../../src/integrations/tracing/knex.ts"],"sourcesContent":["import { KnexInstrumentation } from '@opentelemetry/instrumentation-knex';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, defineIntegration, spanToJSON } from '@sentry/core';\nimport type { IntegrationFn } from '@sentry/types';\nimport { generateInstrumentOnce } from '../../otel/instrument';\n\nconst INTEGRATION_NAME = 'Knex';\n\nexport const instrumentKnex = generateInstrumentOnce(\n INTEGRATION_NAME,\n () => new KnexInstrumentation({ requireParentSpan: true }),\n);\n\nconst _knexIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentKnex();\n },\n\n setup(client) {\n client.on('spanStart', span => {\n const { data } = spanToJSON(span);\n // knex.version is always set in the span data\n // https://github.com/open-telemetry/opentelemetry-js-contrib/blob/0309caeafc44ac9cb13a3345b790b01b76d0497d/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts#L138\n if (data && 'knex.version' in data) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.knex');\n }\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Knex integration\n *\n * Capture tracing data for [Knex](https://knexjs.org/).\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/node';\n *\n * Sentry.init({\n * integrations: [Sentry.knexIntegration()],\n * });\n * ```\n */\nexport const knexIntegration = defineIntegration(_knexIntegration);\n"],"names":[],"mappings":";;;;AAKA,MAAM,gBAAA,GAAmB,MAAM;;AAExB,MAAM,cAAe,GAAE,sBAAsB;AACpD,EAAE,gBAAgB;AAClB,EAAE,MAAM,IAAI,mBAAmB,CAAC,EAAE,iBAAiB,EAAE,IAAK,EAAC,CAAC;AAC5D;;AAEA,MAAM,gBAAiB,IAAG,MAAM;AAChC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,cAAc,EAAE;AACtB,KAAK;;AAEL,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,QAAQ;AACrC,QAAQ,MAAM,EAAE,IAAK,EAAA,GAAI,UAAU,CAAC,IAAI,CAAC;AACzC;AACA;AACA,QAAQ,IAAI,IAAA,IAAQ,cAAe,IAAG,IAAI,EAAE;AAC5C,UAAU,IAAI,CAAC,YAAY,CAAC,gCAAgC,EAAE,mBAAmB,CAAC;AAClF;AACA,OAAO,CAAC;AACR,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,eAAgB,GAAE,iBAAiB,CAAC,gBAAgB;;;;"}