@sentry/core
Advanced tools
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const debounce = require('../utils/debounce.js'); | ||
| const segmentSpanCaptureStrategy = require('./segmentSpanCaptureStrategy.js'); | ||
| const CAPTURED_SPANS = /* @__PURE__ */ new WeakSet(); | ||
| const isSpanAlreadyCaptured = (span) => CAPTURED_SPANS.has(span); | ||
| const markSpanCaptured = (span) => { | ||
| CAPTURED_SPANS.add(span); | ||
| }; | ||
| const CLIENT_QUEUES = /* @__PURE__ */ new WeakMap(); | ||
| function _INTERNAL_setDeferSegmentSpanCapture(client) { | ||
| if (!segmentSpanCaptureStrategy.getSegmentSpanCaptureStrategy()) { | ||
| segmentSpanCaptureStrategy.setSegmentSpanCaptureStrategy(deferredSegmentSpanCaptureStrategy); | ||
| } | ||
| if (CLIENT_QUEUES.has(client)) { | ||
| return; | ||
| } | ||
| const pendingCaptures = /* @__PURE__ */ new Set(); | ||
| const debouncedDrain = debounce.debounce( | ||
| () => { | ||
| const captures = [...pendingCaptures]; | ||
| pendingCaptures.clear(); | ||
| for (const capture of captures) { | ||
| capture(); | ||
| } | ||
| }, | ||
| 1, | ||
| { maxWait: 100 } | ||
| ); | ||
| client.on("flush", () => { | ||
| debouncedDrain.flush(); | ||
| }); | ||
| CLIENT_QUEUES.set(client, (capture) => { | ||
| pendingCaptures.add(capture); | ||
| debouncedDrain(); | ||
| }); | ||
| } | ||
| const deferredSegmentSpanCaptureStrategy = { | ||
| onSegmentSpanEnded(convert, scope) { | ||
| const client = scope.getClient(); | ||
| const enqueue = client && CLIENT_QUEUES.get(client); | ||
| if (!enqueue) { | ||
| const transactionEvent = convert(); | ||
| if (transactionEvent) { | ||
| client?.captureEvent(transactionEvent); | ||
| } | ||
| return; | ||
| } | ||
| enqueue(() => { | ||
| const transactionEvent = convert({ isSpanAlreadyCaptured, onSpanCaptured: markSpanCaptured }); | ||
| if (transactionEvent) { | ||
| client.captureEvent(transactionEvent); | ||
| } | ||
| }); | ||
| }, | ||
| onChildSpanEnded(span, rootSpan, convert, scope) { | ||
| if (CAPTURED_SPANS.has(span) || !CAPTURED_SPANS.has(rootSpan)) { | ||
| return; | ||
| } | ||
| const client = scope.getClient(); | ||
| const enqueue = client && CLIENT_QUEUES.get(client); | ||
| const captureOrphan = () => { | ||
| const transactionEvent = convert({ isSpanAlreadyCaptured, onSpanCaptured: markSpanCaptured }); | ||
| if (transactionEvent?.contexts?.trace?.data) { | ||
| transactionEvent.contexts.trace.data["sentry.parent_span_already_sent"] = true; | ||
| } | ||
| if (transactionEvent) { | ||
| client?.captureEvent(transactionEvent); | ||
| } | ||
| }; | ||
| if (enqueue) { | ||
| enqueue(captureOrphan); | ||
| } else { | ||
| captureOrphan(); | ||
| } | ||
| } | ||
| }; | ||
| exports._INTERNAL_setDeferSegmentSpanCapture = _INTERNAL_setDeferSegmentSpanCapture; | ||
| //# sourceMappingURL=deferSegmentSpanCapture.js.map |
| {"version":3,"file":"deferSegmentSpanCapture.js","sources":["../../../src/tracing/deferSegmentSpanCapture.ts"],"sourcesContent":["import type { Client } from '../client';\nimport type { Scope } from '../scope';\nimport type { Span } from '../types/span';\nimport { debounce } from '../utils/debounce';\nimport { getSegmentSpanCaptureStrategy, setSegmentSpanCaptureStrategy } from './segmentSpanCaptureStrategy';\nimport type { SegmentSpanConverter } from './segmentSpanCaptureStrategy';\n\n// Spans already sent in a transaction, so a child ending after its segment can be emitted as its own\n// orphan transaction instead of being dropped or sent twice.\nconst CAPTURED_SPANS = new WeakSet<Span>();\nconst isSpanAlreadyCaptured = (span: Span): boolean => CAPTURED_SPANS.has(span);\nconst markSpanCaptured = (span: Span): void => {\n CAPTURED_SPANS.add(span);\n};\n\n// One debounced queue per client, drained on the client's `flush`/`close`. Mirrors the OpenTelemetry\n// span exporter, which holds one such buffer per instance, and the debounce window matches it. The\n// capturing client is resolved from the span's captured scope and bound when the span ends, not\n// re-resolved at drain time, so a deferred transaction lands on the client that created the span even if\n// the current client (or the captured scope's own client) is reassigned before the debounce fires.\nconst CLIENT_QUEUES = new WeakMap<Client, (capture: () => void) => void>();\n\n/**\n * @private Private API with no semver guarantees!\n *\n * Enable deferred segment-span transaction capture for a client: create its debounced queue and\n * register the strategy (idempotent).\n *\n * `SentrySpan` otherwise assembles the transaction synchronously the instant a segment span ends, which\n * drops children whose async instrumentation closes them later (a diagnostics-channel `asyncEnd`\n * callback in the same tick, or engine spans replayed on a later tick). The debounced snapshot delays\n * capture just enough for those later span ends to land first; a child that still ends after it is\n * emitted as its own orphan transaction. Pending captures drain on the client's `flush` hook, so\n * `Sentry.flush()` / `client.close()` cannot resolve before they run.\n */\nexport function _INTERNAL_setDeferSegmentSpanCapture(client: Client): void {\n if (!getSegmentSpanCaptureStrategy()) {\n setSegmentSpanCaptureStrategy(deferredSegmentSpanCaptureStrategy);\n }\n if (CLIENT_QUEUES.has(client)) {\n return;\n }\n\n const pendingCaptures = new Set<() => void>();\n const debouncedDrain = debounce(\n () => {\n const captures = [...pendingCaptures];\n pendingCaptures.clear();\n for (const capture of captures) {\n capture();\n }\n },\n 1,\n { maxWait: 100 },\n );\n\n client.on('flush', () => {\n debouncedDrain.flush();\n });\n\n CLIENT_QUEUES.set(client, capture => {\n pendingCaptures.add(capture);\n debouncedDrain();\n });\n}\n\nconst deferredSegmentSpanCaptureStrategy = {\n onSegmentSpanEnded(convert: SegmentSpanConverter, scope: Scope): void {\n const client = scope.getClient();\n const enqueue = client && CLIENT_QUEUES.get(client);\n if (!enqueue) {\n // The capturing client didn't enable deferral: capture synchronously.\n const transactionEvent = convert();\n if (transactionEvent) {\n client?.captureEvent(transactionEvent);\n }\n return;\n }\n\n enqueue(() => {\n const transactionEvent = convert({ isSpanAlreadyCaptured, onSpanCaptured: markSpanCaptured });\n if (transactionEvent) {\n client.captureEvent(transactionEvent);\n }\n });\n },\n\n onChildSpanEnded(span: Span, rootSpan: Span, convert: SegmentSpanConverter, scope: Scope): void {\n // Only a late child of an already-captured segment is an orphan. Inert under span streaming, where\n // `CAPTURED_SPANS` is never populated.\n if (CAPTURED_SPANS.has(span) || !CAPTURED_SPANS.has(rootSpan)) {\n return;\n }\n\n const client = scope.getClient();\n const enqueue = client && CLIENT_QUEUES.get(client);\n\n const captureOrphan = (): void => {\n const transactionEvent = convert({ isSpanAlreadyCaptured, onSpanCaptured: markSpanCaptured });\n if (transactionEvent?.contexts?.trace?.data) {\n // Tag orphans so they're distinguishable downstream (mirrors the OTel span exporter).\n transactionEvent.contexts.trace.data['sentry.parent_span_already_sent'] = true;\n }\n if (transactionEvent) {\n client?.captureEvent(transactionEvent);\n }\n };\n\n // Defer when the capturing client batches; otherwise emit now so the orphan isn't dropped.\n if (enqueue) {\n enqueue(captureOrphan);\n } else {\n captureOrphan();\n }\n },\n};\n"],"names":["getSegmentSpanCaptureStrategy","setSegmentSpanCaptureStrategy","debounce"],"mappings":";;;;;AASA,MAAM,cAAA,uBAAqB,OAAA,EAAc;AACzC,MAAM,qBAAA,GAAwB,CAAC,IAAA,KAAwB,cAAA,CAAe,IAAI,IAAI,CAAA;AAC9E,MAAM,gBAAA,GAAmB,CAAC,IAAA,KAAqB;AAC7C,EAAA,cAAA,CAAe,IAAI,IAAI,CAAA;AACzB,CAAA;AAOA,MAAM,aAAA,uBAAoB,OAAA,EAA+C;AAelE,SAAS,qCAAqC,MAAA,EAAsB;AACzE,EAAA,IAAI,CAACA,0DAA8B,EAAG;AACpC,IAAAC,wDAAA,CAA8B,kCAAkC,CAAA;AAAA,EAClE;AACA,EAAA,IAAI,aAAA,CAAc,GAAA,CAAI,MAAM,CAAA,EAAG;AAC7B,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,eAAA,uBAAsB,GAAA,EAAgB;AAC5C,EAAA,MAAM,cAAA,GAAiBC,iBAAA;AAAA,IACrB,MAAM;AACJ,MAAA,MAAM,QAAA,GAAW,CAAC,GAAG,eAAe,CAAA;AACpC,MAAA,eAAA,CAAgB,KAAA,EAAM;AACtB,MAAA,KAAA,MAAW,WAAW,QAAA,EAAU;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AA,MAAM,MAAA,GAAS,MAAM,SAAA,EAAU;AAC/B,IAAA,MAAM,OAAA,GAAU,MAAA,IAAU,aAAA,CAAc,GAAA,CAAI,MAAM,CAAA;AAElD,IAAA,MAAM,gBAAgB,MAAY;AAChC,MAAA,MAAM,mBAAmB,OAAA,CAAQ,EAAE,qBAAA,EAAuB,cAAA,EAAgB,kBAAkB,CAAA;AAC5F,MAAA,IAAI,gBAAA,EAAkB,QAAA,EAAU,KAAA,EAAO,IAAA,EAAM;AAE3C,QAAA,gBAAA,CAAiB,QAAA,CAAS,KAAA,CAAM,IAAA,CAAK,iCAAiC,CAAA,GAAI,IAAA;AAAA,MAC5E;AACA,MAAA,IAAI,gBAAA,EAAkB;AACpB,QAAA,MAAA,EAAQ,aAAa,gBAAgB,CAAA;AAAA,MACvC;AAAA,IACF,CAAA;AAGA,IAAA,IAAI,OAAA,EAAS;AACX,MAAA,OAAA,CAAQ,aAAa,CAAA;AAAA,IACvB,CAAA,MAAO;AACL,MAAA,aAAA,EAAc;AAAA,IAChB;AAAA,EACF;AACF,CAAA;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const carrier = require('../carrier.js'); | ||
| function setSegmentSpanCaptureStrategy(strategy) { | ||
| carrier.getSentryCarrier(carrier.getMainCarrier()).segmentSpanCaptureStrategy = strategy; | ||
| } | ||
| function getSegmentSpanCaptureStrategy() { | ||
| return carrier.getSentryCarrier(carrier.getMainCarrier()).segmentSpanCaptureStrategy; | ||
| } | ||
| exports.getSegmentSpanCaptureStrategy = getSegmentSpanCaptureStrategy; | ||
| exports.setSegmentSpanCaptureStrategy = setSegmentSpanCaptureStrategy; | ||
| //# sourceMappingURL=segmentSpanCaptureStrategy.js.map |
| {"version":3,"file":"segmentSpanCaptureStrategy.js","sources":["../../../src/tracing/segmentSpanCaptureStrategy.ts"],"sourcesContent":["import { getMainCarrier, getSentryCarrier } from '../carrier';\nimport type { Scope } from '../scope';\nimport type { TransactionEvent } from '../types/event';\nimport type { Span } from '../types/span';\n\n/**\n * Callbacks the deferred-capture strategy hands to `_convertSpanToTransaction` when assembling a\n * transaction. The synchronous (browser) path calls the converter with no options, so neither runs.\n */\nexport interface SegmentSpanCaptureConvertOptions {\n /** Skip a descendant already sent in an earlier transaction, so it isn't sent twice. */\n isSpanAlreadyCaptured?: (span: Span) => boolean;\n /** Record each span included here, so a child that ends after the snapshot can be emitted as an orphan. */\n onSpanCaptured?: (span: Span) => void;\n}\n\nexport type SegmentSpanConverter = (options?: SegmentSpanCaptureConvertOptions) => TransactionEvent | undefined;\n\n/**\n * Assembles segment spans into transactions. Registered by SDKs that defer capture (see\n * `_INTERNAL_setDeferSegmentSpanCapture`); when unset, `SentrySpan` captures synchronously. Living\n * behind this seam tree-shakes the deferral machinery out of SDKs that never register one (e.g. browser).\n */\nexport interface SegmentSpanCaptureStrategy {\n /** Assemble and capture a segment (root or standalone-root) span's transaction through its captured scope. */\n onSegmentSpanEnded(convert: SegmentSpanConverter, scope: Scope): void;\n /** Consider a child that ended after its segment for emission as its own orphan transaction. */\n onChildSpanEnded(span: Span, rootSpan: Span, convert: SegmentSpanConverter, scope: Scope): void;\n}\n\n/**\n * @private Private API with no semver guarantees!\n *\n * Set the global segment-span capture strategy (or clear it with `undefined`).\n */\nexport function setSegmentSpanCaptureStrategy(strategy: SegmentSpanCaptureStrategy | undefined): void {\n getSentryCarrier(getMainCarrier()).segmentSpanCaptureStrategy = strategy;\n}\n\n/** Get the global segment-span capture strategy, or `undefined` when none is registered. */\nexport function getSegmentSpanCaptureStrategy(): SegmentSpanCaptureStrategy | undefined {\n return getSentryCarrier(getMainCarrier()).segmentSpanCaptureStrategy;\n}\n"],"names":["getSentryCarrier","getMainCarrier"],"mappings":";;;;AAmCO,SAAS,8BAA8B,QAAA,EAAwD;AACpG,EAAAA,wBAAA,CAAiBC,sBAAA,EAAgB,CAAA,CAAE,0BAAA,GAA6B,QAAA;AAClE;AAGO,SAAS,6BAAA,GAAwE;AACtF,EAAA,OAAOD,wBAAA,CAAiBC,sBAAA,EAAgB,CAAA,CAAE,0BAAA;AAC5C;;;;;"} |
| import { debounce } from '../utils/debounce.js'; | ||
| import { getSegmentSpanCaptureStrategy, setSegmentSpanCaptureStrategy } from './segmentSpanCaptureStrategy.js'; | ||
| const CAPTURED_SPANS = /* @__PURE__ */ new WeakSet(); | ||
| const isSpanAlreadyCaptured = (span) => CAPTURED_SPANS.has(span); | ||
| const markSpanCaptured = (span) => { | ||
| CAPTURED_SPANS.add(span); | ||
| }; | ||
| const CLIENT_QUEUES = /* @__PURE__ */ new WeakMap(); | ||
| function _INTERNAL_setDeferSegmentSpanCapture(client) { | ||
| if (!getSegmentSpanCaptureStrategy()) { | ||
| setSegmentSpanCaptureStrategy(deferredSegmentSpanCaptureStrategy); | ||
| } | ||
| if (CLIENT_QUEUES.has(client)) { | ||
| return; | ||
| } | ||
| const pendingCaptures = /* @__PURE__ */ new Set(); | ||
| const debouncedDrain = debounce( | ||
| () => { | ||
| const captures = [...pendingCaptures]; | ||
| pendingCaptures.clear(); | ||
| for (const capture of captures) { | ||
| capture(); | ||
| } | ||
| }, | ||
| 1, | ||
| { maxWait: 100 } | ||
| ); | ||
| client.on("flush", () => { | ||
| debouncedDrain.flush(); | ||
| }); | ||
| CLIENT_QUEUES.set(client, (capture) => { | ||
| pendingCaptures.add(capture); | ||
| debouncedDrain(); | ||
| }); | ||
| } | ||
| const deferredSegmentSpanCaptureStrategy = { | ||
| onSegmentSpanEnded(convert, scope) { | ||
| const client = scope.getClient(); | ||
| const enqueue = client && CLIENT_QUEUES.get(client); | ||
| if (!enqueue) { | ||
| const transactionEvent = convert(); | ||
| if (transactionEvent) { | ||
| client?.captureEvent(transactionEvent); | ||
| } | ||
| return; | ||
| } | ||
| enqueue(() => { | ||
| const transactionEvent = convert({ isSpanAlreadyCaptured, onSpanCaptured: markSpanCaptured }); | ||
| if (transactionEvent) { | ||
| client.captureEvent(transactionEvent); | ||
| } | ||
| }); | ||
| }, | ||
| onChildSpanEnded(span, rootSpan, convert, scope) { | ||
| if (CAPTURED_SPANS.has(span) || !CAPTURED_SPANS.has(rootSpan)) { | ||
| return; | ||
| } | ||
| const client = scope.getClient(); | ||
| const enqueue = client && CLIENT_QUEUES.get(client); | ||
| const captureOrphan = () => { | ||
| const transactionEvent = convert({ isSpanAlreadyCaptured, onSpanCaptured: markSpanCaptured }); | ||
| if (transactionEvent?.contexts?.trace?.data) { | ||
| transactionEvent.contexts.trace.data["sentry.parent_span_already_sent"] = true; | ||
| } | ||
| if (transactionEvent) { | ||
| client?.captureEvent(transactionEvent); | ||
| } | ||
| }; | ||
| if (enqueue) { | ||
| enqueue(captureOrphan); | ||
| } else { | ||
| captureOrphan(); | ||
| } | ||
| } | ||
| }; | ||
| export { _INTERNAL_setDeferSegmentSpanCapture }; | ||
| //# sourceMappingURL=deferSegmentSpanCapture.js.map |
| {"version":3,"file":"deferSegmentSpanCapture.js","sources":["../../../src/tracing/deferSegmentSpanCapture.ts"],"sourcesContent":["import type { Client } from '../client';\nimport type { Scope } from '../scope';\nimport type { Span } from '../types/span';\nimport { debounce } from '../utils/debounce';\nimport { getSegmentSpanCaptureStrategy, setSegmentSpanCaptureStrategy } from './segmentSpanCaptureStrategy';\nimport type { SegmentSpanConverter } from './segmentSpanCaptureStrategy';\n\n// Spans already sent in a transaction, so a child ending after its segment can be emitted as its own\n// orphan transaction instead of being dropped or sent twice.\nconst CAPTURED_SPANS = new WeakSet<Span>();\nconst isSpanAlreadyCaptured = (span: Span): boolean => CAPTURED_SPANS.has(span);\nconst markSpanCaptured = (span: Span): void => {\n CAPTURED_SPANS.add(span);\n};\n\n// One debounced queue per client, drained on the client's `flush`/`close`. Mirrors the OpenTelemetry\n// span exporter, which holds one such buffer per instance, and the debounce window matches it. The\n// capturing client is resolved from the span's captured scope and bound when the span ends, not\n// re-resolved at drain time, so a deferred transaction lands on the client that created the span even if\n// the current client (or the captured scope's own client) is reassigned before the debounce fires.\nconst CLIENT_QUEUES = new WeakMap<Client, (capture: () => void) => void>();\n\n/**\n * @private Private API with no semver guarantees!\n *\n * Enable deferred segment-span transaction capture for a client: create its debounced queue and\n * register the strategy (idempotent).\n *\n * `SentrySpan` otherwise assembles the transaction synchronously the instant a segment span ends, which\n * drops children whose async instrumentation closes them later (a diagnostics-channel `asyncEnd`\n * callback in the same tick, or engine spans replayed on a later tick). The debounced snapshot delays\n * capture just enough for those later span ends to land first; a child that still ends after it is\n * emitted as its own orphan transaction. Pending captures drain on the client's `flush` hook, so\n * `Sentry.flush()` / `client.close()` cannot resolve before they run.\n */\nexport function _INTERNAL_setDeferSegmentSpanCapture(client: Client): void {\n if (!getSegmentSpanCaptureStrategy()) {\n setSegmentSpanCaptureStrategy(deferredSegmentSpanCaptureStrategy);\n }\n if (CLIENT_QUEUES.has(client)) {\n return;\n }\n\n const pendingCaptures = new Set<() => void>();\n const debouncedDrain = debounce(\n () => {\n const captures = [...pendingCaptures];\n pendingCaptures.clear();\n for (const capture of captures) {\n capture();\n }\n },\n 1,\n { maxWait: 100 },\n );\n\n client.on('flush', () => {\n debouncedDrain.flush();\n });\n\n CLIENT_QUEUES.set(client, capture => {\n pendingCaptures.add(capture);\n debouncedDrain();\n });\n}\n\nconst deferredSegmentSpanCaptureStrategy = {\n onSegmentSpanEnded(convert: SegmentSpanConverter, scope: Scope): void {\n const client = scope.getClient();\n const enqueue = client && CLIENT_QUEUES.get(client);\n if (!enqueue) {\n // The capturing client didn't enable deferral: capture synchronously.\n const transactionEvent = convert();\n if (transactionEvent) {\n client?.captureEvent(transactionEvent);\n }\n return;\n }\n\n enqueue(() => {\n const transactionEvent = convert({ isSpanAlreadyCaptured, onSpanCaptured: markSpanCaptured });\n if (transactionEvent) {\n client.captureEvent(transactionEvent);\n }\n });\n },\n\n onChildSpanEnded(span: Span, rootSpan: Span, convert: SegmentSpanConverter, scope: Scope): void {\n // Only a late child of an already-captured segment is an orphan. Inert under span streaming, where\n // `CAPTURED_SPANS` is never populated.\n if (CAPTURED_SPANS.has(span) || !CAPTURED_SPANS.has(rootSpan)) {\n return;\n }\n\n const client = scope.getClient();\n const enqueue = client && CLIENT_QUEUES.get(client);\n\n const captureOrphan = (): void => {\n const transactionEvent = convert({ isSpanAlreadyCaptured, onSpanCaptured: markSpanCaptured });\n if (transactionEvent?.contexts?.trace?.data) {\n // Tag orphans so they're distinguishable downstream (mirrors the OTel span exporter).\n transactionEvent.contexts.trace.data['sentry.parent_span_already_sent'] = true;\n }\n if (transactionEvent) {\n client?.captureEvent(transactionEvent);\n }\n };\n\n // Defer when the capturing client batches; otherwise emit now so the orphan isn't dropped.\n if (enqueue) {\n enqueue(captureOrphan);\n } else {\n captureOrphan();\n }\n },\n};\n"],"names":[],"mappings":";;;AASA,MAAM,cAAA,uBAAqB,OAAA,EAAc;AACzC,MAAM,qBAAA,GAAwB,CAAC,IAAA,KAAwB,cAAA,CAAe,IAAI,IAAI,CAAA;AAC9E,MAAM,gBAAA,GAAmB,CAAC,IAAA,KAAqB;AAC7C,EAAA,cAAA,CAAe,IAAI,IAAI,CAAA;AACzB,CAAA;AAOA,MAAM,aAAA,uBAAoB,OAAA,EAA+C;AAelE,SAAS,qCAAqC,MAAA,EAAsB;AACzE,EAAA,IAAI,CAAC,+BAA8B,EAAG;AACpC,IAAA,6BAAA,CAA8B,kCAAkC,CAAA;AAAA,EAClE;AACA,EAAA,IAAI,aAAA,CAAc,GAAA,CAAI,MAAM,CAAA,EAAG;AAC7B,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,eAAA,uBAAsB,GAAA,EAAgB;AAC5C,EAAA,MAAM,cAAA,GAAiB,QAAA;AAAA,IACrB,MAAM;AACJ,MAAA,MAAM,QAAA,GAAW,CAAC,GAAG,eAAe,CAAA;AACpC,MAAA,eAAA,CAAgB,KAAA,EAAM;AACtB,MAAA,KAAA,MAAW,WAAW,QAAA,EAAU;AAC9B,QAAA,OAAA,EAAQ;AAAA,MACV;AAAA,IACF,CAAA;AAAA,IACA,CAAA;AAAA,IAC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AU,aAAA,CAAc,GAAA,CAAI,MAAM,CAAA;AAElD,IAAA,MAAM,gBAAgB,MAAY;AAChC,MAAA,MAAM,mBAAmB,OAAA,CAAQ,EAAE,qBAAA,EAAuB,cAAA,EAAgB,kBAAkB,CAAA;AAC5F,MAAA,IAAI,gBAAA,EAAkB,QAAA,EAAU,KAAA,EAAO,IAAA,EAAM;AAE3C,QAAA,gBAAA,CAAiB,QAAA,CAAS,KAAA,CAAM,IAAA,CAAK,iCAAiC,CAAA,GAAI,IAAA;AAAA,MAC5E;AACA,MAAA,IAAI,gBAAA,EAAkB;AACpB,QAAA,MAAA,EAAQ,aAAa,gBAAgB,CAAA;AAAA,MACvC;AAAA,IACF,CAAA;AAGA,IAAA,IAAI,OAAA,EAAS;AACX,MAAA,OAAA,CAAQ,aAAa,CAAA;AAAA,IACvB,CAAA,MAAO;AACL,MAAA,aAAA,EAAc;AAAA,IAChB;AAAA,EACF;AACF,CAAA;;;;"} |
| import { getSentryCarrier, getMainCarrier } from '../carrier.js'; | ||
| function setSegmentSpanCaptureStrategy(strategy) { | ||
| getSentryCarrier(getMainCarrier()).segmentSpanCaptureStrategy = strategy; | ||
| } | ||
| function getSegmentSpanCaptureStrategy() { | ||
| return getSentryCarrier(getMainCarrier()).segmentSpanCaptureStrategy; | ||
| } | ||
| export { getSegmentSpanCaptureStrategy, setSegmentSpanCaptureStrategy }; | ||
| //# sourceMappingURL=segmentSpanCaptureStrategy.js.map |
| {"version":3,"file":"segmentSpanCaptureStrategy.js","sources":["../../../src/tracing/segmentSpanCaptureStrategy.ts"],"sourcesContent":["import { getMainCarrier, getSentryCarrier } from '../carrier';\nimport type { Scope } from '../scope';\nimport type { TransactionEvent } from '../types/event';\nimport type { Span } from '../types/span';\n\n/**\n * Callbacks the deferred-capture strategy hands to `_convertSpanToTransaction` when assembling a\n * transaction. The synchronous (browser) path calls the converter with no options, so neither runs.\n */\nexport interface SegmentSpanCaptureConvertOptions {\n /** Skip a descendant already sent in an earlier transaction, so it isn't sent twice. */\n isSpanAlreadyCaptured?: (span: Span) => boolean;\n /** Record each span included here, so a child that ends after the snapshot can be emitted as an orphan. */\n onSpanCaptured?: (span: Span) => void;\n}\n\nexport type SegmentSpanConverter = (options?: SegmentSpanCaptureConvertOptions) => TransactionEvent | undefined;\n\n/**\n * Assembles segment spans into transactions. Registered by SDKs that defer capture (see\n * `_INTERNAL_setDeferSegmentSpanCapture`); when unset, `SentrySpan` captures synchronously. Living\n * behind this seam tree-shakes the deferral machinery out of SDKs that never register one (e.g. browser).\n */\nexport interface SegmentSpanCaptureStrategy {\n /** Assemble and capture a segment (root or standalone-root) span's transaction through its captured scope. */\n onSegmentSpanEnded(convert: SegmentSpanConverter, scope: Scope): void;\n /** Consider a child that ended after its segment for emission as its own orphan transaction. */\n onChildSpanEnded(span: Span, rootSpan: Span, convert: SegmentSpanConverter, scope: Scope): void;\n}\n\n/**\n * @private Private API with no semver guarantees!\n *\n * Set the global segment-span capture strategy (or clear it with `undefined`).\n */\nexport function setSegmentSpanCaptureStrategy(strategy: SegmentSpanCaptureStrategy | undefined): void {\n getSentryCarrier(getMainCarrier()).segmentSpanCaptureStrategy = strategy;\n}\n\n/** Get the global segment-span capture strategy, or `undefined` when none is registered. */\nexport function getSegmentSpanCaptureStrategy(): SegmentSpanCaptureStrategy | undefined {\n return getSentryCarrier(getMainCarrier()).segmentSpanCaptureStrategy;\n}\n"],"names":[],"mappings":";;AAmCO,SAAS,8BAA8B,QAAA,EAAwD;AACpG,EAAA,gBAAA,CAAiB,cAAA,EAAgB,CAAA,CAAE,0BAAA,GAA6B,QAAA;AAClE;AAGO,SAAS,6BAAA,GAAwE;AACtF,EAAA,OAAO,gBAAA,CAAiB,cAAA,EAAgB,CAAA,CAAE,0BAAA;AAC5C;;;;"} |
| import { Client } from '../client'; | ||
| /** | ||
| * @private Private API with no semver guarantees! | ||
| * | ||
| * Enable deferred segment-span transaction capture for a client: create its debounced queue and | ||
| * register the strategy (idempotent). | ||
| * | ||
| * `SentrySpan` otherwise assembles the transaction synchronously the instant a segment span ends, which | ||
| * drops children whose async instrumentation closes them later (a diagnostics-channel `asyncEnd` | ||
| * callback in the same tick, or engine spans replayed on a later tick). The debounced snapshot delays | ||
| * capture just enough for those later span ends to land first; a child that still ends after it is | ||
| * emitted as its own orphan transaction. Pending captures drain on the client's `flush` hook, so | ||
| * `Sentry.flush()` / `client.close()` cannot resolve before they run. | ||
| */ | ||
| export declare function _INTERNAL_setDeferSegmentSpanCapture(client: Client): void; | ||
| //# sourceMappingURL=deferSegmentSpanCapture.d.ts.map |
| import { Scope } from '../scope'; | ||
| import { TransactionEvent } from '../types/event'; | ||
| import { Span } from '../types/span'; | ||
| /** | ||
| * Callbacks the deferred-capture strategy hands to `_convertSpanToTransaction` when assembling a | ||
| * transaction. The synchronous (browser) path calls the converter with no options, so neither runs. | ||
| */ | ||
| export interface SegmentSpanCaptureConvertOptions { | ||
| /** Skip a descendant already sent in an earlier transaction, so it isn't sent twice. */ | ||
| isSpanAlreadyCaptured?: (span: Span) => boolean; | ||
| /** Record each span included here, so a child that ends after the snapshot can be emitted as an orphan. */ | ||
| onSpanCaptured?: (span: Span) => void; | ||
| } | ||
| export type SegmentSpanConverter = (options?: SegmentSpanCaptureConvertOptions) => TransactionEvent | undefined; | ||
| /** | ||
| * Assembles segment spans into transactions. Registered by SDKs that defer capture (see | ||
| * `_INTERNAL_setDeferSegmentSpanCapture`); when unset, `SentrySpan` captures synchronously. Living | ||
| * behind this seam tree-shakes the deferral machinery out of SDKs that never register one (e.g. browser). | ||
| */ | ||
| export interface SegmentSpanCaptureStrategy { | ||
| /** Assemble and capture a segment (root or standalone-root) span's transaction through its captured scope. */ | ||
| onSegmentSpanEnded(convert: SegmentSpanConverter, scope: Scope): void; | ||
| /** Consider a child that ended after its segment for emission as its own orphan transaction. */ | ||
| onChildSpanEnded(span: Span, rootSpan: Span, convert: SegmentSpanConverter, scope: Scope): void; | ||
| } | ||
| /** | ||
| * @private Private API with no semver guarantees! | ||
| * | ||
| * Set the global segment-span capture strategy (or clear it with `undefined`). | ||
| */ | ||
| export declare function setSegmentSpanCaptureStrategy(strategy: SegmentSpanCaptureStrategy | undefined): void; | ||
| /** Get the global segment-span capture strategy, or `undefined` when none is registered. */ | ||
| export declare function getSegmentSpanCaptureStrategy(): SegmentSpanCaptureStrategy | undefined; | ||
| //# sourceMappingURL=segmentSpanCaptureStrategy.d.ts.map |
| import type { Client } from '../client'; | ||
| /** | ||
| * @private Private API with no semver guarantees! | ||
| * | ||
| * Enable deferred segment-span transaction capture for a client: create its debounced queue and | ||
| * register the strategy (idempotent). | ||
| * | ||
| * `SentrySpan` otherwise assembles the transaction synchronously the instant a segment span ends, which | ||
| * drops children whose async instrumentation closes them later (a diagnostics-channel `asyncEnd` | ||
| * callback in the same tick, or engine spans replayed on a later tick). The debounced snapshot delays | ||
| * capture just enough for those later span ends to land first; a child that still ends after it is | ||
| * emitted as its own orphan transaction. Pending captures drain on the client's `flush` hook, so | ||
| * `Sentry.flush()` / `client.close()` cannot resolve before they run. | ||
| */ | ||
| export declare function _INTERNAL_setDeferSegmentSpanCapture(client: Client): void; | ||
| //# sourceMappingURL=deferSegmentSpanCapture.d.ts.map |
| {"version":3,"file":"deferSegmentSpanCapture.d.ts","sourceRoot":"","sources":["../../../src/tracing/deferSegmentSpanCapture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAsBxC;;;;;;;;;;;;GAYG;AACH,wBAAgB,oCAAoC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CA6BzE"} |
| import type { Scope } from '../scope'; | ||
| import type { TransactionEvent } from '../types/event'; | ||
| import type { Span } from '../types/span'; | ||
| /** | ||
| * Callbacks the deferred-capture strategy hands to `_convertSpanToTransaction` when assembling a | ||
| * transaction. The synchronous (browser) path calls the converter with no options, so neither runs. | ||
| */ | ||
| export interface SegmentSpanCaptureConvertOptions { | ||
| /** Skip a descendant already sent in an earlier transaction, so it isn't sent twice. */ | ||
| isSpanAlreadyCaptured?: (span: Span) => boolean; | ||
| /** Record each span included here, so a child that ends after the snapshot can be emitted as an orphan. */ | ||
| onSpanCaptured?: (span: Span) => void; | ||
| } | ||
| export type SegmentSpanConverter = (options?: SegmentSpanCaptureConvertOptions) => TransactionEvent | undefined; | ||
| /** | ||
| * Assembles segment spans into transactions. Registered by SDKs that defer capture (see | ||
| * `_INTERNAL_setDeferSegmentSpanCapture`); when unset, `SentrySpan` captures synchronously. Living | ||
| * behind this seam tree-shakes the deferral machinery out of SDKs that never register one (e.g. browser). | ||
| */ | ||
| export interface SegmentSpanCaptureStrategy { | ||
| /** Assemble and capture a segment (root or standalone-root) span's transaction through its captured scope. */ | ||
| onSegmentSpanEnded(convert: SegmentSpanConverter, scope: Scope): void; | ||
| /** Consider a child that ended after its segment for emission as its own orphan transaction. */ | ||
| onChildSpanEnded(span: Span, rootSpan: Span, convert: SegmentSpanConverter, scope: Scope): void; | ||
| } | ||
| /** | ||
| * @private Private API with no semver guarantees! | ||
| * | ||
| * Set the global segment-span capture strategy (or clear it with `undefined`). | ||
| */ | ||
| export declare function setSegmentSpanCaptureStrategy(strategy: SegmentSpanCaptureStrategy | undefined): void; | ||
| /** Get the global segment-span capture strategy, or `undefined` when none is registered. */ | ||
| export declare function getSegmentSpanCaptureStrategy(): SegmentSpanCaptureStrategy | undefined; | ||
| //# sourceMappingURL=segmentSpanCaptureStrategy.d.ts.map |
| {"version":3,"file":"segmentSpanCaptureStrategy.d.ts","sourceRoot":"","sources":["../../../src/tracing/segmentSpanCaptureStrategy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C;;;GAGG;AACH,MAAM,WAAW,gCAAgC;IAC/C,wFAAwF;IACxF,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;IAChD,2GAA2G;IAC3G,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,CAAC,EAAE,gCAAgC,KAAK,gBAAgB,GAAG,SAAS,CAAC;AAEhH;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC,8GAA8G;IAC9G,kBAAkB,CAAC,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACtE,gGAAgG;IAChG,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACjG;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,0BAA0B,GAAG,SAAS,GAAG,IAAI,CAEpG;AAED,4FAA4F;AAC5F,wBAAgB,6BAA6B,IAAI,0BAA0B,GAAG,SAAS,CAEtF"} |
+50
-26
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const errors = require('./tracing/errors.js'); | ||
| const utils$2 = require('./tracing/utils.js'); | ||
| const utils$3 = require('./tracing/utils.js'); | ||
| const idleSpan = require('./tracing/idleSpan.js'); | ||
| const sentrySpan = require('./tracing/sentrySpan.js'); | ||
| const deferSegmentSpanCapture = require('./tracing/deferSegmentSpanCapture.js'); | ||
| const sentryNonRecordingSpan = require('./tracing/sentryNonRecordingSpan.js'); | ||
@@ -21,3 +22,3 @@ const spanstatus = require('./tracing/spanstatus.js'); | ||
| const defaultScopes = require('./defaultScopes.js'); | ||
| const index$2 = require('./asyncContext/index.js'); | ||
| const index$4 = require('./asyncContext/index.js'); | ||
| const tracingChannelBinding = require('./asyncContext/tracing-channel-binding.js'); | ||
@@ -89,17 +90,20 @@ const carrier = require('./carrier.js'); | ||
| const consola = require('./integrations/consola.js'); | ||
| const index = require('./tracing/vercel-ai/index.js'); | ||
| const utils$3 = require('./tracing/ai/utils.js'); | ||
| const index$2 = require('./tracing/vercel-ai/index.js'); | ||
| const utils$4 = require('./tracing/ai/utils.js'); | ||
| const genAiAttributes = require('./tracing/ai/gen-ai-attributes.js'); | ||
| const utils = require('./tracing/vercel-ai/utils.js'); | ||
| const constants$6 = require('./tracing/vercel-ai/constants.js'); | ||
| const index$6 = require('./tracing/openai/index.js'); | ||
| const index$1 = require('./tracing/openai/index.js'); | ||
| const utils$2 = require('./tracing/openai/utils.js'); | ||
| const streaming$1 = require('./tracing/openai/streaming.js'); | ||
| const constants$5 = require('./tracing/openai/constants.js'); | ||
| const index$3 = require('./tracing/anthropic-ai/index.js'); | ||
| const index = require('./tracing/anthropic-ai/index.js'); | ||
| const streaming = require('./tracing/anthropic-ai/streaming.js'); | ||
| const constants = require('./tracing/anthropic-ai/constants.js'); | ||
| const index$5 = require('./tracing/google-genai/index.js'); | ||
| const index$6 = require('./tracing/google-genai/index.js'); | ||
| const constants$2 = require('./tracing/google-genai/constants.js'); | ||
| const index$1 = require('./tracing/langchain/index.js'); | ||
| const index$3 = require('./tracing/langchain/index.js'); | ||
| const utils$1 = require('./tracing/langchain/utils.js'); | ||
| const constants$3 = require('./tracing/langchain/constants.js'); | ||
| const index$4 = require('./tracing/langgraph/index.js'); | ||
| const index$5 = require('./tracing/langgraph/index.js'); | ||
| const constants$4 = require('./tracing/langgraph/constants.js'); | ||
@@ -157,9 +161,14 @@ const spanBuffer = require('./tracing/spans/spanBuffer.js'); | ||
| exports.registerSpanErrorInstrumentation = errors.registerSpanErrorInstrumentation; | ||
| exports.getCapturedScopesOnSpan = utils$2.getCapturedScopesOnSpan; | ||
| exports.markSpanForOtelSourceInference = utils$2.markSpanForOtelSourceInference; | ||
| exports.setCapturedScopesOnSpan = utils$2.setCapturedScopesOnSpan; | ||
| exports.spanShouldInferOtelSource = utils$2.spanShouldInferOtelSource; | ||
| exports.getCapturedScopesOnSpan = utils$3.getCapturedScopesOnSpan; | ||
| exports.markSpanAsTracerProviderSpan = utils$3.markSpanAsTracerProviderSpan; | ||
| exports.markSpanForOtelSourceInference = utils$3.markSpanForOtelSourceInference; | ||
| exports.markSpanSourceAsExplicit = utils$3.markSpanSourceAsExplicit; | ||
| exports.setCapturedScopesOnSpan = utils$3.setCapturedScopesOnSpan; | ||
| exports.spanIsTracerProviderSpan = utils$3.spanIsTracerProviderSpan; | ||
| exports.spanShouldInferOtelSource = utils$3.spanShouldInferOtelSource; | ||
| exports.spanSourceWasExplicitlySet = utils$3.spanSourceWasExplicitlySet; | ||
| exports.TRACING_DEFAULTS = idleSpan.TRACING_DEFAULTS; | ||
| exports.startIdleSpan = idleSpan.startIdleSpan; | ||
| exports.SentrySpan = sentrySpan.SentrySpan; | ||
| exports._INTERNAL_setDeferSegmentSpanCapture = deferSegmentSpanCapture._INTERNAL_setDeferSegmentSpanCapture; | ||
| exports.SentryNonRecordingSpan = sentryNonRecordingSpan.SentryNonRecordingSpan; | ||
@@ -172,4 +181,6 @@ exports.SPAN_STATUS_ERROR = spanstatus.SPAN_STATUS_ERROR; | ||
| exports.SUPPRESS_TRACING_KEY = trace.SUPPRESS_TRACING_KEY; | ||
| exports._INTERNAL_startInactiveSpan = trace._INTERNAL_startInactiveSpan; | ||
| exports.continueTrace = trace.continueTrace; | ||
| exports.isTracingSuppressed = trace.isTracingSuppressed; | ||
| exports.spanIsIgnored = trace.spanIsIgnored; | ||
| exports.startInactiveSpan = trace.startInactiveSpan; | ||
@@ -261,4 +272,4 @@ exports.startNewTrace = trace.startNewTrace; | ||
| exports.getDefaultIsolationScope = defaultScopes.getDefaultIsolationScope; | ||
| exports.getAsyncContextStrategy = index$2.getAsyncContextStrategy; | ||
| exports.setAsyncContextStrategy = index$2.setAsyncContextStrategy; | ||
| exports.getAsyncContextStrategy = index$4.getAsyncContextStrategy; | ||
| exports.setAsyncContextStrategy = index$4.setAsyncContextStrategy; | ||
| exports._INTERNAL_createTracingChannelBinding = tracingChannelBinding._INTERNAL_createTracingChannelBinding; | ||
@@ -318,2 +329,3 @@ exports.waitForTracingChannelBinding = tracingChannelBinding.waitForTracingChannelBinding; | ||
| exports.spanIsSampled = spanUtils.spanIsSampled; | ||
| exports.spanIsSentrySpan = spanUtils.spanIsSentrySpan; | ||
| exports.spanTimeInputToSeconds = spanUtils.spanTimeInputToSeconds; | ||
@@ -381,7 +393,9 @@ exports.spanToJSON = spanUtils.spanToJSON; | ||
| exports.createConsolaReporter = consola.createConsolaReporter; | ||
| exports.addVercelAiProcessors = index.addVercelAiProcessors; | ||
| exports.getProviderMetadataAttributes = index.getProviderMetadataAttributes; | ||
| exports.getTruncatedJsonString = utils$3.getTruncatedJsonString; | ||
| exports.shouldEnableTruncation = utils$3.shouldEnableTruncation; | ||
| exports.addVercelAiProcessors = index$2.addVercelAiProcessors; | ||
| exports.getProviderMetadataAttributes = index$2.getProviderMetadataAttributes; | ||
| exports.getTruncatedJsonString = utils$4.getTruncatedJsonString; | ||
| exports.resolveAIRecordingOptions = utils$4.resolveAIRecordingOptions; | ||
| exports.shouldEnableTruncation = utils$4.shouldEnableTruncation; | ||
| exports.GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE = genAiAttributes.GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE; | ||
| exports.GEN_AI_REQUEST_MODEL_ATTRIBUTE = genAiAttributes.GEN_AI_REQUEST_MODEL_ATTRIBUTE; | ||
| exports.GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE = genAiAttributes.GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE; | ||
@@ -391,14 +405,24 @@ exports._INTERNAL_cleanupToolCallSpanContext = utils._INTERNAL_cleanupToolCallSpanContext; | ||
| exports._INTERNAL_toolCallSpanContextMap = constants$6.toolCallSpanContextMap; | ||
| exports.instrumentOpenAiClient = index$6.instrumentOpenAiClient; | ||
| exports.addOpenAiRequestAttributes = index$1.addRequestAttributes; | ||
| exports.extractOpenAiRequestAttributes = index$1.extractRequestAttributes; | ||
| exports.instrumentOpenAiClient = index$1.instrumentOpenAiClient; | ||
| exports.addOpenAiResponseAttributes = utils$2.addResponseAttributes; | ||
| exports.extractOpenAiRequestParameters = utils$2.extractRequestParameters; | ||
| exports.instrumentOpenAiStream = streaming$1.instrumentStream; | ||
| exports.OPENAI_INTEGRATION_NAME = constants$5.OPENAI_INTEGRATION_NAME; | ||
| exports.instrumentAnthropicAiClient = index$3.instrumentAnthropicAiClient; | ||
| exports.addAnthropicRequestAttributes = index.addPrivateRequestAttributes; | ||
| exports.addAnthropicResponseAttributes = index.addResponseAttributes; | ||
| exports.extractAnthropicRequestAttributes = index.extractRequestAttributes; | ||
| exports.instrumentAnthropicAiClient = index.instrumentAnthropicAiClient; | ||
| exports.instrumentAsyncIterableStream = streaming.instrumentAsyncIterableStream; | ||
| exports.instrumentMessageStream = streaming.instrumentMessageStream; | ||
| exports.ANTHROPIC_AI_INTEGRATION_NAME = constants.ANTHROPIC_AI_INTEGRATION_NAME; | ||
| exports.instrumentGoogleGenAIClient = index$5.instrumentGoogleGenAIClient; | ||
| exports.instrumentGoogleGenAIClient = index$6.instrumentGoogleGenAIClient; | ||
| exports.GOOGLE_GENAI_INTEGRATION_NAME = constants$2.GOOGLE_GENAI_INTEGRATION_NAME; | ||
| exports.createLangChainCallbackHandler = index$1.createLangChainCallbackHandler; | ||
| exports.createLangChainCallbackHandler = index$3.createLangChainCallbackHandler; | ||
| exports._INTERNAL_mergeLangChainCallbackHandler = utils$1._INTERNAL_mergeLangChainCallbackHandler; | ||
| exports.LANGCHAIN_INTEGRATION_NAME = constants$3.LANGCHAIN_INTEGRATION_NAME; | ||
| exports.instrumentCreateReactAgent = index$4.instrumentCreateReactAgent; | ||
| exports.instrumentLangGraph = index$4.instrumentLangGraph; | ||
| exports.instrumentStateGraphCompile = index$4.instrumentStateGraphCompile; | ||
| exports.instrumentCreateReactAgent = index$5.instrumentCreateReactAgent; | ||
| exports.instrumentLangGraph = index$5.instrumentLangGraph; | ||
| exports.instrumentStateGraphCompile = index$5.instrumentStateGraphCompile; | ||
| exports.LANGGRAPH_INTEGRATION_NAME = constants$4.LANGGRAPH_INTEGRATION_NAME; | ||
@@ -405,0 +429,0 @@ exports.SpanBuffer = spanBuffer.SpanBuffer; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"browser.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"browser.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"carrier.js","sources":["../../src/carrier.ts"],"sourcesContent":["import type { AsyncContextStack } from './asyncContext/stackStrategy';\nimport type { AsyncContextStrategy } from './asyncContext/types';\nimport type { Client } from './client';\nimport type { Scope } from './scope';\nimport type { SerializedLog } from './types/log';\nimport type { SerializedMetric } from './types/metric';\nimport { SDK_VERSION } from './utils/version';\nimport { GLOBAL_OBJ } from './utils/worldwide';\n\n/**\n * An object that contains globally accessible properties and maintains a scope stack.\n * @hidden\n */\nexport interface Carrier {\n __SENTRY__?: VersionedCarrier;\n}\n\ntype VersionedCarrier = {\n version?: string;\n} & Record<Exclude<string, 'version'>, SentryCarrier>;\n\nexport interface SentryCarrier {\n acs?: AsyncContextStrategy;\n stack?: AsyncContextStack;\n\n globalScope?: Scope;\n defaultIsolationScope?: Scope;\n defaultCurrentScope?: Scope;\n loggerSettings?: { enabled: boolean };\n /**\n * A map of Sentry clients to their log buffers.\n * This is used to store logs that are sent to Sentry.\n */\n clientToLogBufferMap?: WeakMap<Client, Array<SerializedLog>>;\n\n /**\n * A map of Sentry clients to their metric buffers.\n * This is used to store metrics that are sent to Sentry.\n */\n clientToMetricBufferMap?: WeakMap<Client, Array<SerializedMetric>>;\n\n /** Overwrites TextEncoder used in `@sentry/core`, need for `react-native@0.73` and older */\n encodePolyfill?: (input: string) => Uint8Array;\n /** Overwrites TextDecoder used in `@sentry/core`, need for `react-native@0.73` and older */\n decodePolyfill?: (input: Uint8Array) => string;\n}\n\n/**\n * Returns the global shim registry.\n *\n * FIXME: This function is problematic, because despite always returning a valid Carrier,\n * it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check\n * at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there.\n **/\nexport function getMainCarrier(): Carrier {\n // This ensures a Sentry carrier exists\n getSentryCarrier(GLOBAL_OBJ);\n return GLOBAL_OBJ;\n}\n\n/** Will either get the existing sentry carrier, or create a new one. */\nexport function getSentryCarrier(carrier: Carrier): SentryCarrier {\n const __SENTRY__ = (carrier.__SENTRY__ = carrier.__SENTRY__ || {});\n\n // For now: First SDK that sets the .version property wins\n __SENTRY__.version = __SENTRY__.version || SDK_VERSION;\n\n // Intentionally populating and returning the version of \"this\" SDK instance\n // rather than what's set in .version so that \"this\" SDK always gets its carrier\n return (__SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {});\n}\n\n/**\n * Returns a global singleton contained in the global `__SENTRY__[]` object.\n *\n * If the singleton doesn't already exist in `__SENTRY__`, it will be created using the given factory\n * function and added to the `__SENTRY__` object.\n *\n * @param name name of the global singleton on __SENTRY__\n * @param creator creator Factory function to create the singleton if it doesn't already exist on `__SENTRY__`\n * @param obj (Optional) The global object on which to look for `__SENTRY__`, if not `GLOBAL_OBJ`'s return value\n * @returns the singleton\n */\nexport function getGlobalSingleton<Prop extends keyof SentryCarrier>(\n name: Prop,\n creator: () => NonNullable<SentryCarrier[Prop]>,\n obj = GLOBAL_OBJ,\n): NonNullable<SentryCarrier[Prop]> {\n const __SENTRY__ = (obj.__SENTRY__ = obj.__SENTRY__ || {});\n const carrier = (__SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {});\n // Note: We do not want to set `carrier.version` here, as this may be called before any `init` is called, e.g. for the default scopes\n return carrier[name] || (carrier[name] = creator());\n}\n"],"names":["GLOBAL_OBJ","SDK_VERSION"],"mappings":";;;;;AAsDO,SAAS,cAAA,GAA0B;AAExC,EAAA,gBAAA,CAAiBA,oBAAU,CAAA;AAC3B,EAAA,OAAOA,oBAAA;AACT;AAGO,SAAS,iBAAiB,OAAA,EAAiC;AAChE,EAAA,MAAM,UAAA,GAAc,OAAA,CAAQ,UAAA,GAAa,OAAA,CAAQ,cAAc,EAAC;AAGhE,EAAA,UAAA,CAAW,OAAA,GAAU,WAAW,OAAA,IAAWC,mBAAA;AAI3C,EAAA,OAAQ,WAAWA,mBAAW,CAAA,GAAI,UAAA,CAAWA,mBAAW,KAAK,EAAC;AAChE;AAaO,SAAS,kBAAA,CACd,IAAA,EACA,OAAA,EACA,GAAA,GAAMD,oBAAA,EAC4B;AAClC,EAAA,MAAM,UAAA,GAAc,GAAA,CAAI,UAAA,GAAa,GAAA,CAAI,cAAc,EAAC;AACxD,EAAA,MAAM,UAAW,UAAA,CAAWC,mBAAW,IAAI,UAAA,CAAWA,mBAAW,KAAK,EAAC;AAEvE,EAAA,OAAO,QAAQ,IAAI,CAAA,KAAM,OAAA,CAAQ,IAAI,IAAI,OAAA,EAAQ,CAAA;AACnD;;;;;;"} | ||
| {"version":3,"file":"carrier.js","sources":["../../src/carrier.ts"],"sourcesContent":["import type { AsyncContextStack } from './asyncContext/stackStrategy';\nimport type { AsyncContextStrategy } from './asyncContext/types';\nimport type { Client } from './client';\nimport type { Scope } from './scope';\nimport type { SegmentSpanCaptureStrategy } from './tracing/segmentSpanCaptureStrategy';\nimport type { SerializedLog } from './types/log';\nimport type { SerializedMetric } from './types/metric';\nimport { SDK_VERSION } from './utils/version';\nimport { GLOBAL_OBJ } from './utils/worldwide';\n\n/**\n * An object that contains globally accessible properties and maintains a scope stack.\n * @hidden\n */\nexport interface Carrier {\n __SENTRY__?: VersionedCarrier;\n}\n\ntype VersionedCarrier = {\n version?: string;\n} & Record<Exclude<string, 'version'>, SentryCarrier>;\n\nexport interface SentryCarrier {\n acs?: AsyncContextStrategy;\n stack?: AsyncContextStack;\n\n globalScope?: Scope;\n defaultIsolationScope?: Scope;\n defaultCurrentScope?: Scope;\n loggerSettings?: { enabled: boolean };\n /**\n * A map of Sentry clients to their log buffers.\n * This is used to store logs that are sent to Sentry.\n */\n clientToLogBufferMap?: WeakMap<Client, Array<SerializedLog>>;\n\n /**\n * A map of Sentry clients to their metric buffers.\n * This is used to store metrics that are sent to Sentry.\n */\n clientToMetricBufferMap?: WeakMap<Client, Array<SerializedMetric>>;\n\n /** Strategy for assembling segment spans into transactions; set by SDKs that defer capture. */\n segmentSpanCaptureStrategy?: SegmentSpanCaptureStrategy;\n\n /** Overwrites TextEncoder used in `@sentry/core`, need for `react-native@0.73` and older */\n encodePolyfill?: (input: string) => Uint8Array;\n /** Overwrites TextDecoder used in `@sentry/core`, need for `react-native@0.73` and older */\n decodePolyfill?: (input: Uint8Array) => string;\n}\n\n/**\n * Returns the global shim registry.\n *\n * FIXME: This function is problematic, because despite always returning a valid Carrier,\n * it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check\n * at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there.\n **/\nexport function getMainCarrier(): Carrier {\n // This ensures a Sentry carrier exists\n getSentryCarrier(GLOBAL_OBJ);\n return GLOBAL_OBJ;\n}\n\n/** Will either get the existing sentry carrier, or create a new one. */\nexport function getSentryCarrier(carrier: Carrier): SentryCarrier {\n const __SENTRY__ = (carrier.__SENTRY__ = carrier.__SENTRY__ || {});\n\n // For now: First SDK that sets the .version property wins\n __SENTRY__.version = __SENTRY__.version || SDK_VERSION;\n\n // Intentionally populating and returning the version of \"this\" SDK instance\n // rather than what's set in .version so that \"this\" SDK always gets its carrier\n return (__SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {});\n}\n\n/**\n * Returns a global singleton contained in the global `__SENTRY__[]` object.\n *\n * If the singleton doesn't already exist in `__SENTRY__`, it will be created using the given factory\n * function and added to the `__SENTRY__` object.\n *\n * @param name name of the global singleton on __SENTRY__\n * @param creator creator Factory function to create the singleton if it doesn't already exist on `__SENTRY__`\n * @param obj (Optional) The global object on which to look for `__SENTRY__`, if not `GLOBAL_OBJ`'s return value\n * @returns the singleton\n */\nexport function getGlobalSingleton<Prop extends keyof SentryCarrier>(\n name: Prop,\n creator: () => NonNullable<SentryCarrier[Prop]>,\n obj = GLOBAL_OBJ,\n): NonNullable<SentryCarrier[Prop]> {\n const __SENTRY__ = (obj.__SENTRY__ = obj.__SENTRY__ || {});\n const carrier = (__SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {});\n // Note: We do not want to set `carrier.version` here, as this may be called before any `init` is called, e.g. for the default scopes\n return carrier[name] || (carrier[name] = creator());\n}\n"],"names":["GLOBAL_OBJ","SDK_VERSION"],"mappings":";;;;;AA0DO,SAAS,cAAA,GAA0B;AAExC,EAAA,gBAAA,CAAiBA,oBAAU,CAAA;AAC3B,EAAA,OAAOA,oBAAA;AACT;AAGO,SAAS,iBAAiB,OAAA,EAAiC;AAChE,EAAA,MAAM,UAAA,GAAc,OAAA,CAAQ,UAAA,GAAa,OAAA,CAAQ,cAAc,EAAC;AAGhE,EAAA,UAAA,CAAW,OAAA,GAAU,WAAW,OAAA,IAAWC,mBAAA;AAI3C,EAAA,OAAQ,WAAWA,mBAAW,CAAA,GAAI,UAAA,CAAWA,mBAAW,KAAK,EAAC;AAChE;AAaO,SAAS,kBAAA,CACd,IAAA,EACA,OAAA,EACA,GAAA,GAAMD,oBAAA,EAC4B;AAClC,EAAA,MAAM,UAAA,GAAc,GAAA,CAAI,UAAA,GAAa,GAAA,CAAI,cAAc,EAAC;AACxD,EAAA,MAAM,UAAW,UAAA,CAAWC,mBAAW,IAAI,UAAA,CAAWA,mBAAW,KAAK,EAAC;AAEvE,EAAA,OAAO,QAAQ,IAAI,CAAA,KAAM,OAAA,CAAQ,IAAI,IAAI,OAAA,EAAQ,CAAA;AACnD;;;;;;"} |
+54
-30
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const errors = require('./tracing/errors.js'); | ||
| const utils$2 = require('./tracing/utils.js'); | ||
| const utils$3 = require('./tracing/utils.js'); | ||
| const idleSpan = require('./tracing/idleSpan.js'); | ||
| const sentrySpan = require('./tracing/sentrySpan.js'); | ||
| const deferSegmentSpanCapture = require('./tracing/deferSegmentSpanCapture.js'); | ||
| const sentryNonRecordingSpan = require('./tracing/sentryNonRecordingSpan.js'); | ||
@@ -21,3 +22,3 @@ const spanstatus = require('./tracing/spanstatus.js'); | ||
| const defaultScopes = require('./defaultScopes.js'); | ||
| const index$3 = require('./asyncContext/index.js'); | ||
| const index$5 = require('./asyncContext/index.js'); | ||
| const tracingChannelBinding = require('./asyncContext/tracing-channel-binding.js'); | ||
@@ -89,17 +90,20 @@ const carrier = require('./carrier.js'); | ||
| const consola = require('./integrations/consola.js'); | ||
| const index = require('./tracing/vercel-ai/index.js'); | ||
| const utils$3 = require('./tracing/ai/utils.js'); | ||
| const index$2 = require('./tracing/vercel-ai/index.js'); | ||
| const utils$4 = require('./tracing/ai/utils.js'); | ||
| const genAiAttributes = require('./tracing/ai/gen-ai-attributes.js'); | ||
| const utils = require('./tracing/vercel-ai/utils.js'); | ||
| const constants$7 = require('./tracing/vercel-ai/constants.js'); | ||
| const index$7 = require('./tracing/openai/index.js'); | ||
| const index$1 = require('./tracing/openai/index.js'); | ||
| const utils$2 = require('./tracing/openai/utils.js'); | ||
| const streaming$1 = require('./tracing/openai/streaming.js'); | ||
| const constants$6 = require('./tracing/openai/constants.js'); | ||
| const index$4 = require('./tracing/anthropic-ai/index.js'); | ||
| const index = require('./tracing/anthropic-ai/index.js'); | ||
| const streaming = require('./tracing/anthropic-ai/streaming.js'); | ||
| const constants = require('./tracing/anthropic-ai/constants.js'); | ||
| const index$6 = require('./tracing/google-genai/index.js'); | ||
| const index$7 = require('./tracing/google-genai/index.js'); | ||
| const constants$2 = require('./tracing/google-genai/constants.js'); | ||
| const index$1 = require('./tracing/langchain/index.js'); | ||
| const index$3 = require('./tracing/langchain/index.js'); | ||
| const utils$1 = require('./tracing/langchain/utils.js'); | ||
| const constants$4 = require('./tracing/langchain/constants.js'); | ||
| const index$5 = require('./tracing/langgraph/index.js'); | ||
| const index$6 = require('./tracing/langgraph/index.js'); | ||
| const constants$5 = require('./tracing/langgraph/constants.js'); | ||
@@ -160,3 +164,3 @@ const spanBuffer = require('./tracing/spans/spanBuffer.js'); | ||
| const timer = require('./utils/timer.js'); | ||
| const index$2 = require('./integrations/express/index.js'); | ||
| const index$4 = require('./integrations/express/index.js'); | ||
| const postgresjs = require('./integrations/postgresjs.js'); | ||
@@ -177,9 +181,14 @@ const sql = require('./utils/sql.js'); | ||
| exports.registerSpanErrorInstrumentation = errors.registerSpanErrorInstrumentation; | ||
| exports.getCapturedScopesOnSpan = utils$2.getCapturedScopesOnSpan; | ||
| exports.markSpanForOtelSourceInference = utils$2.markSpanForOtelSourceInference; | ||
| exports.setCapturedScopesOnSpan = utils$2.setCapturedScopesOnSpan; | ||
| exports.spanShouldInferOtelSource = utils$2.spanShouldInferOtelSource; | ||
| exports.getCapturedScopesOnSpan = utils$3.getCapturedScopesOnSpan; | ||
| exports.markSpanAsTracerProviderSpan = utils$3.markSpanAsTracerProviderSpan; | ||
| exports.markSpanForOtelSourceInference = utils$3.markSpanForOtelSourceInference; | ||
| exports.markSpanSourceAsExplicit = utils$3.markSpanSourceAsExplicit; | ||
| exports.setCapturedScopesOnSpan = utils$3.setCapturedScopesOnSpan; | ||
| exports.spanIsTracerProviderSpan = utils$3.spanIsTracerProviderSpan; | ||
| exports.spanShouldInferOtelSource = utils$3.spanShouldInferOtelSource; | ||
| exports.spanSourceWasExplicitlySet = utils$3.spanSourceWasExplicitlySet; | ||
| exports.TRACING_DEFAULTS = idleSpan.TRACING_DEFAULTS; | ||
| exports.startIdleSpan = idleSpan.startIdleSpan; | ||
| exports.SentrySpan = sentrySpan.SentrySpan; | ||
| exports._INTERNAL_setDeferSegmentSpanCapture = deferSegmentSpanCapture._INTERNAL_setDeferSegmentSpanCapture; | ||
| exports.SentryNonRecordingSpan = sentryNonRecordingSpan.SentryNonRecordingSpan; | ||
@@ -192,4 +201,6 @@ exports.SPAN_STATUS_ERROR = spanstatus.SPAN_STATUS_ERROR; | ||
| exports.SUPPRESS_TRACING_KEY = trace.SUPPRESS_TRACING_KEY; | ||
| exports._INTERNAL_startInactiveSpan = trace._INTERNAL_startInactiveSpan; | ||
| exports.continueTrace = trace.continueTrace; | ||
| exports.isTracingSuppressed = trace.isTracingSuppressed; | ||
| exports.spanIsIgnored = trace.spanIsIgnored; | ||
| exports.startInactiveSpan = trace.startInactiveSpan; | ||
@@ -281,4 +292,4 @@ exports.startNewTrace = trace.startNewTrace; | ||
| exports.getDefaultIsolationScope = defaultScopes.getDefaultIsolationScope; | ||
| exports.getAsyncContextStrategy = index$3.getAsyncContextStrategy; | ||
| exports.setAsyncContextStrategy = index$3.setAsyncContextStrategy; | ||
| exports.getAsyncContextStrategy = index$5.getAsyncContextStrategy; | ||
| exports.setAsyncContextStrategy = index$5.setAsyncContextStrategy; | ||
| exports._INTERNAL_createTracingChannelBinding = tracingChannelBinding._INTERNAL_createTracingChannelBinding; | ||
@@ -338,2 +349,3 @@ exports.waitForTracingChannelBinding = tracingChannelBinding.waitForTracingChannelBinding; | ||
| exports.spanIsSampled = spanUtils.spanIsSampled; | ||
| exports.spanIsSentrySpan = spanUtils.spanIsSentrySpan; | ||
| exports.spanTimeInputToSeconds = spanUtils.spanTimeInputToSeconds; | ||
@@ -401,7 +413,9 @@ exports.spanToJSON = spanUtils.spanToJSON; | ||
| exports.createConsolaReporter = consola.createConsolaReporter; | ||
| exports.addVercelAiProcessors = index.addVercelAiProcessors; | ||
| exports.getProviderMetadataAttributes = index.getProviderMetadataAttributes; | ||
| exports.getTruncatedJsonString = utils$3.getTruncatedJsonString; | ||
| exports.shouldEnableTruncation = utils$3.shouldEnableTruncation; | ||
| exports.addVercelAiProcessors = index$2.addVercelAiProcessors; | ||
| exports.getProviderMetadataAttributes = index$2.getProviderMetadataAttributes; | ||
| exports.getTruncatedJsonString = utils$4.getTruncatedJsonString; | ||
| exports.resolveAIRecordingOptions = utils$4.resolveAIRecordingOptions; | ||
| exports.shouldEnableTruncation = utils$4.shouldEnableTruncation; | ||
| exports.GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE = genAiAttributes.GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE; | ||
| exports.GEN_AI_REQUEST_MODEL_ATTRIBUTE = genAiAttributes.GEN_AI_REQUEST_MODEL_ATTRIBUTE; | ||
| exports.GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE = genAiAttributes.GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE; | ||
@@ -411,14 +425,24 @@ exports._INTERNAL_cleanupToolCallSpanContext = utils._INTERNAL_cleanupToolCallSpanContext; | ||
| exports._INTERNAL_toolCallSpanContextMap = constants$7.toolCallSpanContextMap; | ||
| exports.instrumentOpenAiClient = index$7.instrumentOpenAiClient; | ||
| exports.addOpenAiRequestAttributes = index$1.addRequestAttributes; | ||
| exports.extractOpenAiRequestAttributes = index$1.extractRequestAttributes; | ||
| exports.instrumentOpenAiClient = index$1.instrumentOpenAiClient; | ||
| exports.addOpenAiResponseAttributes = utils$2.addResponseAttributes; | ||
| exports.extractOpenAiRequestParameters = utils$2.extractRequestParameters; | ||
| exports.instrumentOpenAiStream = streaming$1.instrumentStream; | ||
| exports.OPENAI_INTEGRATION_NAME = constants$6.OPENAI_INTEGRATION_NAME; | ||
| exports.instrumentAnthropicAiClient = index$4.instrumentAnthropicAiClient; | ||
| exports.addAnthropicRequestAttributes = index.addPrivateRequestAttributes; | ||
| exports.addAnthropicResponseAttributes = index.addResponseAttributes; | ||
| exports.extractAnthropicRequestAttributes = index.extractRequestAttributes; | ||
| exports.instrumentAnthropicAiClient = index.instrumentAnthropicAiClient; | ||
| exports.instrumentAsyncIterableStream = streaming.instrumentAsyncIterableStream; | ||
| exports.instrumentMessageStream = streaming.instrumentMessageStream; | ||
| exports.ANTHROPIC_AI_INTEGRATION_NAME = constants.ANTHROPIC_AI_INTEGRATION_NAME; | ||
| exports.instrumentGoogleGenAIClient = index$6.instrumentGoogleGenAIClient; | ||
| exports.instrumentGoogleGenAIClient = index$7.instrumentGoogleGenAIClient; | ||
| exports.GOOGLE_GENAI_INTEGRATION_NAME = constants$2.GOOGLE_GENAI_INTEGRATION_NAME; | ||
| exports.createLangChainCallbackHandler = index$1.createLangChainCallbackHandler; | ||
| exports.createLangChainCallbackHandler = index$3.createLangChainCallbackHandler; | ||
| exports._INTERNAL_mergeLangChainCallbackHandler = utils$1._INTERNAL_mergeLangChainCallbackHandler; | ||
| exports.LANGCHAIN_INTEGRATION_NAME = constants$4.LANGCHAIN_INTEGRATION_NAME; | ||
| exports.instrumentCreateReactAgent = index$5.instrumentCreateReactAgent; | ||
| exports.instrumentLangGraph = index$5.instrumentLangGraph; | ||
| exports.instrumentStateGraphCompile = index$5.instrumentStateGraphCompile; | ||
| exports.instrumentCreateReactAgent = index$6.instrumentCreateReactAgent; | ||
| exports.instrumentLangGraph = index$6.instrumentLangGraph; | ||
| exports.instrumentStateGraphCompile = index$6.instrumentStateGraphCompile; | ||
| exports.LANGGRAPH_INTEGRATION_NAME = constants$5.LANGGRAPH_INTEGRATION_NAME; | ||
@@ -599,5 +623,5 @@ exports.SpanBuffer = spanBuffer.SpanBuffer; | ||
| exports._INTERNAL_safeUnref = timer.safeUnref; | ||
| exports.expressErrorHandler = index$2.expressErrorHandler; | ||
| exports.patchExpressModule = index$2.patchExpressModule; | ||
| exports.setupExpressErrorHandler = index$2.setupExpressErrorHandler; | ||
| exports.expressErrorHandler = index$4.expressErrorHandler; | ||
| exports.patchExpressModule = index$4.patchExpressModule; | ||
| exports.setupExpressErrorHandler = index$4.setupExpressErrorHandler; | ||
| exports._INTERNAL_sanitizeSqlQuery = postgresjs._sanitizeSqlQuery; | ||
@@ -604,0 +628,0 @@ exports.instrumentPostgresJsSql = postgresjs.instrumentPostgresJsSql; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"growthbook.js","sources":["../../../../src/integrations/featureFlags/growthbook.ts"],"sourcesContent":["import type { Client } from '../../client';\nimport { defineIntegration } from '../../integration';\nimport type { Event, EventHint } from '../../types/event';\nimport type { IntegrationFn } from '../../types/integration';\nimport {\n _INTERNAL_addFeatureFlagToActiveSpan,\n _INTERNAL_copyFlagsFromScopeToEvent,\n _INTERNAL_insertFlagToScope,\n} from '../../utils/featureFlags';\nimport { fill } from '../../utils/object';\n\ninterface GrowthBookLike {\n isOn(this: GrowthBookLike, featureKey: string, ...rest: unknown[]): boolean;\n getFeatureValue(this: GrowthBookLike, featureKey: string, defaultValue: unknown, ...rest: unknown[]): unknown;\n}\n\nexport type GrowthBookClassLike = new (...args: unknown[]) => GrowthBookLike;\n\n/**\n * Sentry integration for capturing feature flag evaluations from GrowthBook.\n *\n * Only boolean results are captured at this time.\n *\n * @example\n * ```typescript\n * import { GrowthBook } from '@growthbook/growthbook';\n * import * as Sentry from '@sentry/browser'; // or '@sentry/node'\n *\n * Sentry.init({\n * dsn: 'your-dsn',\n * integrations: [\n * Sentry.growthbookIntegration({ growthbookClass: GrowthBook })\n * ]\n * });\n * ```\n */\nexport const growthbookIntegration: IntegrationFn = defineIntegration(\n ({ growthbookClass }: { growthbookClass: GrowthBookClassLike }) => {\n return {\n name: 'GrowthBook' as const,\n\n setupOnce() {\n const proto = growthbookClass.prototype as GrowthBookLike;\n\n // Type guard and wrap isOn\n if (typeof proto.isOn === 'function') {\n fill(proto, 'isOn', _wrapAndCaptureBooleanResult);\n }\n\n // Type guard and wrap getFeatureValue\n if (typeof proto.getFeatureValue === 'function') {\n fill(proto, 'getFeatureValue', _wrapAndCaptureBooleanResult);\n }\n },\n\n processEvent(event: Event, _hint: EventHint, _client: Client): Event {\n return _INTERNAL_copyFlagsFromScopeToEvent(event);\n },\n };\n },\n);\n\nfunction _wrapAndCaptureBooleanResult(\n original: (this: GrowthBookLike, ...args: unknown[]) => unknown,\n): (this: GrowthBookLike, ...args: unknown[]) => unknown {\n return function (this: GrowthBookLike, ...args: unknown[]): unknown {\n const flagName = args[0];\n const result = original.apply(this, args);\n\n if (typeof flagName === 'string' && typeof result === 'boolean') {\n _INTERNAL_insertFlagToScope(flagName, result);\n _INTERNAL_addFeatureFlagToActiveSpan(flagName, result);\n }\n\n return result;\n };\n}\n"],"names":["defineIntegration","fill","_INTERNAL_copyFlagsFromScopeToEvent","_INTERNAL_insertFlagToScope","_INTERNAL_addFeatureFlagToActiveSpan"],"mappings":";;;;;;AAoCO,MAAM,qBAAA,GAAuCA,6BAAA;AAAA,EAClD,CAAC,EAAE,eAAA,EAAgB,KAAgD;AACjE,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,YAAA;AAAA,MAEN,SAAA,GAAY;AACV,QAAA,MAAM,QAAQ,eAAA,CAAgB,SAAA;AAG9B,QAAA,IAAI,OAAO,KAAA,CAAM,IAAA,KAAS,UAAA,EAAY;AACpC,UAAAC,WAAA,CAAK,KAAA,EAAO,QAAQ,4BAA4B,CAAA;AAAA,QAClD;AAGA,QAAA,IAAI,OAAO,KAAA,CAAM,eAAA,KAAoB,UAAA,EAAY;AAC/C,UAAAA,WAAA,CAAK,KAAA,EAAO,mBAAmB,4BAA4B,CAAA;AAAA,QAC7D;AAAA,MACF,CAAA;AAAA,MAEA,YAAA,CAAa,KAAA,EAAc,KAAA,EAAkB,OAAA,EAAwB;AACnE,QAAA,OAAOC,iDAAoC,KAAK,CAAA;AAAA,MAClD;AAAA,KACF;AAAA,EACF;AACF;AAEA,SAAS,6BACP,QAAA,EACuD;AACvD,EAAA,OAAO,YAAmC,IAAA,EAA0B;AAClE,IAAA,MAAM,QAAA,GAAW,KAAK,CAAC,CAAA;AACvB,IAAA,MAAM,MAAA,GAAS,QAAA,CAAS,KAAA,CAAM,IAAA,EAAM,IAAI,CAAA;AAExC,IAAA,IAAI,OAAO,QAAA,KAAa,QAAA,IAAY,OAAO,WAAW,SAAA,EAAW;AAC/D,MAAAC,wCAAA,CAA4B,UAAU,MAAM,CAAA;AAC5C,MAAAC,iDAAA,CAAqC,UAAU,MAAM,CAAA;AAAA,IACvD;AAEA,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AACF;;;;"} | ||
| {"version":3,"file":"growthbook.js","sources":["../../../../src/integrations/featureFlags/growthbook.ts"],"sourcesContent":["import type { Client } from '../../client';\nimport { defineIntegration } from '../../integration';\nimport type { Event, EventHint } from '../../types/event';\nimport type { IntegrationFn } from '../../types/integration';\nimport {\n _INTERNAL_addFeatureFlagToActiveSpan,\n _INTERNAL_copyFlagsFromScopeToEvent,\n _INTERNAL_insertFlagToScope,\n} from '../../utils/featureFlags';\nimport { fill } from '../../utils/object';\n\ninterface GrowthBookLike {\n isOn(this: GrowthBookLike, featureKey: string, ...rest: unknown[]): boolean;\n getFeatureValue(this: GrowthBookLike, featureKey: string, defaultValue: unknown, ...rest: unknown[]): unknown;\n}\n\n// `unknown[]` is contravariantly incompatible with real constructors (e.g. GrowthBook's), so use `any[]`.\n// oxlint-disable-next-line typescript-eslint/no-explicit-any\nexport type GrowthBookClassLike = new (...args: any[]) => GrowthBookLike;\n\n/**\n * Sentry integration for capturing feature flag evaluations from GrowthBook.\n *\n * Only boolean results are captured at this time.\n *\n * @example\n * ```typescript\n * import { GrowthBook } from '@growthbook/growthbook';\n * import * as Sentry from '@sentry/browser'; // or '@sentry/node'\n *\n * Sentry.init({\n * dsn: 'your-dsn',\n * integrations: [\n * Sentry.growthbookIntegration({ growthbookClass: GrowthBook })\n * ]\n * });\n * ```\n */\nexport const growthbookIntegration: IntegrationFn = defineIntegration(\n ({ growthbookClass }: { growthbookClass: GrowthBookClassLike }) => {\n return {\n name: 'GrowthBook' as const,\n\n setupOnce() {\n const proto = growthbookClass.prototype as GrowthBookLike;\n\n // Type guard and wrap isOn\n if (typeof proto.isOn === 'function') {\n fill(proto, 'isOn', _wrapAndCaptureBooleanResult);\n }\n\n // Type guard and wrap getFeatureValue\n if (typeof proto.getFeatureValue === 'function') {\n fill(proto, 'getFeatureValue', _wrapAndCaptureBooleanResult);\n }\n },\n\n processEvent(event: Event, _hint: EventHint, _client: Client): Event {\n return _INTERNAL_copyFlagsFromScopeToEvent(event);\n },\n };\n },\n);\n\nfunction _wrapAndCaptureBooleanResult(\n original: (this: GrowthBookLike, ...args: unknown[]) => unknown,\n): (this: GrowthBookLike, ...args: unknown[]) => unknown {\n return function (this: GrowthBookLike, ...args: unknown[]): unknown {\n const flagName = args[0];\n const result = original.apply(this, args);\n\n if (typeof flagName === 'string' && typeof result === 'boolean') {\n _INTERNAL_insertFlagToScope(flagName, result);\n _INTERNAL_addFeatureFlagToActiveSpan(flagName, result);\n }\n\n return result;\n };\n}\n"],"names":["defineIntegration","fill","_INTERNAL_copyFlagsFromScopeToEvent","_INTERNAL_insertFlagToScope","_INTERNAL_addFeatureFlagToActiveSpan"],"mappings":";;;;;;AAsCO,MAAM,qBAAA,GAAuCA,6BAAA;AAAA,EAClD,CAAC,EAAE,eAAA,EAAgB,KAAgD;AACjE,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,YAAA;AAAA,MAEN,SAAA,GAAY;AACV,QAAA,MAAM,QAAQ,eAAA,CAAgB,SAAA;AAG9B,QAAA,IAAI,OAAO,KAAA,CAAM,IAAA,KAAS,UAAA,EAAY;AACpC,UAAAC,WAAA,CAAK,KAAA,EAAO,QAAQ,4BAA4B,CAAA;AAAA,QAClD;AAGA,QAAA,IAAI,OAAO,KAAA,CAAM,eAAA,KAAoB,UAAA,EAAY;AAC/C,UAAAA,WAAA,CAAK,KAAA,EAAO,mBAAmB,4BAA4B,CAAA;AAAA,QAC7D;AAAA,MACF,CAAA;AAAA,MAEA,YAAA,CAAa,KAAA,EAAc,KAAA,EAAkB,OAAA,EAAwB;AACnE,QAAA,OAAOC,iDAAoC,KAAK,CAAA;AAAA,MAClD;AAAA,KACF;AAAA,EACF;AACF;AAEA,SAAS,6BACP,QAAA,EACuD;AACvD,EAAA,OAAO,YAAmC,IAAA,EAA0B;AAClE,IAAA,MAAM,QAAA,GAAW,KAAK,CAAC,CAAA;AACvB,IAAA,MAAM,MAAA,GAAS,QAAA,CAAS,KAAA,CAAM,IAAA,EAAM,IAAI,CAAA;AAExC,IAAA,IAAI,OAAO,QAAA,KAAa,QAAA,IAAY,OAAO,WAAW,SAAA,EAAW;AAC/D,MAAAC,wCAAA,CAA4B,UAAU,MAAM,CAAA;AAC5C,MAAAC,iDAAA,CAAqC,UAAU,MAAM,CAAA;AAAA,IACvD;AAEA,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AACF;;;;"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"semanticAttributes.js","sources":["../../src/semanticAttributes.ts"],"sourcesContent":["/**\n * Use this attribute to represent the source of a span name.\n * Must be one of: custom, url, route, view, component, task\n * TODO(v11): rename this to sentry.span.source'\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = 'sentry.source';\n\n/**\n * Attributes that holds the sample rate that was locally applied to a span.\n * If this attribute is not defined, it means that the span inherited a sampling decision.\n *\n * NOTE: Is only defined on root spans.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = 'sentry.sample_rate';\n\n/**\n * Attribute holding the sample rate of the previous trace.\n * This is used to sample consistently across subsequent traces in the browser SDK.\n *\n * Note: Only defined on root spans, if opted into consistent sampling\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE = 'sentry.previous_trace_sample_rate';\n\n/**\n * Use this attribute to represent the operation of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_OP = 'sentry.op';\n\n/**\n * Use this attribute to represent the origin of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = 'sentry.origin';\n\n/**\n * Holds the human-readable span status message (e.g. set via\n * `span.setStatus({ code, message })`).\n *\n * Streamed (v2) span statuses are reduced to `ok`/`error`, so we preserve the\n * message as an attribute instead of dropping it. This mirrors the attribute\n * Sentry's OTLP ingestion uses for the same purpose.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE = 'sentry.status.message';\n\n/** The reason why an idle span finished. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON = 'sentry.idle_span_finish_reason';\n\n/** The unit of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT = 'sentry.measurement_unit';\n\n/** The value of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE = 'sentry.measurement_value';\n\n/** The release version of the application */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = 'sentry.release';\n/** The environment name (e.g., \"production\", \"staging\", \"development\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = 'sentry.environment';\n/** The segment name (e.g., \"GET /users\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME = 'sentry.segment.name';\n/** The id of the segment that this span belongs to. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID = 'sentry.segment.id';\n/** The name of the Sentry SDK (e.g., \"sentry.php\", \"sentry.javascript\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = 'sentry.sdk.name';\n/** The version of the Sentry SDK */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = 'sentry.sdk.version';\n/** The list of integrations enabled in the Sentry SDK (e.g., [\"InboundFilters\", \"BrowserTracing\"]) */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS = 'sentry.sdk.integrations';\n\n/** The user ID */\nexport const SEMANTIC_ATTRIBUTE_USER_ID = 'user.id';\n/** The user email */\nexport const SEMANTIC_ATTRIBUTE_USER_EMAIL = 'user.email';\n/** The user IP address */\nexport const SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = 'user.ip_address';\n/** The user username */\nexport const SEMANTIC_ATTRIBUTE_USER_USERNAME = 'user.name';\n\n/**\n * A custom span name set by users guaranteed to be taken over any automatically\n * inferred name. This attribute is removed before the span is sent.\n *\n * @internal only meant for internal SDK usage\n * @hidden\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME = 'sentry.custom_span_name';\n\n/**\n * The id of the profile that this span occurred in.\n */\nexport const SEMANTIC_ATTRIBUTE_PROFILE_ID = 'sentry.profile_id';\n\nexport const SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = 'sentry.exclusive_time';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_HIT = 'cache.hit';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_KEY = 'cache.key';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = 'cache.item_size';\n\n/** TODO: Remove these once we update to latest semantic conventions */\nexport const SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = 'http.request.method';\nexport const SEMANTIC_ATTRIBUTE_URL_FULL = 'url.full';\n\n/**\n * A span link attribute to mark the link as a special span link.\n *\n * Known values:\n * - `previous_trace`: The span links to the frontend root span of the previous trace.\n * - `next_trace`: The span links to the frontend root span of the next trace. (Not set by the SDK)\n *\n * Other values may be set as appropriate.\n * @see https://develop.sentry.dev/sdk/telemetry/traces/span-links/#link-types\n */\nexport const SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = 'sentry.link.type';\n\n/**\n * =============================================================================\n * GEN AI ATTRIBUTES\n * Based on OpenTelemetry Semantic Conventions for Generative AI\n * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/\n * =============================================================================\n */\n\n/**\n * The conversation ID for linking messages across API calls.\n * For OpenAI Assistants API: thread_id\n * For LangGraph: configurable.thread_id\n */\nexport const GEN_AI_CONVERSATION_ID_ATTRIBUTE = 'gen_ai.conversation.id';\n"],"names":[],"mappings":";;AAKO,MAAM,gCAAA,GAAmC;AAQzC,MAAM,qCAAA,GAAwC;AAQ9C,MAAM,oDAAA,GAAuD;AAK7D,MAAM,4BAAA,GAA+B;AAKrC,MAAM,gCAAA,GAAmC;AAUzC,MAAM,wCAAA,GAA2C;AAGjD,MAAM,iDAAA,GAAoD;AAG1D,MAAM,0CAAA,GAA6C;AAGnD,MAAM,2CAAA,GAA8C;AAGpD,MAAM,iCAAA,GAAoC;AAE1C,MAAM,qCAAA,GAAwC;AAE9C,MAAM,sCAAA,GAAyC;AAE/C,MAAM,oCAAA,GAAuC;AAE7C,MAAM,kCAAA,GAAqC;AAE3C,MAAM,qCAAA,GAAwC;AAE9C,MAAM,0CAAA,GAA6C;AAGnD,MAAM,0BAAA,GAA6B;AAEnC,MAAM,6BAAA,GAAgC;AAEtC,MAAM,kCAAA,GAAqC;AAE3C,MAAM,gCAAA,GAAmC;AASzC,MAAM,0CAAA,GAA6C;AAKnD,MAAM,6BAAA,GAAgC;AAEtC,MAAM,iCAAA,GAAoC;AAE1C,MAAM,4BAAA,GAA+B;AAErC,MAAM,4BAAA,GAA+B;AAErC,MAAM,kCAAA,GAAqC;AAG3C,MAAM,sCAAA,GAAyC;AAC/C,MAAM,2BAAA,GAA8B;AAYpC,MAAM,iCAAA,GAAoC;AAe1C,MAAM,gCAAA,GAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"semanticAttributes.js","sources":["../../src/semanticAttributes.ts"],"sourcesContent":["/**\n * Use this attribute to represent the source of a span name.\n * Must be one of: custom, url, route, view, component, task\n * TODO(v11): remove this export\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = 'sentry.source';\n\n/**\n * Attributes that holds the sample rate that was locally applied to a span.\n * If this attribute is not defined, it means that the span inherited a sampling decision.\n *\n * NOTE: Is only defined on root spans.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = 'sentry.sample_rate';\n\n/**\n * Attribute holding the sample rate of the previous trace.\n * This is used to sample consistently across subsequent traces in the browser SDK.\n *\n * Note: Only defined on root spans, if opted into consistent sampling\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE = 'sentry.previous_trace_sample_rate';\n\n/**\n * Use this attribute to represent the operation of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_OP = 'sentry.op';\n\n/**\n * Use this attribute to represent the origin of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = 'sentry.origin';\n\n/**\n * Holds the human-readable span status message (e.g. set via\n * `span.setStatus({ code, message })`).\n *\n * Streamed (v2) span statuses are reduced to `ok`/`error`, so we preserve the\n * message as an attribute instead of dropping it. This mirrors the attribute\n * Sentry's OTLP ingestion uses for the same purpose.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE = 'sentry.status.message';\n\n/** The reason why an idle span finished. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON = 'sentry.idle_span_finish_reason';\n\n/** The unit of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT = 'sentry.measurement_unit';\n\n/** The value of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE = 'sentry.measurement_value';\n\n/** The release version of the application */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = 'sentry.release';\n/** The environment name (e.g., \"production\", \"staging\", \"development\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = 'sentry.environment';\n/** The segment name (e.g., \"GET /users\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME = 'sentry.segment.name';\n/** The id of the segment that this span belongs to. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID = 'sentry.segment.id';\n/** The name of the Sentry SDK (e.g., \"sentry.php\", \"sentry.javascript\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = 'sentry.sdk.name';\n/** The version of the Sentry SDK */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = 'sentry.sdk.version';\n/** The list of integrations enabled in the Sentry SDK (e.g., [\"InboundFilters\", \"BrowserTracing\"]) */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS = 'sentry.sdk.integrations';\n\n/** The user ID */\nexport const SEMANTIC_ATTRIBUTE_USER_ID = 'user.id';\n/** The user email */\nexport const SEMANTIC_ATTRIBUTE_USER_EMAIL = 'user.email';\n/** The user IP address */\nexport const SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = 'user.ip_address';\n/** The user username */\nexport const SEMANTIC_ATTRIBUTE_USER_USERNAME = 'user.name';\n\n/**\n * A custom span name set by users guaranteed to be taken over any automatically\n * inferred name. This attribute is removed before the span is sent.\n *\n * @internal only meant for internal SDK usage\n * @hidden\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME = 'sentry.custom_span_name';\n\n/**\n * The id of the profile that this span occurred in.\n */\nexport const SEMANTIC_ATTRIBUTE_PROFILE_ID = 'sentry.profile_id';\n\nexport const SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = 'sentry.exclusive_time';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_HIT = 'cache.hit';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_KEY = 'cache.key';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = 'cache.item_size';\n\n/** TODO: Remove these once we update to latest semantic conventions */\nexport const SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = 'http.request.method';\nexport const SEMANTIC_ATTRIBUTE_URL_FULL = 'url.full';\n\n/**\n * A span link attribute to mark the link as a special span link.\n *\n * Known values:\n * - `previous_trace`: The span links to the frontend root span of the previous trace.\n * - `next_trace`: The span links to the frontend root span of the next trace. (Not set by the SDK)\n *\n * Other values may be set as appropriate.\n * @see https://develop.sentry.dev/sdk/telemetry/traces/span-links/#link-types\n */\nexport const SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = 'sentry.link.type';\n\n/**\n * =============================================================================\n * GEN AI ATTRIBUTES\n * Based on OpenTelemetry Semantic Conventions for Generative AI\n * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/\n * =============================================================================\n */\n\n/**\n * The conversation ID for linking messages across API calls.\n * For OpenAI Assistants API: thread_id\n * For LangGraph: configurable.thread_id\n */\nexport const GEN_AI_CONVERSATION_ID_ATTRIBUTE = 'gen_ai.conversation.id';\n"],"names":[],"mappings":";;AAKO,MAAM,gCAAA,GAAmC;AAQzC,MAAM,qCAAA,GAAwC;AAQ9C,MAAM,oDAAA,GAAuD;AAK7D,MAAM,4BAAA,GAA+B;AAKrC,MAAM,gCAAA,GAAmC;AAUzC,MAAM,wCAAA,GAA2C;AAGjD,MAAM,iDAAA,GAAoD;AAG1D,MAAM,0CAAA,GAA6C;AAGnD,MAAM,2CAAA,GAA8C;AAGpD,MAAM,iCAAA,GAAoC;AAE1C,MAAM,qCAAA,GAAwC;AAE9C,MAAM,sCAAA,GAAyC;AAE/C,MAAM,oCAAA,GAAuC;AAE7C,MAAM,kCAAA,GAAqC;AAE3C,MAAM,qCAAA,GAAwC;AAE9C,MAAM,0CAAA,GAA6C;AAGnD,MAAM,0BAAA,GAA6B;AAEnC,MAAM,6BAAA,GAAgC;AAEtC,MAAM,kCAAA,GAAqC;AAE3C,MAAM,gCAAA,GAAmC;AASzC,MAAM,0CAAA,GAA6C;AAKnD,MAAM,6BAAA,GAAgC;AAEtC,MAAM,iCAAA,GAAoC;AAE1C,MAAM,4BAAA,GAA+B;AAErC,MAAM,4BAAA,GAA+B;AAErC,MAAM,kCAAA,GAAqC;AAG3C,MAAM,sCAAA,GAAyC;AAC/C,MAAM,2BAAA,GAA8B;AAYpC,MAAM,iCAAA,GAAoC;AAe1C,MAAM,gCAAA,GAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
+54
-30
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const errors = require('./tracing/errors.js'); | ||
| const utils$2 = require('./tracing/utils.js'); | ||
| const utils$3 = require('./tracing/utils.js'); | ||
| const idleSpan = require('./tracing/idleSpan.js'); | ||
| const sentrySpan = require('./tracing/sentrySpan.js'); | ||
| const deferSegmentSpanCapture = require('./tracing/deferSegmentSpanCapture.js'); | ||
| const sentryNonRecordingSpan = require('./tracing/sentryNonRecordingSpan.js'); | ||
@@ -21,3 +22,3 @@ const spanstatus = require('./tracing/spanstatus.js'); | ||
| const defaultScopes = require('./defaultScopes.js'); | ||
| const index$3 = require('./asyncContext/index.js'); | ||
| const index$5 = require('./asyncContext/index.js'); | ||
| const tracingChannelBinding = require('./asyncContext/tracing-channel-binding.js'); | ||
@@ -89,17 +90,20 @@ const carrier = require('./carrier.js'); | ||
| const consola = require('./integrations/consola.js'); | ||
| const index = require('./tracing/vercel-ai/index.js'); | ||
| const utils$3 = require('./tracing/ai/utils.js'); | ||
| const index$2 = require('./tracing/vercel-ai/index.js'); | ||
| const utils$4 = require('./tracing/ai/utils.js'); | ||
| const genAiAttributes = require('./tracing/ai/gen-ai-attributes.js'); | ||
| const utils = require('./tracing/vercel-ai/utils.js'); | ||
| const constants$7 = require('./tracing/vercel-ai/constants.js'); | ||
| const index$7 = require('./tracing/openai/index.js'); | ||
| const index$1 = require('./tracing/openai/index.js'); | ||
| const utils$2 = require('./tracing/openai/utils.js'); | ||
| const streaming$1 = require('./tracing/openai/streaming.js'); | ||
| const constants$6 = require('./tracing/openai/constants.js'); | ||
| const index$4 = require('./tracing/anthropic-ai/index.js'); | ||
| const index = require('./tracing/anthropic-ai/index.js'); | ||
| const streaming = require('./tracing/anthropic-ai/streaming.js'); | ||
| const constants = require('./tracing/anthropic-ai/constants.js'); | ||
| const index$6 = require('./tracing/google-genai/index.js'); | ||
| const index$7 = require('./tracing/google-genai/index.js'); | ||
| const constants$2 = require('./tracing/google-genai/constants.js'); | ||
| const index$1 = require('./tracing/langchain/index.js'); | ||
| const index$3 = require('./tracing/langchain/index.js'); | ||
| const utils$1 = require('./tracing/langchain/utils.js'); | ||
| const constants$4 = require('./tracing/langchain/constants.js'); | ||
| const index$5 = require('./tracing/langgraph/index.js'); | ||
| const index$6 = require('./tracing/langgraph/index.js'); | ||
| const constants$5 = require('./tracing/langgraph/constants.js'); | ||
@@ -160,3 +164,3 @@ const spanBuffer = require('./tracing/spans/spanBuffer.js'); | ||
| const timer = require('./utils/timer.js'); | ||
| const index$2 = require('./integrations/express/index.js'); | ||
| const index$4 = require('./integrations/express/index.js'); | ||
| const postgresjs = require('./integrations/postgresjs.js'); | ||
@@ -176,9 +180,14 @@ const sql = require('./utils/sql.js'); | ||
| exports.registerSpanErrorInstrumentation = errors.registerSpanErrorInstrumentation; | ||
| exports.getCapturedScopesOnSpan = utils$2.getCapturedScopesOnSpan; | ||
| exports.markSpanForOtelSourceInference = utils$2.markSpanForOtelSourceInference; | ||
| exports.setCapturedScopesOnSpan = utils$2.setCapturedScopesOnSpan; | ||
| exports.spanShouldInferOtelSource = utils$2.spanShouldInferOtelSource; | ||
| exports.getCapturedScopesOnSpan = utils$3.getCapturedScopesOnSpan; | ||
| exports.markSpanAsTracerProviderSpan = utils$3.markSpanAsTracerProviderSpan; | ||
| exports.markSpanForOtelSourceInference = utils$3.markSpanForOtelSourceInference; | ||
| exports.markSpanSourceAsExplicit = utils$3.markSpanSourceAsExplicit; | ||
| exports.setCapturedScopesOnSpan = utils$3.setCapturedScopesOnSpan; | ||
| exports.spanIsTracerProviderSpan = utils$3.spanIsTracerProviderSpan; | ||
| exports.spanShouldInferOtelSource = utils$3.spanShouldInferOtelSource; | ||
| exports.spanSourceWasExplicitlySet = utils$3.spanSourceWasExplicitlySet; | ||
| exports.TRACING_DEFAULTS = idleSpan.TRACING_DEFAULTS; | ||
| exports.startIdleSpan = idleSpan.startIdleSpan; | ||
| exports.SentrySpan = sentrySpan.SentrySpan; | ||
| exports._INTERNAL_setDeferSegmentSpanCapture = deferSegmentSpanCapture._INTERNAL_setDeferSegmentSpanCapture; | ||
| exports.SentryNonRecordingSpan = sentryNonRecordingSpan.SentryNonRecordingSpan; | ||
@@ -191,4 +200,6 @@ exports.SPAN_STATUS_ERROR = spanstatus.SPAN_STATUS_ERROR; | ||
| exports.SUPPRESS_TRACING_KEY = trace.SUPPRESS_TRACING_KEY; | ||
| exports._INTERNAL_startInactiveSpan = trace._INTERNAL_startInactiveSpan; | ||
| exports.continueTrace = trace.continueTrace; | ||
| exports.isTracingSuppressed = trace.isTracingSuppressed; | ||
| exports.spanIsIgnored = trace.spanIsIgnored; | ||
| exports.startInactiveSpan = trace.startInactiveSpan; | ||
@@ -280,4 +291,4 @@ exports.startNewTrace = trace.startNewTrace; | ||
| exports.getDefaultIsolationScope = defaultScopes.getDefaultIsolationScope; | ||
| exports.getAsyncContextStrategy = index$3.getAsyncContextStrategy; | ||
| exports.setAsyncContextStrategy = index$3.setAsyncContextStrategy; | ||
| exports.getAsyncContextStrategy = index$5.getAsyncContextStrategy; | ||
| exports.setAsyncContextStrategy = index$5.setAsyncContextStrategy; | ||
| exports._INTERNAL_createTracingChannelBinding = tracingChannelBinding._INTERNAL_createTracingChannelBinding; | ||
@@ -337,2 +348,3 @@ exports.waitForTracingChannelBinding = tracingChannelBinding.waitForTracingChannelBinding; | ||
| exports.spanIsSampled = spanUtils.spanIsSampled; | ||
| exports.spanIsSentrySpan = spanUtils.spanIsSentrySpan; | ||
| exports.spanTimeInputToSeconds = spanUtils.spanTimeInputToSeconds; | ||
@@ -400,7 +412,9 @@ exports.spanToJSON = spanUtils.spanToJSON; | ||
| exports.createConsolaReporter = consola.createConsolaReporter; | ||
| exports.addVercelAiProcessors = index.addVercelAiProcessors; | ||
| exports.getProviderMetadataAttributes = index.getProviderMetadataAttributes; | ||
| exports.getTruncatedJsonString = utils$3.getTruncatedJsonString; | ||
| exports.shouldEnableTruncation = utils$3.shouldEnableTruncation; | ||
| exports.addVercelAiProcessors = index$2.addVercelAiProcessors; | ||
| exports.getProviderMetadataAttributes = index$2.getProviderMetadataAttributes; | ||
| exports.getTruncatedJsonString = utils$4.getTruncatedJsonString; | ||
| exports.resolveAIRecordingOptions = utils$4.resolveAIRecordingOptions; | ||
| exports.shouldEnableTruncation = utils$4.shouldEnableTruncation; | ||
| exports.GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE = genAiAttributes.GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE; | ||
| exports.GEN_AI_REQUEST_MODEL_ATTRIBUTE = genAiAttributes.GEN_AI_REQUEST_MODEL_ATTRIBUTE; | ||
| exports.GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE = genAiAttributes.GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE; | ||
@@ -410,14 +424,24 @@ exports._INTERNAL_cleanupToolCallSpanContext = utils._INTERNAL_cleanupToolCallSpanContext; | ||
| exports._INTERNAL_toolCallSpanContextMap = constants$7.toolCallSpanContextMap; | ||
| exports.instrumentOpenAiClient = index$7.instrumentOpenAiClient; | ||
| exports.addOpenAiRequestAttributes = index$1.addRequestAttributes; | ||
| exports.extractOpenAiRequestAttributes = index$1.extractRequestAttributes; | ||
| exports.instrumentOpenAiClient = index$1.instrumentOpenAiClient; | ||
| exports.addOpenAiResponseAttributes = utils$2.addResponseAttributes; | ||
| exports.extractOpenAiRequestParameters = utils$2.extractRequestParameters; | ||
| exports.instrumentOpenAiStream = streaming$1.instrumentStream; | ||
| exports.OPENAI_INTEGRATION_NAME = constants$6.OPENAI_INTEGRATION_NAME; | ||
| exports.instrumentAnthropicAiClient = index$4.instrumentAnthropicAiClient; | ||
| exports.addAnthropicRequestAttributes = index.addPrivateRequestAttributes; | ||
| exports.addAnthropicResponseAttributes = index.addResponseAttributes; | ||
| exports.extractAnthropicRequestAttributes = index.extractRequestAttributes; | ||
| exports.instrumentAnthropicAiClient = index.instrumentAnthropicAiClient; | ||
| exports.instrumentAsyncIterableStream = streaming.instrumentAsyncIterableStream; | ||
| exports.instrumentMessageStream = streaming.instrumentMessageStream; | ||
| exports.ANTHROPIC_AI_INTEGRATION_NAME = constants.ANTHROPIC_AI_INTEGRATION_NAME; | ||
| exports.instrumentGoogleGenAIClient = index$6.instrumentGoogleGenAIClient; | ||
| exports.instrumentGoogleGenAIClient = index$7.instrumentGoogleGenAIClient; | ||
| exports.GOOGLE_GENAI_INTEGRATION_NAME = constants$2.GOOGLE_GENAI_INTEGRATION_NAME; | ||
| exports.createLangChainCallbackHandler = index$1.createLangChainCallbackHandler; | ||
| exports.createLangChainCallbackHandler = index$3.createLangChainCallbackHandler; | ||
| exports._INTERNAL_mergeLangChainCallbackHandler = utils$1._INTERNAL_mergeLangChainCallbackHandler; | ||
| exports.LANGCHAIN_INTEGRATION_NAME = constants$4.LANGCHAIN_INTEGRATION_NAME; | ||
| exports.instrumentCreateReactAgent = index$5.instrumentCreateReactAgent; | ||
| exports.instrumentLangGraph = index$5.instrumentLangGraph; | ||
| exports.instrumentStateGraphCompile = index$5.instrumentStateGraphCompile; | ||
| exports.instrumentCreateReactAgent = index$6.instrumentCreateReactAgent; | ||
| exports.instrumentLangGraph = index$6.instrumentLangGraph; | ||
| exports.instrumentStateGraphCompile = index$6.instrumentStateGraphCompile; | ||
| exports.LANGGRAPH_INTEGRATION_NAME = constants$5.LANGGRAPH_INTEGRATION_NAME; | ||
@@ -594,5 +618,5 @@ exports.SpanBuffer = spanBuffer.SpanBuffer; | ||
| exports._INTERNAL_safeUnref = timer.safeUnref; | ||
| exports.expressErrorHandler = index$2.expressErrorHandler; | ||
| exports.patchExpressModule = index$2.patchExpressModule; | ||
| exports.setupExpressErrorHandler = index$2.setupExpressErrorHandler; | ||
| exports.expressErrorHandler = index$4.expressErrorHandler; | ||
| exports.patchExpressModule = index$4.patchExpressModule; | ||
| exports.setupExpressErrorHandler = index$4.setupExpressErrorHandler; | ||
| exports._INTERNAL_sanitizeSqlQuery = postgresjs._sanitizeSqlQuery; | ||
@@ -599,0 +623,0 @@ exports.instrumentPostgresJsSql = postgresjs.instrumentPostgresJsSql; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
@@ -8,6 +8,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const genAiAttributes = require('../ai/gen-ai-attributes.js'); | ||
| const utils = require('../ai/utils.js'); | ||
| const utils$1 = require('../ai/utils.js'); | ||
| const constants = require('./constants.js'); | ||
| const streaming = require('./streaming.js'); | ||
| const utils$1 = require('./utils.js'); | ||
| const utils = require('./utils.js'); | ||
@@ -43,4 +43,4 @@ function extractRequestAttributes(args, methodPath, operationName) { | ||
| function addPrivateRequestAttributes(span, params, enableTruncation) { | ||
| const messages = utils$1.messagesFromParams(params); | ||
| utils$1.setMessagesAttribute(span, messages, enableTruncation); | ||
| const messages = utils.messagesFromParams(params); | ||
| utils.setMessagesAttribute(span, messages, enableTruncation); | ||
| if ("prompt" in params) { | ||
@@ -81,3 +81,3 @@ span.setAttributes({ [genAiAttributes.GEN_AI_PROMPT_ATTRIBUTE]: JSON.stringify(params.prompt) }); | ||
| if ("usage" in response && response.usage) { | ||
| utils.setTokenUsageAttributes( | ||
| utils$1.setTokenUsageAttributes( | ||
| span, | ||
@@ -95,3 +95,3 @@ response.usage.input_tokens, | ||
| if ("type" in response && response.type === "error") { | ||
| utils$1.handleResponseError(span, response); | ||
| utils.handleResponseError(span, response); | ||
| return; | ||
@@ -126,3 +126,3 @@ } | ||
| if (options.recordInputs && params) { | ||
| addPrivateRequestAttributes(span, params, utils.shouldEnableTruncation(options.enableTruncation)); | ||
| addPrivateRequestAttributes(span, params, utils$1.shouldEnableTruncation(options.enableTruncation)); | ||
| } | ||
@@ -142,3 +142,3 @@ return (async () => { | ||
| }); | ||
| return utils.wrapPromiseWithMethods(originalResult, instrumentedPromise, "auto.ai.anthropic"); | ||
| return utils$1.wrapPromiseWithMethods(originalResult, instrumentedPromise, "auto.ai.anthropic"); | ||
| } else { | ||
@@ -148,3 +148,3 @@ return trace.startSpanManual(spanConfig, (span) => { | ||
| if (options.recordInputs && params) { | ||
| addPrivateRequestAttributes(span, params, utils.shouldEnableTruncation(options.enableTruncation)); | ||
| addPrivateRequestAttributes(span, params, utils$1.shouldEnableTruncation(options.enableTruncation)); | ||
| } | ||
@@ -193,3 +193,3 @@ const messageStream = target.apply(context, args); | ||
| if (options.recordInputs && params) { | ||
| addPrivateRequestAttributes(span, params, utils.shouldEnableTruncation(options.enableTruncation)); | ||
| addPrivateRequestAttributes(span, params, utils$1.shouldEnableTruncation(options.enableTruncation)); | ||
| } | ||
@@ -216,3 +216,3 @@ return originalResult.then( | ||
| ); | ||
| return utils.wrapPromiseWithMethods(originalResult, instrumentedPromise, "auto.ai.anthropic"); | ||
| return utils$1.wrapPromiseWithMethods(originalResult, instrumentedPromise, "auto.ai.anthropic"); | ||
| } | ||
@@ -225,3 +225,3 @@ }); | ||
| const value = obj[prop]; | ||
| const methodPath = utils.buildMethodPath(currentPath, String(prop)); | ||
| const methodPath = utils$1.buildMethodPath(currentPath, String(prop)); | ||
| const instrumentedMethod = constants.ANTHROPIC_METHOD_REGISTRY[methodPath]; | ||
@@ -248,6 +248,9 @@ if (typeof value === "function" && instrumentedMethod) { | ||
| function instrumentAnthropicAiClient(anthropicAiClient, options) { | ||
| return createDeepProxy(anthropicAiClient, "", utils.resolveAIRecordingOptions(options)); | ||
| return createDeepProxy(anthropicAiClient, "", utils$1.resolveAIRecordingOptions(options)); | ||
| } | ||
| exports.addPrivateRequestAttributes = addPrivateRequestAttributes; | ||
| exports.addResponseAttributes = addResponseAttributes; | ||
| exports.extractRequestAttributes = extractRequestAttributes; | ||
| exports.instrumentAnthropicAiClient = instrumentAnthropicAiClient; | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/anthropic-ai/index.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpan, startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types/span';\nimport {\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_PROMPT_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_REQUEST_STREAM_ATTRIBUTE,\n GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_K_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_P_ATTRIBUTE,\n GEN_AI_RESPONSE_ID_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_TEXT_ATTRIBUTE,\n GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { InstrumentedMethodEntry } from '../ai/utils';\nimport {\n buildMethodPath,\n resolveAIRecordingOptions,\n setTokenUsageAttributes,\n shouldEnableTruncation,\n wrapPromiseWithMethods,\n} from '../ai/utils';\nimport { ANTHROPIC_METHOD_REGISTRY } from './constants';\nimport { instrumentAsyncIterableStream, instrumentMessageStream } from './streaming';\nimport type { AnthropicAiOptions, AnthropicAiResponse, AnthropicAiStreamingEvent, ContentBlock } from './types';\nimport { handleResponseError, messagesFromParams, setMessagesAttribute } from './utils';\n\n/**\n * Extract request attributes from method arguments\n */\nfunction extractRequestAttributes(args: unknown[], methodPath: string, operationName: string): Record<string, unknown> {\n const attributes: Record<string, unknown> = {\n [GEN_AI_SYSTEM_ATTRIBUTE]: 'anthropic',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: operationName,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.anthropic',\n };\n\n if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null) {\n const params = args[0] as Record<string, unknown>;\n if (params.tools && Array.isArray(params.tools)) {\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = JSON.stringify(params.tools);\n }\n\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = params.model ?? 'unknown';\n if ('temperature' in params) attributes[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE] = params.temperature;\n if ('top_p' in params) attributes[GEN_AI_REQUEST_TOP_P_ATTRIBUTE] = params.top_p;\n if ('stream' in params) attributes[GEN_AI_REQUEST_STREAM_ATTRIBUTE] = params.stream;\n if ('top_k' in params) attributes[GEN_AI_REQUEST_TOP_K_ATTRIBUTE] = params.top_k;\n if ('frequency_penalty' in params)\n attributes[GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE] = params.frequency_penalty;\n if ('max_tokens' in params) attributes[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE] = params.max_tokens;\n } else {\n if (methodPath === 'models.retrieve' || methodPath === 'models.get') {\n // models.retrieve(model-id) and models.get(model-id)\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = args[0];\n } else {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = 'unknown';\n }\n }\n\n return attributes;\n}\n\n/**\n * Add private request attributes to spans.\n * This is only recorded if recordInputs is true.\n */\nfunction addPrivateRequestAttributes(span: Span, params: Record<string, unknown>, enableTruncation: boolean): void {\n const messages = messagesFromParams(params);\n setMessagesAttribute(span, messages, enableTruncation);\n\n if ('prompt' in params) {\n span.setAttributes({ [GEN_AI_PROMPT_ATTRIBUTE]: JSON.stringify(params.prompt) });\n }\n}\n\n/**\n * Add content attributes when recordOutputs is enabled\n */\nfunction addContentAttributes(span: Span, response: AnthropicAiResponse): void {\n // Messages.create\n if ('content' in response) {\n if (Array.isArray(response.content)) {\n span.setAttributes({\n [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: response.content\n .map((item: ContentBlock) => item.text)\n .filter(text => !!text)\n .join(''),\n });\n\n const toolCalls: Array<ContentBlock> = [];\n\n for (const item of response.content) {\n if (item.type === 'tool_use' || item.type === 'server_tool_use') {\n toolCalls.push(item);\n }\n }\n if (toolCalls.length > 0) {\n span.setAttributes({ [GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE]: JSON.stringify(toolCalls) });\n }\n }\n }\n // Completions.create\n if ('completion' in response) {\n span.setAttributes({ [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: response.completion });\n }\n // Models.countTokens\n if ('input_tokens' in response) {\n span.setAttributes({ [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: JSON.stringify(response.input_tokens) });\n }\n}\n\n/**\n * Add basic metadata attributes from the response\n */\nfunction addMetadataAttributes(span: Span, response: AnthropicAiResponse): void {\n if ('id' in response && 'model' in response) {\n span.setAttributes({\n [GEN_AI_RESPONSE_ID_ATTRIBUTE]: response.id,\n [GEN_AI_RESPONSE_MODEL_ATTRIBUTE]: response.model,\n });\n\n if ('usage' in response && response.usage) {\n setTokenUsageAttributes(\n span,\n response.usage.input_tokens,\n response.usage.output_tokens,\n response.usage.cache_creation_input_tokens,\n response.usage.cache_read_input_tokens,\n );\n }\n }\n}\n\n/**\n * Add response attributes to spans\n */\nfunction addResponseAttributes(span: Span, response: AnthropicAiResponse, recordOutputs?: boolean): void {\n if (!response || typeof response !== 'object') return;\n\n // capture error, do not add attributes if error (they shouldn't exist)\n if ('type' in response && response.type === 'error') {\n handleResponseError(span, response);\n return;\n }\n\n // Private response attributes that are only recorded if recordOutputs is true.\n if (recordOutputs) {\n addContentAttributes(span, response);\n }\n\n // Add basic metadata attributes\n addMetadataAttributes(span, response);\n}\n\n/**\n * Handle common error catching and reporting for streaming requests\n */\nfunction handleStreamingError(error: unknown, span: Span, methodPath: string): never {\n captureException(error, {\n mechanism: { handled: false, type: 'auto.ai.anthropic', data: { function: methodPath } },\n });\n\n if (span.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n span.end();\n }\n throw error;\n}\n\n/**\n * Handle streaming cases with common logic\n */\nfunction handleStreamingRequest<T extends unknown[], R>(\n originalMethod: (...args: T) => R | Promise<R>,\n target: (...args: T) => R | Promise<R>,\n context: unknown,\n args: T,\n requestAttributes: Record<string, unknown>,\n operationName: string,\n methodPath: string,\n params: Record<string, unknown> | undefined,\n options: AnthropicAiOptions,\n isStreamRequested: boolean,\n isStreamingMethod: boolean,\n): R | Promise<R> {\n const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? 'unknown';\n const spanConfig = {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n };\n\n // messages.stream() always returns a sync MessageStream, even with stream: true param\n if (isStreamRequested && !isStreamingMethod) {\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpanManual(spanConfig, (span: Span) => {\n originalResult = originalMethod.apply(context, args) as Promise<R>;\n\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n\n return (async () => {\n try {\n const result = await originalResult;\n return instrumentAsyncIterableStream(\n result as AsyncIterable<AnthropicAiStreamingEvent>,\n span,\n options.recordOutputs ?? false,\n ) as unknown as R;\n } catch (error) {\n return handleStreamingError(error, span, methodPath);\n }\n })();\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.anthropic');\n } else {\n return startSpanManual(spanConfig, span => {\n try {\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n const messageStream = target.apply(context, args);\n return instrumentMessageStream(messageStream, span, options.recordOutputs ?? false);\n } catch (error) {\n return handleStreamingError(error, span, methodPath);\n }\n });\n }\n}\n\n/**\n * Instrument a method with Sentry spans\n * Following Sentry AI Agents Manual Instrumentation conventions\n * @see https://docs.sentry.io/platforms/javascript/guides/node/tracing/instrumentation/ai-agents-module/#manual-instrumentation\n */\nfunction instrumentMethod<T extends unknown[], R>(\n originalMethod: (...args: T) => R | Promise<R>,\n methodPath: string,\n instrumentedMethod: InstrumentedMethodEntry,\n context: unknown,\n options: AnthropicAiOptions,\n): (...args: T) => R | Promise<R> {\n return new Proxy(originalMethod, {\n apply(target, thisArg, args: T): R | Promise<R> {\n const operationName = instrumentedMethod.operation || 'unknown';\n const requestAttributes = extractRequestAttributes(args, methodPath, operationName);\n const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? 'unknown';\n\n const params = typeof args[0] === 'object' ? (args[0] as Record<string, unknown>) : undefined;\n const isStreamRequested = Boolean(params?.stream);\n const isStreamingMethod = instrumentedMethod.streaming === true;\n\n if (isStreamRequested || isStreamingMethod) {\n return handleStreamingRequest(\n originalMethod,\n target,\n context,\n args,\n requestAttributes,\n operationName,\n methodPath,\n params,\n options,\n isStreamRequested,\n isStreamingMethod,\n );\n }\n\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpan(\n {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n },\n span => {\n originalResult = target.apply(context, args) as Promise<R>;\n\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n\n return originalResult.then(\n result => {\n addResponseAttributes(span, result as AnthropicAiResponse, options.recordOutputs);\n return result;\n },\n error => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic',\n data: {\n function: methodPath,\n },\n },\n });\n throw error;\n },\n );\n },\n );\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.anthropic');\n },\n }) as (...args: T) => R | Promise<R>;\n}\n\n/**\n * Create a deep proxy for Anthropic AI client instrumentation\n */\nfunction createDeepProxy<T extends object>(target: T, currentPath = '', options: AnthropicAiOptions): T {\n return new Proxy(target, {\n get(obj: object, prop: string): unknown {\n const value = (obj as Record<string, unknown>)[prop];\n const methodPath = buildMethodPath(currentPath, String(prop));\n\n const instrumentedMethod = ANTHROPIC_METHOD_REGISTRY[methodPath as keyof typeof ANTHROPIC_METHOD_REGISTRY];\n if (typeof value === 'function' && instrumentedMethod) {\n return instrumentMethod(\n value as (...args: unknown[]) => unknown | Promise<unknown>,\n methodPath,\n instrumentedMethod,\n obj,\n options,\n );\n }\n\n if (typeof value === 'function') {\n // Bind non-instrumented functions to preserve the original `this` context,\n return value.bind(obj);\n }\n\n if (value && typeof value === 'object') {\n return createDeepProxy(value, methodPath, options);\n }\n\n return value;\n },\n }) as T;\n}\n\n/**\n * Instrument an Anthropic AI client with Sentry tracing\n * Can be used across Node.js, Cloudflare Workers, and Vercel Edge\n *\n * @template T - The type of the client that extends object\n * @param client - The Anthropic AI client to instrument\n * @param options - Optional configuration for recording inputs and outputs\n * @returns The instrumented client with the same type as the input\n */\nexport function instrumentAnthropicAiClient<T extends object>(anthropicAiClient: T, options?: AnthropicAiOptions): T {\n return createDeepProxy(anthropicAiClient, '', resolveAIRecordingOptions(options));\n}\n"],"names":["GEN_AI_SYSTEM_ATTRIBUTE","GEN_AI_OPERATION_NAME_ATTRIBUTE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE","GEN_AI_REQUEST_TOP_P_ATTRIBUTE","GEN_AI_REQUEST_STREAM_ATTRIBUTE","GEN_AI_REQUEST_TOP_K_ATTRIBUTE","GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE","GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE","messagesFromParams","setMessagesAttribute","GEN_AI_PROMPT_ATTRIBUTE","GEN_AI_RESPONSE_TEXT_ATTRIBUTE","GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE","GEN_AI_RESPONSE_ID_ATTRIBUTE","GEN_AI_RESPONSE_MODEL_ATTRIBUTE","setTokenUsageAttributes","handleResponseError","captureException","SPAN_STATUS_ERROR","startSpanManual","shouldEnableTruncation","instrumentAsyncIterableStream","wrapPromiseWithMethods","instrumentM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MAAA,MAAM,kBAAA,GAAqBC,oCAA0B,UAAoD,CAAA;AACzG,MAAA,IAAI,OAAO,KAAA,KAAU,UAAA,IAAc,kBAAA,EAAoB;AACrD,QAAA,OAAO,gBAAA;AAAA,UACL,KAAA;AAAA,UACA,UAAA;AAAA,UACA,kBAAA;AAAA,UACA,GAAA;AAAA,UACA;AAAA,SACF;AAAA,MACF;AAEA,MAAA,IAAI,OAAO,UAAU,UAAA,EAAY;AAE/B,QAAA,OAAO,KAAA,CAAM,KAAK,GAAG,CAAA;AAAA,MACvB;AAEA,MAAA,IAAI,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,EAAU;AACtC,QAAA,OAAO,eAAA,CAAgB,KAAA,EAAO,UAAA,EAAY,OAAO,CAAA;AAAA,MACnD;AAEA,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,GACD,CAAA;AACH;AAWO,SAAS,2BAAA,CAA8C,mBAAsB,OAAA,EAAiC;AACnH,EAAA,OAAO,eAAA,CAAgB,iBAAA,EAAmB,EAAA,EAAIC,+BAAA,CAA0B,OAAO,CAAC,CAAA;AAClF;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/anthropic-ai/index.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpan, startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types/span';\nimport {\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_PROMPT_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_REQUEST_STREAM_ATTRIBUTE,\n GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_K_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_P_ATTRIBUTE,\n GEN_AI_RESPONSE_ID_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_TEXT_ATTRIBUTE,\n GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { InstrumentedMethodEntry } from '../ai/utils';\nimport {\n buildMethodPath,\n resolveAIRecordingOptions,\n setTokenUsageAttributes,\n shouldEnableTruncation,\n wrapPromiseWithMethods,\n} from '../ai/utils';\nimport { ANTHROPIC_METHOD_REGISTRY } from './constants';\nimport { instrumentAsyncIterableStream, instrumentMessageStream } from './streaming';\nimport type { AnthropicAiOptions, AnthropicAiResponse, AnthropicAiStreamingEvent, ContentBlock } from './types';\nimport { handleResponseError, messagesFromParams, setMessagesAttribute } from './utils';\n\n/**\n * Extract request attributes from method arguments\n */\nexport function extractRequestAttributes(\n args: unknown[],\n methodPath: string,\n operationName: string,\n): Record<string, unknown> {\n const attributes: Record<string, unknown> = {\n [GEN_AI_SYSTEM_ATTRIBUTE]: 'anthropic',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: operationName,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.anthropic',\n };\n\n if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null) {\n const params = args[0] as Record<string, unknown>;\n if (params.tools && Array.isArray(params.tools)) {\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = JSON.stringify(params.tools);\n }\n\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = params.model ?? 'unknown';\n if ('temperature' in params) attributes[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE] = params.temperature;\n if ('top_p' in params) attributes[GEN_AI_REQUEST_TOP_P_ATTRIBUTE] = params.top_p;\n if ('stream' in params) attributes[GEN_AI_REQUEST_STREAM_ATTRIBUTE] = params.stream;\n if ('top_k' in params) attributes[GEN_AI_REQUEST_TOP_K_ATTRIBUTE] = params.top_k;\n if ('frequency_penalty' in params)\n attributes[GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE] = params.frequency_penalty;\n if ('max_tokens' in params) attributes[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE] = params.max_tokens;\n } else {\n if (methodPath === 'models.retrieve' || methodPath === 'models.get') {\n // models.retrieve(model-id) and models.get(model-id)\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = args[0];\n } else {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = 'unknown';\n }\n }\n\n return attributes;\n}\n\n/**\n * Add private request attributes to spans.\n * This is only recorded if recordInputs is true.\n */\nexport function addPrivateRequestAttributes(\n span: Span,\n params: Record<string, unknown>,\n enableTruncation: boolean,\n): void {\n const messages = messagesFromParams(params);\n setMessagesAttribute(span, messages, enableTruncation);\n\n if ('prompt' in params) {\n span.setAttributes({ [GEN_AI_PROMPT_ATTRIBUTE]: JSON.stringify(params.prompt) });\n }\n}\n\n/**\n * Add content attributes when recordOutputs is enabled\n */\nfunction addContentAttributes(span: Span, response: AnthropicAiResponse): void {\n // Messages.create\n if ('content' in response) {\n if (Array.isArray(response.content)) {\n span.setAttributes({\n [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: response.content\n .map((item: ContentBlock) => item.text)\n .filter(text => !!text)\n .join(''),\n });\n\n const toolCalls: Array<ContentBlock> = [];\n\n for (const item of response.content) {\n if (item.type === 'tool_use' || item.type === 'server_tool_use') {\n toolCalls.push(item);\n }\n }\n if (toolCalls.length > 0) {\n span.setAttributes({ [GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE]: JSON.stringify(toolCalls) });\n }\n }\n }\n // Completions.create\n if ('completion' in response) {\n span.setAttributes({ [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: response.completion });\n }\n // Models.countTokens\n if ('input_tokens' in response) {\n span.setAttributes({ [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: JSON.stringify(response.input_tokens) });\n }\n}\n\n/**\n * Add basic metadata attributes from the response\n */\nfunction addMetadataAttributes(span: Span, response: AnthropicAiResponse): void {\n if ('id' in response && 'model' in response) {\n span.setAttributes({\n [GEN_AI_RESPONSE_ID_ATTRIBUTE]: response.id,\n [GEN_AI_RESPONSE_MODEL_ATTRIBUTE]: response.model,\n });\n\n if ('usage' in response && response.usage) {\n setTokenUsageAttributes(\n span,\n response.usage.input_tokens,\n response.usage.output_tokens,\n response.usage.cache_creation_input_tokens,\n response.usage.cache_read_input_tokens,\n );\n }\n }\n}\n\n/**\n * Add response attributes to spans\n */\nexport function addResponseAttributes(span: Span, response: AnthropicAiResponse, recordOutputs?: boolean): void {\n if (!response || typeof response !== 'object') return;\n\n // capture error, do not add attributes if error (they shouldn't exist)\n if ('type' in response && response.type === 'error') {\n handleResponseError(span, response);\n return;\n }\n\n // Private response attributes that are only recorded if recordOutputs is true.\n if (recordOutputs) {\n addContentAttributes(span, response);\n }\n\n // Add basic metadata attributes\n addMetadataAttributes(span, response);\n}\n\n/**\n * Handle common error catching and reporting for streaming requests\n */\nfunction handleStreamingError(error: unknown, span: Span, methodPath: string): never {\n captureException(error, {\n mechanism: { handled: false, type: 'auto.ai.anthropic', data: { function: methodPath } },\n });\n\n if (span.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n span.end();\n }\n throw error;\n}\n\n/**\n * Handle streaming cases with common logic\n */\nfunction handleStreamingRequest<T extends unknown[], R>(\n originalMethod: (...args: T) => R | Promise<R>,\n target: (...args: T) => R | Promise<R>,\n context: unknown,\n args: T,\n requestAttributes: Record<string, unknown>,\n operationName: string,\n methodPath: string,\n params: Record<string, unknown> | undefined,\n options: AnthropicAiOptions,\n isStreamRequested: boolean,\n isStreamingMethod: boolean,\n): R | Promise<R> {\n const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? 'unknown';\n const spanConfig = {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n };\n\n // messages.stream() always returns a sync MessageStream, even with stream: true param\n if (isStreamRequested && !isStreamingMethod) {\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpanManual(spanConfig, (span: Span) => {\n originalResult = originalMethod.apply(context, args) as Promise<R>;\n\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n\n return (async () => {\n try {\n const result = await originalResult;\n return instrumentAsyncIterableStream(\n result as AsyncIterable<AnthropicAiStreamingEvent>,\n span,\n options.recordOutputs ?? false,\n ) as unknown as R;\n } catch (error) {\n return handleStreamingError(error, span, methodPath);\n }\n })();\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.anthropic');\n } else {\n return startSpanManual(spanConfig, span => {\n try {\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n const messageStream = target.apply(context, args);\n return instrumentMessageStream(messageStream, span, options.recordOutputs ?? false);\n } catch (error) {\n return handleStreamingError(error, span, methodPath);\n }\n });\n }\n}\n\n/**\n * Instrument a method with Sentry spans\n * Following Sentry AI Agents Manual Instrumentation conventions\n * @see https://docs.sentry.io/platforms/javascript/guides/node/tracing/instrumentation/ai-agents-module/#manual-instrumentation\n */\nfunction instrumentMethod<T extends unknown[], R>(\n originalMethod: (...args: T) => R | Promise<R>,\n methodPath: string,\n instrumentedMethod: InstrumentedMethodEntry,\n context: unknown,\n options: AnthropicAiOptions,\n): (...args: T) => R | Promise<R> {\n return new Proxy(originalMethod, {\n apply(target, thisArg, args: T): R | Promise<R> {\n const operationName = instrumentedMethod.operation || 'unknown';\n const requestAttributes = extractRequestAttributes(args, methodPath, operationName);\n const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? 'unknown';\n\n const params = typeof args[0] === 'object' ? (args[0] as Record<string, unknown>) : undefined;\n const isStreamRequested = Boolean(params?.stream);\n const isStreamingMethod = instrumentedMethod.streaming === true;\n\n if (isStreamRequested || isStreamingMethod) {\n return handleStreamingRequest(\n originalMethod,\n target,\n context,\n args,\n requestAttributes,\n operationName,\n methodPath,\n params,\n options,\n isStreamRequested,\n isStreamingMethod,\n );\n }\n\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpan(\n {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n },\n span => {\n originalResult = target.apply(context, args) as Promise<R>;\n\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n\n return originalResult.then(\n result => {\n addResponseAttributes(span, result as AnthropicAiResponse, options.recordOutputs);\n return result;\n },\n error => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic',\n data: {\n function: methodPath,\n },\n },\n });\n throw error;\n },\n );\n },\n );\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.anthropic');\n },\n }) as (...args: T) => R | Promise<R>;\n}\n\n/**\n * Create a deep proxy for Anthropic AI client instrumentation\n */\nfunction createDeepProxy<T extends object>(target: T, currentPath = '', options: AnthropicAiOptions): T {\n return new Proxy(target, {\n get(obj: object, prop: string): unknown {\n const value = (obj as Record<string, unknown>)[prop];\n const methodPath = buildMethodPath(currentPath, String(prop));\n\n const instrumentedMethod = ANTHROPIC_METHOD_REGISTRY[methodPath as keyof typeof ANTHROPIC_METHOD_REGISTRY];\n if (typeof value === 'function' && instrumentedMethod) {\n return instrumentMethod(\n value as (...args: unknown[]) => unknown | Promise<unknown>,\n methodPath,\n instrumentedMethod,\n obj,\n options,\n );\n }\n\n if (typeof value === 'function') {\n // Bind non-instrumented functions to preserve the original `this` context,\n return value.bind(obj);\n }\n\n if (value && typeof value === 'object') {\n return createDeepProxy(value, methodPath, options);\n }\n\n return value;\n },\n }) as T;\n}\n\n/**\n * Instrument an Anthropic AI client with Sentry tracing\n * Can be used across Node.js, Cloudflare Workers, and Vercel Edge\n *\n * @template T - The type of the client that extends object\n * @param client - The Anthropic AI client to instrument\n * @param options - Optional configuration for recording inputs and outputs\n * @returns The instrumented client with the same type as the input\n */\nexport function instrumentAnthropicAiClient<T extends object>(anthropicAiClient: T, options?: AnthropicAiOptions): T {\n return createDeepProxy(anthropicAiClient, '', resolveAIRecordingOptions(options));\n}\n"],"names":["GEN_AI_SYSTEM_ATTRIBUTE","GEN_AI_OPERATION_NAME_ATTRIBUTE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE","GEN_AI_REQUEST_TOP_P_ATTRIBUTE","GEN_AI_REQUEST_STREAM_ATTRIBUTE","GEN_AI_REQUEST_TOP_K_ATTRIBUTE","GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE","GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE","messagesFromParams","setMessagesAttribute","GEN_AI_PROMPT_ATTRIBUTE","GEN_AI_RESPONSE_TEXT_ATTRIBUTE","GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE","GEN_AI_RESPONSE_ID_ATTRIBUTE","GEN_AI_RESPONSE_MODEL_ATTRIBUTE","setTokenUsageAttributes","handleResponseError","captureException","SPAN_STATUS_ERROR","startSpanManual","shouldEnableTruncation","instrumentAsyncIterableStream","wrapPromiseWithMethods","instrumentMessageStream","startSpan","buildMethodPath","ANTHROPIC_METHOD_REGISTRY","resolveAIRecordingOptions"],"mappings":";;;;;;;;;;;;AAsCO,SAAS,wBAAA,CACd,IAAA,EACA,UAAA,EACA,aAAA,EACyB;AACzB,EAAA,MAAM,UAAA,GAA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;AAAA,UACA,GAAA;AAAA,UACA;AAAA,SACF;AAAA,MACF;AAEA,MAAA,IAAI,OAAO,UAAU,UAAA,EAAY;AAE/B,QAAA,OAAO,KAAA,CAAM,KAAK,GAAG,CAAA;AAAA,MACvB;AAEA,MAAA,IAAI,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,EAAU;AACtC,QAAA,OAAO,eAAA,CAAgB,KAAA,EAAO,UAAA,EAAY,OAAO,CAAA;AAAA,MACnD;AAEA,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,GACD,CAAA;AACH;AAWO,SAAS,2BAAA,CAA8C,mBAAsB,OAAA,EAAiC;AACnH,EAAA,OAAO,eAAA,CAAgB,iBAAA,EAAmB,EAAA,EAAIC,iCAAA,CAA0B,OAAO,CAAC,CAAA;AAClF;;;;;;;"} |
@@ -24,6 +24,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| function handleMessageMetadata(event, state) { | ||
| if (event.type === "message_delta" && event.usage) { | ||
| if ("output_tokens" in event.usage && typeof event.usage.output_tokens === "number") { | ||
| if (event.type === "message_delta") { | ||
| if (event.usage && typeof event.usage.output_tokens === "number") { | ||
| state.completionTokens = event.usage.output_tokens; | ||
| } | ||
| if (event.delta?.stop_reason) { | ||
| state.finishReasons.push(event.delta.stop_reason); | ||
| } | ||
| } | ||
@@ -34,3 +37,2 @@ if (event.message) { | ||
| if (message.model) state.responseModel = message.model; | ||
| if (message.stop_reason) state.finishReasons.push(message.stop_reason); | ||
| if (message.usage) { | ||
@@ -37,0 +39,0 @@ if (typeof message.usage.input_tokens === "number") state.promptTokens = message.usage.input_tokens; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"streaming.js","sources":["../../../../src/tracing/anthropic-ai/streaming.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport type { Span } from '../../types/span';\nimport { endStreamSpan } from '../ai/utils';\nimport type { AnthropicAiStreamingEvent } from './types';\nimport { mapAnthropicErrorToStatusMessage } from './utils';\n\n/**\n * State object used to accumulate information from a stream of Anthropic AI events.\n */\ninterface StreamingState {\n /** Collected response text fragments (for output recording). */\n responseTexts: string[];\n /** Reasons for finishing the response, as reported by the API. */\n finishReasons: string[];\n /** The response ID. */\n responseId: string;\n /** The model name. */\n responseModel: string;\n /** Number of prompt/input tokens used. */\n promptTokens: number | undefined;\n /** Number of completion/output tokens used. */\n completionTokens: number | undefined;\n /** Number of cache creation input tokens used. */\n cacheCreationInputTokens: number | undefined;\n /** Number of cache read input tokens used. */\n cacheReadInputTokens: number | undefined;\n /** Accumulated tool calls (finalized) */\n toolCalls: Array<Record<string, unknown>>;\n /** In-progress tool call blocks keyed by index */\n activeToolBlocks: Record<\n number,\n {\n id?: string;\n name?: string;\n inputJsonParts: string[];\n }\n >;\n}\n\n/**\n * Checks if an event is an error event\n * @param event - The event to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n * @param span - The span to update\n * @returns Whether an error occurred\n */\n\nfunction isErrorEvent(event: AnthropicAiStreamingEvent, span: Span): boolean {\n if ('type' in event && typeof event.type === 'string') {\n // If the event is an error, set the span status and capture the error\n // These error events are not rejected by the API by default, but are sent as metadata of the response\n if (event.type === 'error') {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: mapAnthropicErrorToStatusMessage(event.error?.type) });\n captureException(event.error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic.anthropic_error',\n },\n });\n return true;\n }\n }\n return false;\n}\n\n/**\n * Processes the message metadata of an event\n * @param event - The event to process\n * @param state - The state of the streaming process\n */\n\nfunction handleMessageMetadata(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n // The token counts shown in the usage field of the message_delta event are cumulative.\n // @see https://docs.anthropic.com/en/docs/build-with-claude/streaming#event-types\n if (event.type === 'message_delta' && event.usage) {\n if ('output_tokens' in event.usage && typeof event.usage.output_tokens === 'number') {\n state.completionTokens = event.usage.output_tokens;\n }\n }\n\n if (event.message) {\n const message = event.message;\n\n if (message.id) state.responseId = message.id;\n if (message.model) state.responseModel = message.model;\n if (message.stop_reason) state.finishReasons.push(message.stop_reason);\n\n if (message.usage) {\n if (typeof message.usage.input_tokens === 'number') state.promptTokens = message.usage.input_tokens;\n if (typeof message.usage.cache_creation_input_tokens === 'number')\n state.cacheCreationInputTokens = message.usage.cache_creation_input_tokens;\n if (typeof message.usage.cache_read_input_tokens === 'number')\n state.cacheReadInputTokens = message.usage.cache_read_input_tokens;\n }\n }\n}\n\n/**\n * Handle start of a content block (e.g., tool_use)\n */\nfunction handleContentBlockStart(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n if (event.type !== 'content_block_start' || typeof event.index !== 'number' || !event.content_block) return;\n if (event.content_block.type === 'tool_use' || event.content_block.type === 'server_tool_use') {\n state.activeToolBlocks[event.index] = {\n id: event.content_block.id,\n name: event.content_block.name,\n inputJsonParts: [],\n };\n }\n}\n\n/**\n * Handle deltas of a content block, including input_json_delta for tool_use\n */\nfunction handleContentBlockDelta(\n event: AnthropicAiStreamingEvent,\n state: StreamingState,\n recordOutputs: boolean,\n): void {\n if (event.type !== 'content_block_delta' || !event.delta) return;\n\n // Accumulate tool_use input JSON deltas only when we have an index and an active tool block\n if (\n typeof event.index === 'number' &&\n 'partial_json' in event.delta &&\n typeof event.delta.partial_json === 'string'\n ) {\n const active = state.activeToolBlocks[event.index];\n if (active) {\n active.inputJsonParts.push(event.delta.partial_json);\n }\n }\n\n // Accumulate streamed response text regardless of index\n if (recordOutputs && typeof event.delta.text === 'string') {\n state.responseTexts.push(event.delta.text);\n }\n}\n\n/**\n * Handle stop of a content block; finalize tool_use entries\n */\nfunction handleContentBlockStop(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n if (event.type !== 'content_block_stop' || typeof event.index !== 'number') return;\n\n const active = state.activeToolBlocks[event.index];\n if (!active) return;\n\n const raw = active.inputJsonParts.join('');\n let parsedInput: unknown;\n\n try {\n parsedInput = raw ? JSON.parse(raw) : {};\n } catch {\n parsedInput = { __unparsed: raw };\n }\n\n state.toolCalls.push({\n type: 'tool_use',\n id: active.id,\n name: active.name,\n input: parsedInput,\n });\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete state.activeToolBlocks[event.index];\n}\n\n/**\n * Processes an event\n * @param event - The event to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n * @param span - The span to update\n */\nfunction processEvent(\n event: AnthropicAiStreamingEvent,\n state: StreamingState,\n recordOutputs: boolean,\n span: Span,\n): void {\n if (!(event && typeof event === 'object')) {\n return;\n }\n\n const isError = isErrorEvent(event, span);\n if (isError) return;\n\n handleMessageMetadata(event, state);\n\n // Tool call events are sent via 3 separate events:\n // - content_block_start (start of the tool call)\n // - content_block_delta (delta aka input of the tool call)\n // - content_block_stop (end of the tool call)\n // We need to handle them all to capture the full tool call.\n handleContentBlockStart(event, state);\n handleContentBlockDelta(event, state, recordOutputs);\n handleContentBlockStop(event, state);\n}\n\n/**\n * Instruments an async iterable stream of Anthropic events, updates the span with\n * streaming attributes and (optionally) the aggregated output text, and yields\n * each event from the input stream unchanged.\n */\nexport async function* instrumentAsyncIterableStream(\n stream: AsyncIterable<AnthropicAiStreamingEvent>,\n span: Span,\n recordOutputs: boolean,\n): AsyncGenerator<AnthropicAiStreamingEvent, void, unknown> {\n const state: StreamingState = {\n responseTexts: [],\n finishReasons: [],\n responseId: '',\n responseModel: '',\n promptTokens: undefined,\n completionTokens: undefined,\n cacheCreationInputTokens: undefined,\n cacheReadInputTokens: undefined,\n toolCalls: [],\n activeToolBlocks: {},\n };\n\n try {\n for await (const event of stream) {\n processEvent(event, state, recordOutputs, span);\n yield event;\n }\n } finally {\n endStreamSpan(span, state, recordOutputs);\n }\n}\n\n/**\n * Instruments a MessageStream by registering event handlers and preserving the original stream API.\n */\nexport function instrumentMessageStream<R extends { on: (...args: unknown[]) => void }>(\n stream: R,\n span: Span,\n recordOutputs: boolean,\n): R {\n const state: StreamingState = {\n responseTexts: [],\n finishReasons: [],\n responseId: '',\n responseModel: '',\n promptTokens: undefined,\n completionTokens: undefined,\n cacheCreationInputTokens: undefined,\n cacheReadInputTokens: undefined,\n toolCalls: [],\n activeToolBlocks: {},\n };\n\n stream.on('streamEvent', (event: unknown) => {\n processEvent(event as AnthropicAiStreamingEvent, state, recordOutputs, span);\n });\n\n // The event fired when a message is done being streamed by the API. Corresponds to the message_stop SSE event.\n // @see https://github.com/anthropics/anthropic-sdk-typescript/blob/d3be31f5a4e6ebb4c0a2f65dbb8f381ae73a9166/helpers.md?plain=1#L42-L44\n stream.on('message', () => {\n endStreamSpan(span, state, recordOutputs);\n });\n\n stream.on('error', (error: unknown) => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic.stream_error',\n },\n });\n\n if (span.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n span.end();\n }\n });\n\n return stream;\n}\n"],"names":["SPAN_STATUS_ERROR","mapAnthropicErrorToStatusMessage","captureException","endStreamSpan"],"mappings":";;;;;;;AAiDA,SAAS,YAAA,CAAa,OAAkC,IAAA,EAAqB;AAC3E,EAAA,IAAI,MAAA,IAAU,KAAA,IAAS,OAAO,KAAA,CAAM,SAAS,QAAA,EAAU;AAGrD,IAAA,IAAI,KAAA,CAAM,SAAS,OAAA,EAAS;AAC1B,MAAA,IAAA,CAAK,SAAA,CAAU,EAAE,IAAA,EAAMA,4BAAA,EAAmB,OAAA,EAASC,yCAAiC,KAAA,CAAM,KAAA,EAAO,IAAI,CAAA,EAAG,CAAA;AACxG,MAAAC,0BAAA,CAAiB,MAAM,KAAA,EAAO;AAAA,QAC5B,SAAA,EAAW;AAAA,UACT,OAAA,EAAS,KAAA;AAAA,UACT,IAAA,EAAM;AAAA;AACR,OACD,CAAA;AACD,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT;AAQA,SAAS,qBAAA,CAAsB,OAAkC,KAAA,EAA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B,SAAA,EAAW;AAAA,QACT,OAAA,EAAS,KAAA;AAAA,QACT,IAAA,EAAM;AAAA;AACR,KACD,CAAA;AAED,IAAA,IAAI,IAAA,CAAK,aAAY,EAAG;AACtB,MAAA,IAAA,CAAK,UAAU,EAAE,IAAA,EAAMF,4BAAA,EAAmB,OAAA,EAAS,kBAAkB,CAAA;AACrE,MAAA,IAAA,CAAK,GAAA,EAAI;AAAA,IACX;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,MAAA;AACT;;;;;"} | ||
| {"version":3,"file":"streaming.js","sources":["../../../../src/tracing/anthropic-ai/streaming.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport type { Span } from '../../types/span';\nimport { endStreamSpan } from '../ai/utils';\nimport type { AnthropicAiStreamingEvent } from './types';\nimport { mapAnthropicErrorToStatusMessage } from './utils';\n\n/**\n * State object used to accumulate information from a stream of Anthropic AI events.\n */\ninterface StreamingState {\n /** Collected response text fragments (for output recording). */\n responseTexts: string[];\n /** Reasons for finishing the response, as reported by the API. */\n finishReasons: string[];\n /** The response ID. */\n responseId: string;\n /** The model name. */\n responseModel: string;\n /** Number of prompt/input tokens used. */\n promptTokens: number | undefined;\n /** Number of completion/output tokens used. */\n completionTokens: number | undefined;\n /** Number of cache creation input tokens used. */\n cacheCreationInputTokens: number | undefined;\n /** Number of cache read input tokens used. */\n cacheReadInputTokens: number | undefined;\n /** Accumulated tool calls (finalized) */\n toolCalls: Array<Record<string, unknown>>;\n /** In-progress tool call blocks keyed by index */\n activeToolBlocks: Record<\n number,\n {\n id?: string;\n name?: string;\n inputJsonParts: string[];\n }\n >;\n}\n\n/**\n * Checks if an event is an error event\n * @param event - The event to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n * @param span - The span to update\n * @returns Whether an error occurred\n */\n\nfunction isErrorEvent(event: AnthropicAiStreamingEvent, span: Span): boolean {\n if ('type' in event && typeof event.type === 'string') {\n // If the event is an error, set the span status and capture the error\n // These error events are not rejected by the API by default, but are sent as metadata of the response\n if (event.type === 'error') {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: mapAnthropicErrorToStatusMessage(event.error?.type) });\n captureException(event.error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic.anthropic_error',\n },\n });\n return true;\n }\n }\n return false;\n}\n\n/**\n * Processes the message metadata of an event\n * @param event - The event to process\n * @param state - The state of the streaming process\n */\n\nfunction handleMessageMetadata(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n // Cumulative token counts and the final stop reason both arrive on the message_delta event.\n // @see https://docs.anthropic.com/en/docs/build-with-claude/streaming#event-types\n if (event.type === 'message_delta') {\n if (event.usage && typeof event.usage.output_tokens === 'number') {\n state.completionTokens = event.usage.output_tokens;\n }\n if (event.delta?.stop_reason) {\n state.finishReasons.push(event.delta.stop_reason);\n }\n }\n\n if (event.message) {\n const message = event.message;\n\n if (message.id) state.responseId = message.id;\n if (message.model) state.responseModel = message.model;\n\n if (message.usage) {\n if (typeof message.usage.input_tokens === 'number') state.promptTokens = message.usage.input_tokens;\n if (typeof message.usage.cache_creation_input_tokens === 'number')\n state.cacheCreationInputTokens = message.usage.cache_creation_input_tokens;\n if (typeof message.usage.cache_read_input_tokens === 'number')\n state.cacheReadInputTokens = message.usage.cache_read_input_tokens;\n }\n }\n}\n\n/**\n * Handle start of a content block (e.g., tool_use)\n */\nfunction handleContentBlockStart(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n if (event.type !== 'content_block_start' || typeof event.index !== 'number' || !event.content_block) return;\n if (event.content_block.type === 'tool_use' || event.content_block.type === 'server_tool_use') {\n state.activeToolBlocks[event.index] = {\n id: event.content_block.id,\n name: event.content_block.name,\n inputJsonParts: [],\n };\n }\n}\n\n/**\n * Handle deltas of a content block, including input_json_delta for tool_use\n */\nfunction handleContentBlockDelta(\n event: AnthropicAiStreamingEvent,\n state: StreamingState,\n recordOutputs: boolean,\n): void {\n if (event.type !== 'content_block_delta' || !event.delta) return;\n\n // Accumulate tool_use input JSON deltas only when we have an index and an active tool block\n if (\n typeof event.index === 'number' &&\n 'partial_json' in event.delta &&\n typeof event.delta.partial_json === 'string'\n ) {\n const active = state.activeToolBlocks[event.index];\n if (active) {\n active.inputJsonParts.push(event.delta.partial_json);\n }\n }\n\n // Accumulate streamed response text regardless of index\n if (recordOutputs && typeof event.delta.text === 'string') {\n state.responseTexts.push(event.delta.text);\n }\n}\n\n/**\n * Handle stop of a content block; finalize tool_use entries\n */\nfunction handleContentBlockStop(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n if (event.type !== 'content_block_stop' || typeof event.index !== 'number') return;\n\n const active = state.activeToolBlocks[event.index];\n if (!active) return;\n\n const raw = active.inputJsonParts.join('');\n let parsedInput: unknown;\n\n try {\n parsedInput = raw ? JSON.parse(raw) : {};\n } catch {\n parsedInput = { __unparsed: raw };\n }\n\n state.toolCalls.push({\n type: 'tool_use',\n id: active.id,\n name: active.name,\n input: parsedInput,\n });\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete state.activeToolBlocks[event.index];\n}\n\n/**\n * Processes an event\n * @param event - The event to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n * @param span - The span to update\n */\nfunction processEvent(\n event: AnthropicAiStreamingEvent,\n state: StreamingState,\n recordOutputs: boolean,\n span: Span,\n): void {\n if (!(event && typeof event === 'object')) {\n return;\n }\n\n const isError = isErrorEvent(event, span);\n if (isError) return;\n\n handleMessageMetadata(event, state);\n\n // Tool call events are sent via 3 separate events:\n // - content_block_start (start of the tool call)\n // - content_block_delta (delta aka input of the tool call)\n // - content_block_stop (end of the tool call)\n // We need to handle them all to capture the full tool call.\n handleContentBlockStart(event, state);\n handleContentBlockDelta(event, state, recordOutputs);\n handleContentBlockStop(event, state);\n}\n\n/**\n * Instruments an async iterable stream of Anthropic events, updates the span with\n * streaming attributes and (optionally) the aggregated output text, and yields\n * each event from the input stream unchanged.\n */\nexport async function* instrumentAsyncIterableStream(\n stream: AsyncIterable<AnthropicAiStreamingEvent>,\n span: Span,\n recordOutputs: boolean,\n): AsyncGenerator<AnthropicAiStreamingEvent, void, unknown> {\n const state: StreamingState = {\n responseTexts: [],\n finishReasons: [],\n responseId: '',\n responseModel: '',\n promptTokens: undefined,\n completionTokens: undefined,\n cacheCreationInputTokens: undefined,\n cacheReadInputTokens: undefined,\n toolCalls: [],\n activeToolBlocks: {},\n };\n\n try {\n for await (const event of stream) {\n processEvent(event, state, recordOutputs, span);\n yield event;\n }\n } finally {\n endStreamSpan(span, state, recordOutputs);\n }\n}\n\n/**\n * Instruments a MessageStream by registering event handlers and preserving the original stream API.\n */\nexport function instrumentMessageStream<R extends { on: (...args: unknown[]) => void }>(\n stream: R,\n span: Span,\n recordOutputs: boolean,\n): R {\n const state: StreamingState = {\n responseTexts: [],\n finishReasons: [],\n responseId: '',\n responseModel: '',\n promptTokens: undefined,\n completionTokens: undefined,\n cacheCreationInputTokens: undefined,\n cacheReadInputTokens: undefined,\n toolCalls: [],\n activeToolBlocks: {},\n };\n\n stream.on('streamEvent', (event: unknown) => {\n processEvent(event as AnthropicAiStreamingEvent, state, recordOutputs, span);\n });\n\n // The event fired when a message is done being streamed by the API. Corresponds to the message_stop SSE event.\n // @see https://github.com/anthropics/anthropic-sdk-typescript/blob/d3be31f5a4e6ebb4c0a2f65dbb8f381ae73a9166/helpers.md?plain=1#L42-L44\n stream.on('message', () => {\n endStreamSpan(span, state, recordOutputs);\n });\n\n stream.on('error', (error: unknown) => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic.stream_error',\n },\n });\n\n if (span.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n span.end();\n }\n });\n\n return stream;\n}\n"],"names":["SPAN_STATUS_ERROR","mapAnthropicErrorToStatusMessage","captureException","endStreamSpan"],"mappings":";;;;;;;AAiDA,SAAS,YAAA,CAAa,OAAkC,IAAA,EAAqB;AAC3E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A,IAClB,wBAAA,EAA0B,MAAA;AAAA,IAC1B,oBAAA,EAAsB,MAAA;AAAA,IACtB,WAAW,EAAC;AAAA,IACZ,kBAAkB;AAAC,GACrB;AAEA,EAAA,MAAA,CAAO,EAAA,CAAG,aAAA,EAAe,CAAC,KAAA,KAAmB;AAC3C,IAAA,YAAA,CAAa,KAAA,EAAoC,KAAA,EAAO,aAAA,EAAe,IAAI,CAAA;AAAA,EAC7E,CAAC,CAAA;AAID,EAAA,MAAA,CAAO,EAAA,CAAG,WAAW,MAAM;AACzB,IAAAA,mBAAA,CAAc,IAAA,EAAM,OAAO,aAAa,CAAA;AAAA,EAC1C,CAAC,CAAA;AAED,EAAA,MAAA,CAAO,EAAA,CAAG,OAAA,EAAS,CAAC,KAAA,KAAmB;AACrC,IAAAD,0BAAA,CAAiB,KAAA,EAAO;AAAA,MACtB,SAAA,EAAW;AAAA,QACT,OAAA,EAAS,KAAA;AAAA,QACT,IAAA,EAAM;AAAA;AACR,KACD,CAAA;AAED,IAAA,IAAI,IAAA,CAAK,aAAY,EAAG;AACtB,MAAA,IAAA,CAAK,UAAU,EAAE,IAAA,EAAMF,4BAAA,EAAmB,OAAA,EAAS,kBAAkB,CAAA;AACrE,MAAA,IAAA,CAAK,GAAA,EAAI;AAAA,IACX;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,MAAA;AACT;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const attributes = require('@sentry/conventions/attributes'); | ||
| const constants = require('../constants.js'); | ||
@@ -68,3 +69,3 @@ const currentScopes = require('../currentScopes.js'); | ||
| const dsc = getDynamicSamplingContextFromClient(span.spanContext().traceId, client); | ||
| const source = rootSpanAttributes[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] ?? rootSpanAttributes["sentry.span.source"]; | ||
| const source = rootSpanAttributes[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] ?? rootSpanAttributes[attributes.SENTRY_SPAN_SOURCE]; | ||
| const name = rootSpanJson.description; | ||
@@ -71,0 +72,0 @@ if (source !== "url" && name) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"dynamicSamplingContext.js","sources":["../../../src/tracing/dynamicSamplingContext.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { DEFAULT_ENVIRONMENT } from '../constants';\nimport { getClient } from '../currentScopes';\nimport type { Scope } from '../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { DynamicSamplingContext } from '../types/envelope';\nimport type { Span } from '../types/span';\nimport { baggageHeaderToDynamicSamplingContext, dynamicSamplingContextToSentryBaggageHeader } from '../utils/baggage';\nimport { extractOrgIdFromClient } from '../utils/dsn';\nimport { hasSpansEnabled } from '../utils/hasSpansEnabled';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { getRootSpan, spanIsSampled, spanToJSON } from '../utils/spanUtils';\nimport { spanIsNonRecordingSpan } from './sentryNonRecordingSpan';\nimport { getCapturedScopesOnSpan } from './utils';\n\n/**\n * If you change this value, also update the terser plugin config to\n * avoid minification of the object property!\n */\nconst FROZEN_DSC_FIELD = '_frozenDsc';\n\ntype SpanWithMaybeDsc = Span & {\n [FROZEN_DSC_FIELD]?: Partial<DynamicSamplingContext> | undefined;\n};\n\n/**\n * Freeze the given DSC on the given span.\n */\nexport function freezeDscOnSpan(span: Span, dsc: Partial<DynamicSamplingContext>): void {\n const spanWithMaybeDsc = span as SpanWithMaybeDsc;\n addNonEnumerableProperty(spanWithMaybeDsc, FROZEN_DSC_FIELD, dsc);\n}\n\n/**\n * Creates a dynamic sampling context from a client.\n *\n * Dispatches the `createDsc` lifecycle hook as a side effect.\n */\nexport function getDynamicSamplingContextFromClient(trace_id: string, client: Client): DynamicSamplingContext {\n const options = client.getOptions();\n\n const { publicKey: public_key } = client.getDsn() || {};\n\n // Instead of conditionally adding non-undefined values, we add them and then remove them if needed\n // otherwise, the order of baggage entries changes, which \"breaks\" a bunch of tests etc.\n const dsc: DynamicSamplingContext = {\n environment: options.environment || DEFAULT_ENVIRONMENT,\n release: options.release,\n public_key,\n trace_id,\n org_id: extractOrgIdFromClient(client),\n };\n\n client.emit('createDsc', dsc);\n\n return dsc;\n}\n\n/**\n * Get the dynamic sampling context for the currently active scopes.\n */\nexport function getDynamicSamplingContextFromScope(client: Client, scope: Scope): Partial<DynamicSamplingContext> {\n const propagationContext = scope.getPropagationContext();\n return propagationContext.dsc || getDynamicSamplingContextFromClient(propagationContext.traceId, client);\n}\n\n/**\n * Creates a dynamic sampling context from a span (and client and scope)\n *\n * @param span the span from which a few values like the root span name and sample rate are extracted.\n *\n * @returns a dynamic sampling context\n */\nexport function getDynamicSamplingContextFromSpan(span: Span): Readonly<Partial<DynamicSamplingContext>> {\n const client = getClient();\n if (!client) {\n return {};\n }\n\n const rootSpan = getRootSpan(span);\n const rootSpanJson = spanToJSON(rootSpan);\n const rootSpanAttributes = rootSpanJson.data;\n const traceState = rootSpan.spanContext().traceState;\n\n // The span sample rate that was locally applied to the root span should also always be applied to the DSC, even if the DSC is frozen.\n // This is so that the downstream traces/services can use parentSampleRate in their `tracesSampler` to make consistent sampling decisions across the entire trace.\n const rootSpanSampleRate =\n traceState?.get('sentry.sample_rate') ??\n rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE] ??\n rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE];\n\n function applyLocalSampleRateToDsc(dsc: Partial<DynamicSamplingContext>): Partial<DynamicSamplingContext> {\n if (typeof rootSpanSampleRate === 'number' || typeof rootSpanSampleRate === 'string') {\n dsc.sample_rate = `${rootSpanSampleRate}`;\n }\n return dsc;\n }\n\n // For core implementation, we freeze the DSC onto the span as a non-enumerable property\n const frozenDsc = (rootSpan as SpanWithMaybeDsc)[FROZEN_DSC_FIELD];\n if (frozenDsc) {\n return applyLocalSampleRateToDsc(frozenDsc);\n }\n\n // For a non-recording placeholder in Tracing without Performance (TwP) mode, the DSC is not\n // carried on the span; the scope is the source of truth. Resolve it from the span's captured\n // scope: continued traces keep the incoming DSC, new traces derive it from the client.\n //\n // We gate this on `!hasSpansEnabled()` so it mirrors the `sentry-trace` source in `getTraceData`:\n // with tracing enabled, a non-recording span (e.g. an `onlyIfParent` placeholder) keeps deriving\n // its DSC from the span/client so the baggage agrees with the `-0` decision that `spanToTraceHeader`\n // encodes for `sentry-trace`. Without this guard the two headers can disagree.\n //\n // We spread into a new object so applying the local sample rate can't mutate the scope's DSC.\n if (spanIsNonRecordingSpan(rootSpan) && !hasSpansEnabled(client.getOptions())) {\n const capturedScope = getCapturedScopesOnSpan(rootSpan).scope;\n if (capturedScope) {\n return applyLocalSampleRateToDsc({ ...getDynamicSamplingContextFromScope(client, capturedScope) });\n }\n }\n\n // For OpenTelemetry, we freeze the DSC on the trace state\n const traceStateDsc = traceState?.get('sentry.dsc');\n\n // If the span has a DSC, we want it to take precedence\n const dscOnTraceState = traceStateDsc && baggageHeaderToDynamicSamplingContext(traceStateDsc);\n\n if (dscOnTraceState) {\n return applyLocalSampleRateToDsc(dscOnTraceState);\n }\n\n // Else, we generate it from the span\n const dsc = getDynamicSamplingContextFromClient(span.spanContext().traceId, client);\n\n // We don't want to have a transaction name in the DSC if the source is \"url\" because URLs might contain PII\n // TODO(v11): Only read `SEMANTIC_ATTRIBUTE_SENTRY_SOURCE` again, once we renamed it to `sentry.span.source`\n const source = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] ?? rootSpanAttributes['sentry.span.source'];\n\n // after JSON conversion, txn.name becomes jsonSpan.description\n const name = rootSpanJson.description;\n if (source !== 'url' && name) {\n dsc.transaction = name;\n }\n\n // How can we even land here with hasSpansEnabled() returning false?\n // Otel creates a Non-recording span in Tracing Without Performance mode when handling incoming requests\n // So we end up with an active span that is not sampled (neither positively nor negatively)\n if (hasSpansEnabled()) {\n dsc.sampled = String(spanIsSampled(rootSpan));\n dsc.sample_rand =\n // In OTEL we store the sample rand on the trace state because we cannot access scopes for NonRecordingSpans\n // The Sentry OTEL SpanSampler takes care of writing the sample rand on the root span\n traceState?.get('sentry.sample_rand') ??\n // On all other platforms we can actually get the scopes from a root span (we use this as a fallback)\n getCapturedScopesOnSpan(rootSpan).scope?.getPropagationContext().sampleRand.toString();\n }\n\n applyLocalSampleRateToDsc(dsc);\n\n client.emit('createDsc', dsc, rootSpan);\n\n return dsc;\n}\n\n/**\n * Convert a Span to a baggage header.\n */\nexport function spanToBaggageHeader(span: Span): string | undefined {\n const dsc = getDynamicSamplingContextFromSpan(span);\n return dynamicSamplingContextToSentryBaggageHeader(dsc);\n}\n"],"names":["addNonEnumerableProperty","DEFAULT_ENVIRONMENT","extractOrgIdFromClient","getClient","getRootSpan","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE","SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE","dsc","spanIsNonRecordingSpan","hasSpansEnabled","getCapturedScopesOnSpan","baggageHeaderToDynamicSamplingContext","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","spanIsSampled","dynamicSamplingContextToSentryBaggageHeader"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,gBAAA,GAAmB,YAAA;AASlB,SAAS,eAAA,CAAgB,MAAY,GAAA,EAA4C;AACtF,EAAA,MAAM,gBAAA,GAAmB,IAAA;AACzB,EAAAA,+BAAA,CAAyB,gBAAA,EAAkB,kBAAkB,GAAG,CAAA;AAClE;AAOO,SAAS,mCAAA,CAAoC,UAAkB,MAAA,EAAwC;AAC5G,EAAA,MAAM,OAAA,GAAU,OAAO,UAAA,EAAW;AAElC,EAAA,MAAM,EAAE,SAAA,EAAW,UAAA,KAAe,MAAA,CAAO,MAAA,MA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AAsB,CAAE,WAAW,QAAA,EAAS;AAAA,EACzF;AAEA,EAAA,yBAAA,CAA0B,GAAG,CAAA;AAE7B,EAAA,MAAA,CAAO,IAAA,CAAK,WAAA,EAAa,GAAA,EAAK,QAAQ,CAAA;AAEtC,EAAA,OAAO,GAAA;AACT;AAKO,SAAS,oBAAoB,IAAA,EAAgC;AAClE,EAAA,MAAM,GAAA,GAAM,kCAAkC,IAAI,CAAA;AAClD,EAAA,OAAOI,oDAA4C,GAAG,CAAA;AACxD;;;;;;;;"} | ||
| {"version":3,"file":"dynamicSamplingContext.js","sources":["../../../src/tracing/dynamicSamplingContext.ts"],"sourcesContent":["import { SENTRY_SPAN_SOURCE } from '@sentry/conventions/attributes';\nimport type { Client } from '../client';\nimport { DEFAULT_ENVIRONMENT } from '../constants';\nimport { getClient } from '../currentScopes';\nimport type { Scope } from '../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { DynamicSamplingContext } from '../types/envelope';\nimport type { Span } from '../types/span';\nimport { baggageHeaderToDynamicSamplingContext, dynamicSamplingContextToSentryBaggageHeader } from '../utils/baggage';\nimport { extractOrgIdFromClient } from '../utils/dsn';\nimport { hasSpansEnabled } from '../utils/hasSpansEnabled';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { getRootSpan, spanIsSampled, spanToJSON } from '../utils/spanUtils';\nimport { spanIsNonRecordingSpan } from './sentryNonRecordingSpan';\nimport { getCapturedScopesOnSpan } from './utils';\n\n/**\n * If you change this value, also update the terser plugin config to\n * avoid minification of the object property!\n */\nconst FROZEN_DSC_FIELD = '_frozenDsc';\n\ntype SpanWithMaybeDsc = Span & {\n [FROZEN_DSC_FIELD]?: Partial<DynamicSamplingContext> | undefined;\n};\n\n/**\n * Freeze the given DSC on the given span.\n */\nexport function freezeDscOnSpan(span: Span, dsc: Partial<DynamicSamplingContext>): void {\n const spanWithMaybeDsc = span as SpanWithMaybeDsc;\n addNonEnumerableProperty(spanWithMaybeDsc, FROZEN_DSC_FIELD, dsc);\n}\n\n/**\n * Creates a dynamic sampling context from a client.\n *\n * Dispatches the `createDsc` lifecycle hook as a side effect.\n */\nexport function getDynamicSamplingContextFromClient(trace_id: string, client: Client): DynamicSamplingContext {\n const options = client.getOptions();\n\n const { publicKey: public_key } = client.getDsn() || {};\n\n // Instead of conditionally adding non-undefined values, we add them and then remove them if needed\n // otherwise, the order of baggage entries changes, which \"breaks\" a bunch of tests etc.\n const dsc: DynamicSamplingContext = {\n environment: options.environment || DEFAULT_ENVIRONMENT,\n release: options.release,\n public_key,\n trace_id,\n org_id: extractOrgIdFromClient(client),\n };\n\n client.emit('createDsc', dsc);\n\n return dsc;\n}\n\n/**\n * Get the dynamic sampling context for the currently active scopes.\n */\nexport function getDynamicSamplingContextFromScope(client: Client, scope: Scope): Partial<DynamicSamplingContext> {\n const propagationContext = scope.getPropagationContext();\n return propagationContext.dsc || getDynamicSamplingContextFromClient(propagationContext.traceId, client);\n}\n\n/**\n * Creates a dynamic sampling context from a span (and client and scope)\n *\n * @param span the span from which a few values like the root span name and sample rate are extracted.\n *\n * @returns a dynamic sampling context\n */\nexport function getDynamicSamplingContextFromSpan(span: Span): Readonly<Partial<DynamicSamplingContext>> {\n const client = getClient();\n if (!client) {\n return {};\n }\n\n const rootSpan = getRootSpan(span);\n const rootSpanJson = spanToJSON(rootSpan);\n const rootSpanAttributes = rootSpanJson.data;\n const traceState = rootSpan.spanContext().traceState;\n\n // The span sample rate that was locally applied to the root span should also always be applied to the DSC, even if the DSC is frozen.\n // This is so that the downstream traces/services can use parentSampleRate in their `tracesSampler` to make consistent sampling decisions across the entire trace.\n const rootSpanSampleRate =\n traceState?.get('sentry.sample_rate') ??\n rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE] ??\n rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE];\n\n function applyLocalSampleRateToDsc(dsc: Partial<DynamicSamplingContext>): Partial<DynamicSamplingContext> {\n if (typeof rootSpanSampleRate === 'number' || typeof rootSpanSampleRate === 'string') {\n dsc.sample_rate = `${rootSpanSampleRate}`;\n }\n return dsc;\n }\n\n // For core implementation, we freeze the DSC onto the span as a non-enumerable property\n const frozenDsc = (rootSpan as SpanWithMaybeDsc)[FROZEN_DSC_FIELD];\n if (frozenDsc) {\n return applyLocalSampleRateToDsc(frozenDsc);\n }\n\n // For a non-recording placeholder in Tracing without Performance (TwP) mode, the DSC is not\n // carried on the span; the scope is the source of truth. Resolve it from the span's captured\n // scope: continued traces keep the incoming DSC, new traces derive it from the client.\n //\n // We gate this on `!hasSpansEnabled()` so it mirrors the `sentry-trace` source in `getTraceData`:\n // with tracing enabled, a non-recording span (e.g. an `onlyIfParent` placeholder) keeps deriving\n // its DSC from the span/client so the baggage agrees with the `-0` decision that `spanToTraceHeader`\n // encodes for `sentry-trace`. Without this guard the two headers can disagree.\n //\n // We spread into a new object so applying the local sample rate can't mutate the scope's DSC.\n if (spanIsNonRecordingSpan(rootSpan) && !hasSpansEnabled(client.getOptions())) {\n const capturedScope = getCapturedScopesOnSpan(rootSpan).scope;\n if (capturedScope) {\n return applyLocalSampleRateToDsc({ ...getDynamicSamplingContextFromScope(client, capturedScope) });\n }\n }\n\n // For OpenTelemetry, we freeze the DSC on the trace state\n const traceStateDsc = traceState?.get('sentry.dsc');\n\n // If the span has a DSC, we want it to take precedence\n const dscOnTraceState = traceStateDsc && baggageHeaderToDynamicSamplingContext(traceStateDsc);\n\n if (dscOnTraceState) {\n return applyLocalSampleRateToDsc(dscOnTraceState);\n }\n\n // Else, we generate it from the span\n const dsc = getDynamicSamplingContextFromClient(span.spanContext().traceId, client);\n\n // We don't want to have a transaction name in the DSC if the source is \"url\" because URLs might contain PII\n // TODO(v11): Only read `SENTRY_SPAN_SOURCE` once we removed `SEMANTIC_ATTRIBUTE_SENTRY_SOURCE`\n const source = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] ?? rootSpanAttributes[SENTRY_SPAN_SOURCE];\n\n // after JSON conversion, txn.name becomes jsonSpan.description\n const name = rootSpanJson.description;\n if (source !== 'url' && name) {\n dsc.transaction = name;\n }\n\n // How can we even land here with hasSpansEnabled() returning false?\n // Otel creates a Non-recording span in Tracing Without Performance mode when handling incoming requests\n // So we end up with an active span that is not sampled (neither positively nor negatively)\n if (hasSpansEnabled()) {\n dsc.sampled = String(spanIsSampled(rootSpan));\n dsc.sample_rand =\n // In OTEL we store the sample rand on the trace state because we cannot access scopes for NonRecordingSpans\n // The Sentry OTEL SpanSampler takes care of writing the sample rand on the root span\n traceState?.get('sentry.sample_rand') ??\n // On all other platforms we can actually get the scopes from a root span (we use this as a fallback)\n getCapturedScopesOnSpan(rootSpan).scope?.getPropagationContext().sampleRand.toString();\n }\n\n applyLocalSampleRateToDsc(dsc);\n\n client.emit('createDsc', dsc, rootSpan);\n\n return dsc;\n}\n\n/**\n * Convert a Span to a baggage header.\n */\nexport function spanToBaggageHeader(span: Span): string | undefined {\n const dsc = getDynamicSamplingContextFromSpan(span);\n return dynamicSamplingContextToSentryBaggageHeader(dsc);\n}\n"],"names":["addNonEnumerableProperty","DEFAULT_ENVIRONMENT","extractOrgIdFromClient","getClient","getRootSpan","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE","SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE","dsc","spanIsNonRecordingSpan","hasSpansEnabled","getCapturedScopesOnSpan","baggageHeaderToDynamicSamplingContext","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SENTRY_SPAN_SOURCE","spanIsSampled","dynamicSamplingContextToSentryBaggageHeader"],"mappings":";;;;;;;;;;;;;;AAwBA,MAAM,gBAAA,GAAmB,YAAA;AASlB,SA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AAC5B,IAAA,GAAA,CAAI,WAAA,GAAc,IAAA;AAAA,EACpB;AAKA,EAAA,IAAIJ,iCAAgB,EAAG;AACrB,IAAA,GAAA,CAAI,OAAA,GAAU,MAAA,CAAOK,uBAAA,CAAc,QAAQ,CAAC,CAAA;AAC5C,IAAA,GAAA,CAAI,WAAA;AAAA;AAAA,IAGF,UAAA,EAAY,IAAI,oBAAoB,CAAA;AAAA,IAEpCJ,8BAAwB,QAAQ,CAAA,CAAE,OAAO,qBAAA,EAAsB,CAAE,WAAW,QAAA,EAAS;AAAA,EACzF;AAEA,EAAA,yBAAA,CAA0B,GAAG,CAAA;AAE7B,EAAA,MAAA,CAAO,IAAA,CAAK,WAAA,EAAa,GAAA,EAAK,QAAQ,CAAA;AAEtC,EAAA,OAAO,GAAA;AACT;AAKO,SAAS,oBAAoB,IAAA,EAAgC;AAClE,EAAA,MAAM,GAAA,GAAM,kCAAkC,IAAI,CAAA;AAClD,EAAA,OAAOK,oDAA4C,GAAG,CAAA;AACxD;;;;;;;;"} |
@@ -182,3 +182,5 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| exports.addRequestAttributes = addRequestAttributes; | ||
| exports.extractRequestAttributes = extractRequestAttributes; | ||
| exports.instrumentOpenAiClient = instrumentOpenAiClient; | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/openai/index.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../../debug-build';\nimport { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpan, startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types/span';\nimport { debug } from '../../utils/debug-logger';\nimport {\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { InstrumentedMethodEntry } from '../ai/utils';\nimport {\n buildMethodPath,\n extractSystemInstructions,\n getJsonString,\n getTruncatedJsonString,\n resolveAIRecordingOptions,\n shouldEnableTruncation,\n wrapPromiseWithMethods,\n} from '../ai/utils';\nimport { OPENAI_METHOD_REGISTRY } from './constants';\nimport { instrumentStream } from './streaming';\nimport type { ChatCompletionChunk, OpenAiOptions, OpenAIStream, ResponseStreamingEvent } from './types';\nimport { addResponseAttributes, extractRequestParameters } from './utils';\n\n/**\n * Extract available tools from request parameters\n */\nfunction extractAvailableTools(params: Record<string, unknown>): string | undefined {\n const tools = Array.isArray(params.tools) ? params.tools : [];\n const hasWebSearchOptions = params.web_search_options && typeof params.web_search_options === 'object';\n const webSearchOptions = hasWebSearchOptions\n ? [{ type: 'web_search_options', ...(params.web_search_options as Record<string, unknown>) }]\n : [];\n\n const availableTools = [...tools, ...webSearchOptions];\n if (availableTools.length === 0) {\n return undefined;\n }\n\n try {\n return JSON.stringify(availableTools);\n } catch (error) {\n DEBUG_BUILD && debug.error('Failed to serialize OpenAI tools:', error);\n return undefined;\n }\n}\n\n/**\n * Extract request attributes from method arguments\n */\nfunction extractRequestAttributes(args: unknown[], operationName: string): Record<string, unknown> {\n const attributes: Record<string, unknown> = {\n [GEN_AI_SYSTEM_ATTRIBUTE]: 'openai',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: operationName,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.openai',\n };\n\n if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null) {\n const params = args[0] as Record<string, unknown>;\n\n const availableTools = extractAvailableTools(params);\n if (availableTools) {\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = availableTools;\n }\n\n Object.assign(attributes, extractRequestParameters(params));\n } else {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = 'unknown';\n }\n\n return attributes;\n}\n\n// Extract and record AI request inputs, if present. This is intentionally separate from response attributes.\nfunction addRequestAttributes(\n span: Span,\n params: Record<string, unknown>,\n operationName: string,\n enableTruncation: boolean,\n): void {\n // Store embeddings input on a separate attribute and do not truncate it\n if (operationName === 'embeddings' && 'input' in params) {\n const input = params.input;\n\n // No input provided\n if (input == null) {\n return;\n }\n\n // Empty input string\n if (typeof input === 'string' && input.length === 0) {\n return;\n }\n\n // Empty array input\n if (Array.isArray(input) && input.length === 0) {\n return;\n }\n\n // Store strings as-is, arrays/objects as JSON\n span.setAttribute(GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE, typeof input === 'string' ? input : JSON.stringify(input));\n return;\n }\n\n const src = 'input' in params ? params.input : 'messages' in params ? params.messages : undefined;\n\n if (!src) {\n return;\n }\n\n if (Array.isArray(src) && src.length === 0) {\n return;\n }\n\n const { systemInstructions, filteredMessages } = extractSystemInstructions(src);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n span.setAttribute(\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n enableTruncation ? getTruncatedJsonString(filteredMessages) : getJsonString(filteredMessages),\n );\n\n if (Array.isArray(filteredMessages)) {\n span.setAttribute(GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, filteredMessages.length);\n } else {\n span.setAttribute(GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, 1);\n }\n}\n\n/**\n * Instrument a method with Sentry spans\n * Following Sentry AI Agents Manual Instrumentation conventions\n * @see https://docs.sentry.io/platforms/javascript/guides/node/tracing/instrumentation/ai-agents-module/#manual-instrumentation\n */\nfunction instrumentMethod<T extends unknown[], R>(\n originalMethod: (...args: T) => Promise<R>,\n methodPath: string,\n instrumentedMethod: InstrumentedMethodEntry,\n context: unknown,\n options: OpenAiOptions,\n): (...args: T) => Promise<R> {\n return function instrumentedCall(...args: T): Promise<R> {\n const operationName = instrumentedMethod.operation || 'unknown';\n const requestAttributes = extractRequestAttributes(args, operationName);\n const model = (requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] as string) || 'unknown';\n\n const params = args[0] as Record<string, unknown> | undefined;\n const isStreamRequested = params && typeof params === 'object' && params.stream === true;\n\n const spanConfig = {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n };\n\n if (isStreamRequested) {\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpanManual(spanConfig, (span: Span) => {\n originalResult = originalMethod.apply(context, args);\n\n if (options.recordInputs && params) {\n addRequestAttributes(span, params, operationName, shouldEnableTruncation(options.enableTruncation));\n }\n\n // Return async processing\n return (async () => {\n try {\n const result = await originalResult;\n return instrumentStream(\n result as OpenAIStream<ChatCompletionChunk | ResponseStreamingEvent>,\n span,\n options.recordOutputs ?? false,\n ) as unknown as R;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.openai.stream',\n data: { function: methodPath },\n },\n });\n span.end();\n throw error;\n }\n })();\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.openai');\n }\n\n // Non-streaming\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpan(spanConfig, (span: Span) => {\n // Call synchronously to capture the promise\n originalResult = originalMethod.apply(context, args);\n\n if (options.recordInputs && params) {\n addRequestAttributes(span, params, operationName, shouldEnableTruncation(options.enableTruncation));\n }\n\n return originalResult.then(\n result => {\n addResponseAttributes(span, result, options.recordOutputs);\n return result;\n },\n error => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.openai',\n data: { function: methodPath },\n },\n });\n throw error;\n },\n );\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.openai');\n };\n}\n\n/**\n * Create a deep proxy for OpenAI client instrumentation\n */\nfunction createDeepProxy<T extends object>(target: T, currentPath = '', options: OpenAiOptions): T {\n return new Proxy(target, {\n get(obj: object, prop: string): unknown {\n const value = (obj as Record<string, unknown>)[prop];\n const methodPath = buildMethodPath(currentPath, String(prop));\n\n const instrumentedMethod = OPENAI_METHOD_REGISTRY[methodPath as keyof typeof OPENAI_METHOD_REGISTRY];\n if (typeof value === 'function' && instrumentedMethod) {\n return instrumentMethod(\n value as (...args: unknown[]) => Promise<unknown>,\n methodPath,\n instrumentedMethod,\n obj,\n options,\n );\n }\n\n if (typeof value === 'function') {\n // Bind non-instrumented functions to preserve the original `this` context,\n // which is required for accessing private class fields (e.g. #baseURL) in OpenAI SDK v5.\n return value.bind(obj);\n }\n\n if (value && typeof value === 'object') {\n return createDeepProxy(value, methodPath, options);\n }\n\n return value;\n },\n }) as T;\n}\n\n/**\n * Instrument an OpenAI client with Sentry tracing\n * Can be used across Node.js, Cloudflare Workers, and Vercel Edge\n */\nexport function instrumentOpenAiClient<T extends object>(client: T, options?: OpenAiOptions): T {\n return createDeepProxy(client, '', resolveAIRecordingOptions(options));\n}\n"],"names":["DEBUG_BUILD","debug","GEN_AI_SYSTEM_ATTRIBUTE","GEN_AI_OPERATION_NAME_ATTRIBUTE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","extractRequestParameters","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE","extractSystemInstructions","GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE","GEN_AI_INPUT_MESSAGES_ATTRIBUTE","getTruncatedJsonString","getJsonString","GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE","originalResult","instrumentedPromise","startSpanManual","shouldEnableTruncation","instrumentStream","SPAN_STATUS_ERROR","captureException","wrapPromiseWithMethods","startSpan","addResponseAttributes","buildMethodPath","OPENAI_METHOD_REGISTRY","resolveAIRecordingOptions"],"mappings":";;;;;;;;;;;;;;AAmCA,SAAS,sBAAsB,MAAA,EAAqD;AAClF,EAAA,MAAM,KAAA,GAAQ,MAAM,OAAA,CAAQ,MAAA,CAAO,KAAK,CAAA,GAAI,MAAA,CAAO,QAAQ,EAAC;AAC5D,EAAA,MAAM,mBAAA,GAAsB,MAAA,CAAO,kBAAA,IAAsB,OAAO,OAAO,kBAAA,KAAuB,QAAA;AAC9F,EAAA,MAAM,gBAAA,GAAmB,mBAAA,GACrB,CAAC,EAAE,IAAA,EAAM,oBAAA,EAAsB,GAAI,MAAA,CAAO,kBAAA,EAAgD,CAAA,GAC1F,EAAC;AAEL,EAAA,MAAM,cAAA,GAAiB,CAAC,GAAG,KAAA,EAAO,GAAG,gBAAgB,CAAA;AACrD,EAAA,IAAI,cAAA,CAAe,WAAW,CAAA,EAAG;AAC/B,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,IAAI;AACF,IAAA,OAAO,IAAA,CAAK,UAAU,cAAc,CAAA;AAAA,EACtC,SAAS,KAAA,EAAO;AACd,IAAAA,sBAAA,IAAeC,iBAAA,CAAM,KAAA,CAAM,mCAAA,EAAqC,KAAK,CAAA;AACrE,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAKA,SAAS,wBAAA,CAAyB,MAAiB,aAAA,EAAgD;AACjG,EAAA,MAAM,UAAA,GAAsC;AAAA,IAC1C,CAACC,uCAAuB,GAAG,QAAA;AAAA,IAC3B,CAACC,+CAA+B,GAAG,aAAA;AAAA,IACnC,CAACC,mDAAgC,GAAG;AAAA,GACtC;AAEA,EAAA,IAAI,IAAA,CAA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,IAAI,CAAC,CAAA;AAE5D,MAAA,MAAM,kBAAA,GAAqBC,iCAAuB,UAAiD,CAAA;AACnG,MAAA,IAAI,OAAO,KAAA,KAAU,UAAA,IAAc,kBAAA,EAAoB;AACrD,QAAA,OAAO,gBAAA;AAAA,UACL,KAAA;AAAA,UACA,UAAA;AAAA,UACA,kBAAA;AAAA,UACA,GAAA;AAAA,UACA;AAAA,SACF;AAAA,MACF;AAEA,MAAA,IAAI,OAAO,UAAU,UAAA,EAAY;AAG/B,QAAA,OAAO,KAAA,CAAM,KAAK,GAAG,CAAA;AAAA,MACvB;AAEA,MAAA,IAAI,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,EAAU;AACtC,QAAA,OAAO,eAAA,CAAgB,KAAA,EAAO,UAAA,EAAY,OAAO,CAAA;AAAA,MACnD;AAEA,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,GACD,CAAA;AACH;AAMO,SAAS,sBAAA,CAAyC,QAAW,OAAA,EAA4B;AAC9F,EAAA,OAAO,eAAA,CAAgB,MAAA,EAAQ,EAAA,EAAIC,+BAAA,CAA0B,OAAO,CAAC,CAAA;AACvE;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/openai/index.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../../debug-build';\nimport { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpan, startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types/span';\nimport { debug } from '../../utils/debug-logger';\nimport {\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { InstrumentedMethodEntry } from '../ai/utils';\nimport {\n buildMethodPath,\n extractSystemInstructions,\n getJsonString,\n getTruncatedJsonString,\n resolveAIRecordingOptions,\n shouldEnableTruncation,\n wrapPromiseWithMethods,\n} from '../ai/utils';\nimport { OPENAI_METHOD_REGISTRY } from './constants';\nimport { instrumentStream } from './streaming';\nimport type { ChatCompletionChunk, OpenAiOptions, OpenAIStream, ResponseStreamingEvent } from './types';\nimport { addResponseAttributes, extractRequestParameters } from './utils';\n\n/**\n * Extract available tools from request parameters\n */\nfunction extractAvailableTools(params: Record<string, unknown>): string | undefined {\n const tools = Array.isArray(params.tools) ? params.tools : [];\n const hasWebSearchOptions = params.web_search_options && typeof params.web_search_options === 'object';\n const webSearchOptions = hasWebSearchOptions\n ? [{ type: 'web_search_options', ...(params.web_search_options as Record<string, unknown>) }]\n : [];\n\n const availableTools = [...tools, ...webSearchOptions];\n if (availableTools.length === 0) {\n return undefined;\n }\n\n try {\n return JSON.stringify(availableTools);\n } catch (error) {\n DEBUG_BUILD && debug.error('Failed to serialize OpenAI tools:', error);\n return undefined;\n }\n}\n\n/**\n * Extract request attributes from method arguments\n */\nexport function extractRequestAttributes(args: unknown[], operationName: string): Record<string, unknown> {\n const attributes: Record<string, unknown> = {\n [GEN_AI_SYSTEM_ATTRIBUTE]: 'openai',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: operationName,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.openai',\n };\n\n if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null) {\n const params = args[0] as Record<string, unknown>;\n\n const availableTools = extractAvailableTools(params);\n if (availableTools) {\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = availableTools;\n }\n\n Object.assign(attributes, extractRequestParameters(params));\n } else {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = 'unknown';\n }\n\n return attributes;\n}\n\n// Extract and record AI request inputs, if present. This is intentionally separate from response attributes.\nexport function addRequestAttributes(\n span: Span,\n params: Record<string, unknown>,\n operationName: string,\n enableTruncation: boolean,\n): void {\n // Store embeddings input on a separate attribute and do not truncate it\n if (operationName === 'embeddings' && 'input' in params) {\n const input = params.input;\n\n // No input provided\n if (input == null) {\n return;\n }\n\n // Empty input string\n if (typeof input === 'string' && input.length === 0) {\n return;\n }\n\n // Empty array input\n if (Array.isArray(input) && input.length === 0) {\n return;\n }\n\n // Store strings as-is, arrays/objects as JSON\n span.setAttribute(GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE, typeof input === 'string' ? input : JSON.stringify(input));\n return;\n }\n\n const src = 'input' in params ? params.input : 'messages' in params ? params.messages : undefined;\n\n if (!src) {\n return;\n }\n\n if (Array.isArray(src) && src.length === 0) {\n return;\n }\n\n const { systemInstructions, filteredMessages } = extractSystemInstructions(src);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n span.setAttribute(\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n enableTruncation ? getTruncatedJsonString(filteredMessages) : getJsonString(filteredMessages),\n );\n\n if (Array.isArray(filteredMessages)) {\n span.setAttribute(GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, filteredMessages.length);\n } else {\n span.setAttribute(GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, 1);\n }\n}\n\n/**\n * Instrument a method with Sentry spans\n * Following Sentry AI Agents Manual Instrumentation conventions\n * @see https://docs.sentry.io/platforms/javascript/guides/node/tracing/instrumentation/ai-agents-module/#manual-instrumentation\n */\nfunction instrumentMethod<T extends unknown[], R>(\n originalMethod: (...args: T) => Promise<R>,\n methodPath: string,\n instrumentedMethod: InstrumentedMethodEntry,\n context: unknown,\n options: OpenAiOptions,\n): (...args: T) => Promise<R> {\n return function instrumentedCall(...args: T): Promise<R> {\n const operationName = instrumentedMethod.operation || 'unknown';\n const requestAttributes = extractRequestAttributes(args, operationName);\n const model = (requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] as string) || 'unknown';\n\n const params = args[0] as Record<string, unknown> | undefined;\n const isStreamRequested = params && typeof params === 'object' && params.stream === true;\n\n const spanConfig = {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n };\n\n if (isStreamRequested) {\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpanManual(spanConfig, (span: Span) => {\n originalResult = originalMethod.apply(context, args);\n\n if (options.recordInputs && params) {\n addRequestAttributes(span, params, operationName, shouldEnableTruncation(options.enableTruncation));\n }\n\n // Return async processing\n return (async () => {\n try {\n const result = await originalResult;\n return instrumentStream(\n result as OpenAIStream<ChatCompletionChunk | ResponseStreamingEvent>,\n span,\n options.recordOutputs ?? false,\n ) as unknown as R;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.openai.stream',\n data: { function: methodPath },\n },\n });\n span.end();\n throw error;\n }\n })();\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.openai');\n }\n\n // Non-streaming\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpan(spanConfig, (span: Span) => {\n // Call synchronously to capture the promise\n originalResult = originalMethod.apply(context, args);\n\n if (options.recordInputs && params) {\n addRequestAttributes(span, params, operationName, shouldEnableTruncation(options.enableTruncation));\n }\n\n return originalResult.then(\n result => {\n addResponseAttributes(span, result, options.recordOutputs);\n return result;\n },\n error => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.openai',\n data: { function: methodPath },\n },\n });\n throw error;\n },\n );\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.openai');\n };\n}\n\n/**\n * Create a deep proxy for OpenAI client instrumentation\n */\nfunction createDeepProxy<T extends object>(target: T, currentPath = '', options: OpenAiOptions): T {\n return new Proxy(target, {\n get(obj: object, prop: string): unknown {\n const value = (obj as Record<string, unknown>)[prop];\n const methodPath = buildMethodPath(currentPath, String(prop));\n\n const instrumentedMethod = OPENAI_METHOD_REGISTRY[methodPath as keyof typeof OPENAI_METHOD_REGISTRY];\n if (typeof value === 'function' && instrumentedMethod) {\n return instrumentMethod(\n value as (...args: unknown[]) => Promise<unknown>,\n methodPath,\n instrumentedMethod,\n obj,\n options,\n );\n }\n\n if (typeof value === 'function') {\n // Bind non-instrumented functions to preserve the original `this` context,\n // which is required for accessing private class fields (e.g. #baseURL) in OpenAI SDK v5.\n return value.bind(obj);\n }\n\n if (value && typeof value === 'object') {\n return createDeepProxy(value, methodPath, options);\n }\n\n return value;\n },\n }) as T;\n}\n\n/**\n * Instrument an OpenAI client with Sentry tracing\n * Can be used across Node.js, Cloudflare Workers, and Vercel Edge\n */\nexport function instrumentOpenAiClient<T extends object>(client: T, options?: OpenAiOptions): T {\n return createDeepProxy(client, '', resolveAIRecordingOptions(options));\n}\n"],"names":["DEBUG_BUILD","debug","GEN_AI_SYSTEM_ATTRIBUTE","GEN_AI_OPERATION_NAME_ATTRIBUTE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE","extractRequestParameters","GEN_AI_REQUEST_MODEL_ATTRIBUTE","GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE","extractSystemInstructions","GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE","GEN_AI_INPUT_MESSAGES_ATTRIBUTE","getTruncatedJsonString","getJsonString","GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE","originalResult","instrumentedPromise","startSpanManual","shouldEnableTruncation","instrumentStream","SPAN_STATUS_ERROR","captureException","wrapPromiseWithMethods","startSpan","addResponseAttributes","buildMethodPath","OPENAI_METHOD_REGISTRY","resolveAIRecordingOptions"],"mappings":";;;;;;;;;;;;;;AAmCA,SAAS,sBAAsB,MAAA,EAAqD;AAClF,EAAA,MAAM,KAAA,GAAQ,MAAM,OAAA,CAAQ,MAAA,CAAO,KAAK,CAAA,GAAI,MAAA,CAAO,QAAQ,EAAC;AAC5D,EAAA,MAAM,mBAAA,GAAsB,MAAA,CAAO,kBAAA,IAAsB,OAAO,OAAO,kBAAA,KAAuB,QAAA;AAC9F,EAAA,MAAM,gBAAA,GAAmB,mBAAA,GACrB,CAAC,EAAE,IAAA,EAAM,oBAAA,EAAsB,GAAI,MAAA,CAAO,kBAAA,EAAgD,CAAA,GAC1F,EAAC;AAEL,EAAA,MAAM,cAAA,GAAiB,CAAC,GAAG,KAAA,EAAO,GAAG,gBAAgB,CAAA;AACrD,EAAA,IAAI,cAAA,CAAe,WAAW,CAAA,EAAG;AAC/B,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,IAAI;AACF,IAAA,OAAO,IAAA,CAAK,UAAU,cAAc,CAAA;AAAA,EACtC,SAAS,KAAA,EAAO;AACd,IAAAA,sBAAA,IAAeC,iBAAA,CAAM,KAAA,CAAM,mCAAA,EAAqC,KAAK,CAAA;AACrE,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAKO,SAAS,wBAAA,CAAyB,MAAiB,aAAA,EAAgD;AACxG,EAAA,MAAM,UAAA,GAAsC;AAAA,IAC1C,CAACC,uCAAuB,GAAG,QAAA;AAAA,IAC3B,CAACC,+CAA+B,GAAG,aAAA;AAAA,IACnC,CAACC,mDAAgC,GAAG;AAAA,GACtC;AAEA,EAAA,IAAI,IAAA,CAAK,MAAA,GAAS,CAAA,IAAK,OAAO,IAAA,CAAK,CAAC,CAAA,KAAM,QAAA,IAAY,IAAA,CAAK,CAAC,CAAA,KAAM,IAAA,EAAM;AACtE,IAAA,MAAM,M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B;AACrD,QAAA,OAAO,gBAAA;AAAA,UACL,KAAA;AAAA,UACA,UAAA;AAAA,UACA,kBAAA;AAAA,UACA,GAAA;AAAA,UACA;AAAA,SACF;AAAA,MACF;AAEA,MAAA,IAAI,OAAO,UAAU,UAAA,EAAY;AAG/B,QAAA,OAAO,KAAA,CAAM,KAAK,GAAG,CAAA;AAAA,MACvB;AAEA,MAAA,IAAI,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,EAAU;AACtC,QAAA,OAAO,eAAA,CAAgB,KAAA,EAAO,UAAA,EAAY,OAAO,CAAA;AAAA,MACnD;AAEA,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,GACD,CAAA;AACH;AAMO,SAAS,sBAAA,CAAyC,QAAW,OAAA,EAA4B;AAC9F,EAAA,OAAO,eAAA,CAAgB,MAAA,EAAQ,EAAA,EAAIC,+BAAA,CAA0B,OAAO,CAAC,CAAA;AACvE;;;;;;"} |
@@ -14,2 +14,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const measurement = require('./measurement.js'); | ||
| const segmentSpanCaptureStrategy = require('./segmentSpanCaptureStrategy.js'); | ||
| const hasSpanStreamingEnabled = require('./spans/hasSpanStreamingEnabled.js'); | ||
@@ -56,2 +57,5 @@ const utils = require('./utils.js'); | ||
| addLink(link) { | ||
| if (this._frozen) { | ||
| return this; | ||
| } | ||
| if (this._links) { | ||
@@ -66,2 +70,5 @@ this._links.push(link); | ||
| addLinks(links) { | ||
| if (this._frozen) { | ||
| return this; | ||
| } | ||
| if (this._links) { | ||
@@ -94,2 +101,5 @@ this._links.push(...links); | ||
| setAttribute(key, value) { | ||
| if (this._frozen) { | ||
| return this; | ||
| } | ||
| if (value === void 0) { | ||
@@ -100,2 +110,5 @@ delete this._attributes[key]; | ||
| } | ||
| if (key === semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE && value !== void 0 && utils.spanShouldInferOtelSource(this)) { | ||
| utils.markSpanSourceAsExplicit(this); | ||
| } | ||
| return this; | ||
@@ -117,2 +130,5 @@ } | ||
| updateStartTime(timeInput) { | ||
| if (this._frozen) { | ||
| return; | ||
| } | ||
| this._startTime = spanUtils.spanTimeInputToSeconds(timeInput); | ||
@@ -124,2 +140,5 @@ } | ||
| setStatus(value) { | ||
| if (this._frozen) { | ||
| return this; | ||
| } | ||
| this._status = value; | ||
@@ -132,2 +151,5 @@ return this; | ||
| updateName(name) { | ||
| if (this._frozen) { | ||
| return this; | ||
| } | ||
| this._name = name; | ||
@@ -142,2 +164,3 @@ if (!utils.spanShouldInferOtelSource(this)) { | ||
| if (this._endTime) { | ||
| this._frozen = utils.spanIsTracerProviderSpan(this); | ||
| return; | ||
@@ -148,2 +171,3 @@ } | ||
| this._onSpanEnded(); | ||
| this._frozen = utils.spanIsTracerProviderSpan(this); | ||
| } | ||
@@ -209,2 +233,5 @@ /** | ||
| addEvent(name, attributesOrStartTime, startTime) { | ||
| if (this._frozen) { | ||
| return this; | ||
| } | ||
| debugBuild.DEBUG_BUILD && debugLogger.debug.log("[Tracing] Adding an event to span:", name); | ||
@@ -241,6 +268,4 @@ const time$1 = isSpanTimeInput(attributesOrStartTime) ? attributesOrStartTime : startTime || time.timestampInSeconds(); | ||
| } | ||
| const isSegmentSpan = this._isStandaloneSpan || this === spanUtils.getRootSpan(this); | ||
| if (!isSegmentSpan) { | ||
| return; | ||
| } | ||
| const rootSpan = spanUtils.getRootSpan(this); | ||
| const isSegmentSpan = this._isStandaloneSpan || this === rootSpan; | ||
| if (this._isStandaloneSpan) { | ||
@@ -256,10 +281,24 @@ if (this._sampled) { | ||
| return; | ||
| } else if (client && hasSpanStreamingEnabled.hasSpanStreamingEnabled(client)) { | ||
| } | ||
| if (!isSegmentSpan) { | ||
| const strategy2 = segmentSpanCaptureStrategy.getSegmentSpanCaptureStrategy(); | ||
| if (strategy2) { | ||
| const scope2 = utils.getCapturedScopesOnSpan(this).scope || currentScopes.getCurrentScope(); | ||
| strategy2.onChildSpanEnded(this, rootSpan, (options) => this._convertSpanToTransaction(options), scope2); | ||
| } | ||
| return; | ||
| } | ||
| if (client && hasSpanStreamingEnabled.hasSpanStreamingEnabled(client)) { | ||
| client.emit("afterSegmentSpanEnd", this); | ||
| return; | ||
| } | ||
| const transactionEvent = this._convertSpanToTransaction(); | ||
| if (transactionEvent) { | ||
| const scope = utils.getCapturedScopesOnSpan(this).scope || currentScopes.getCurrentScope(); | ||
| scope.captureEvent(transactionEvent); | ||
| const scope = utils.getCapturedScopesOnSpan(this).scope || currentScopes.getCurrentScope(); | ||
| const strategy = segmentSpanCaptureStrategy.getSegmentSpanCaptureStrategy(); | ||
| if (strategy) { | ||
| strategy.onSegmentSpanEnded((options) => this._convertSpanToTransaction(options), scope); | ||
| } else { | ||
| const transactionEvent = this._convertSpanToTransaction(); | ||
| if (transactionEvent) { | ||
| scope.captureEvent(transactionEvent); | ||
| } | ||
| } | ||
@@ -270,3 +309,3 @@ } | ||
| */ | ||
| _convertSpanToTransaction() { | ||
| _convertSpanToTransaction(options = {}) { | ||
| if (!isFullFinishedSpan(spanUtils.spanToJSON(this))) { | ||
@@ -284,4 +323,15 @@ return void 0; | ||
| } | ||
| const finishedSpans = spanUtils.getSpanDescendants(this).filter((span) => span !== this && !isStandaloneSpan(span)); | ||
| const spans = finishedSpans.map((span) => spanUtils.spanToJSON(span)).filter(isFullFinishedSpan); | ||
| options.onSpanCaptured?.(this); | ||
| const spans = []; | ||
| for (const descendant of spanUtils.getSpanDescendants(this)) { | ||
| if (descendant === this || isStandaloneSpan(descendant) || options.isSpanAlreadyCaptured?.(descendant)) { | ||
| continue; | ||
| } | ||
| const spanJSON = spanUtils.spanToJSON(descendant); | ||
| if (!isFullFinishedSpan(spanJSON)) { | ||
| continue; | ||
| } | ||
| options.onSpanCaptured?.(descendant); | ||
| spans.push(spanJSON); | ||
| } | ||
| const source = this._attributes[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]; | ||
@@ -288,0 +338,0 @@ delete this._attributes[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"sentrySpan.js","sources":["../../../src/tracing/sentrySpan.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { getClient, getCurrentScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { createSpanEnvelope } from '../envelope';\nimport {\n SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,\n SEMANTIC_ATTRIBUTE_PROFILE_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { SpanEnvelope } from '../types/envelope';\nimport type { TransactionEvent } from '../types/event';\nimport type { SpanLink } from '../types/link';\nimport type {\n SentrySpanArguments,\n Span,\n SpanAttributes,\n SpanAttributeValue,\n SpanContextData,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types/span';\nimport type { SpanStatus } from '../types/spanStatus';\nimport type { TimedEvent } from '../types/timedEvent';\nimport { debug } from '../utils/debug-logger';\nimport { generateSpanId, generateTraceId } from '../utils/propagationContext';\nimport {\n addStatusMessageAttribute,\n convertSpanLinksForEnvelope,\n getRootSpan,\n getSimpleStatus,\n getSpanDescendants,\n getStatusMessage,\n getStreamedSpanLinks,\n spanTimeInputToSeconds,\n spanToJSON,\n spanToTransactionTraceContext,\n TRACE_FLAG_NONE,\n TRACE_FLAG_SAMPLED,\n} from '../utils/spanUtils';\nimport { timestampInSeconds } from '../utils/time';\nimport { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanEnd } from './logSpans';\nimport { timedEventsToMeasurements } from './measurement';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport { getCapturedScopesOnSpan, spanShouldInferOtelSource } from './utils';\n\nconst MAX_SPAN_COUNT = 1000;\n\n/**\n * Span contains all data about a span\n */\nexport class SentrySpan implements Span {\n protected _traceId: string;\n protected _spanId: string;\n protected _parentSpanId?: string | undefined;\n protected _sampled: boolean | undefined;\n protected _name?: string | undefined;\n protected _attributes: SpanAttributes;\n protected _links?: SpanLink[];\n /** Epoch timestamp in seconds when the span started. */\n protected _startTime: number;\n /** Epoch timestamp in seconds when the span ended. */\n protected _endTime?: number | undefined;\n /** Internal keeper of the status */\n protected _status?: SpanStatus;\n /** The timed events added to this span. */\n protected _events: TimedEvent[];\n\n /** if true, treat span as a standalone span (not part of a transaction) */\n private _isStandaloneSpan?: boolean;\n\n /**\n * You should never call the constructor manually, always use `Sentry.startSpan()`\n * or other span methods.\n * @internal\n * @hideconstructor\n * @hidden\n */\n public constructor(spanContext: SentrySpanArguments = {}) {\n this._traceId = spanContext.traceId || generateTraceId();\n this._spanId = spanContext.spanId || generateSpanId();\n this._startTime = spanContext.startTimestamp || timestampInSeconds();\n this._links = spanContext.links;\n\n this._attributes = {};\n this.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: spanContext.op,\n ...spanContext.attributes,\n });\n\n this._name = spanContext.name;\n\n if (spanContext.parentSpanId) {\n this._parentSpanId = spanContext.parentSpanId;\n }\n // We want to include booleans as well here\n if ('sampled' in spanContext) {\n this._sampled = spanContext.sampled;\n }\n if (spanContext.endTimestamp) {\n this._endTime = spanContext.endTimestamp;\n }\n\n this._events = [];\n\n this._isStandaloneSpan = spanContext.isStandalone;\n\n // If the span is already ended, ensure we finalize the span immediately\n if (this._endTime) {\n this._onSpanEnded();\n }\n }\n\n /** @inheritDoc */\n public addLink(link: SpanLink): this {\n if (this._links) {\n this._links.push(link);\n } else {\n this._links = [link];\n }\n return this;\n }\n\n /** @inheritDoc */\n public addLinks(links: SpanLink[]): this {\n if (this._links) {\n this._links.push(...links);\n } else {\n this._links = links;\n }\n return this;\n }\n\n /**\n * This should generally not be used,\n * but it is needed for being compliant with the OTEL Span interface.\n *\n * @hidden\n * @internal\n */\n public recordException(_exception: unknown, _time?: number | undefined): void {\n // noop\n }\n\n /** @inheritdoc */\n public spanContext(): SpanContextData {\n const { _spanId: spanId, _traceId: traceId, _sampled: sampled } = this;\n return {\n spanId,\n traceId,\n traceFlags: sampled ? TRACE_FLAG_SAMPLED : TRACE_FLAG_NONE,\n };\n }\n\n /** @inheritdoc */\n public setAttribute(key: string, value: SpanAttributeValue | undefined): this {\n if (value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n } else {\n this._attributes[key] = value;\n }\n\n return this;\n }\n\n /** @inheritdoc */\n public setAttributes(attributes: SpanAttributes): this {\n Object.keys(attributes).forEach(key => this.setAttribute(key, attributes[key]));\n return this;\n }\n\n /**\n * This should generally not be used,\n * but we need it for browser tracing where we want to adjust the start time afterwards.\n * USE THIS WITH CAUTION!\n *\n * @hidden\n * @internal\n */\n public updateStartTime(timeInput: SpanTimeInput): void {\n this._startTime = spanTimeInputToSeconds(timeInput);\n }\n\n /**\n * @inheritDoc\n */\n public setStatus(value: SpanStatus): this {\n this._status = value;\n return this;\n }\n\n /**\n * @inheritDoc\n */\n public updateName(name: string): this {\n this._name = name;\n // Renaming a span marks its name as explicitly chosen, so we stamp `custom`.\n // The exception is spans created by SentryTraceProvider: those are branded for\n // OTel-style source inference at span end (mirroring OTel SDK spans, which have\n // no Sentry source concept), so instrumentations renaming them must not pin\n // `custom` — applyOtelSpanData infers the correct source (e.g. 'route', 'task').\n if (!spanShouldInferOtelSource(this)) {\n this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'custom');\n }\n return this;\n }\n\n /** @inheritdoc */\n public end(endTimestamp?: SpanTimeInput): void {\n // If already ended, skip\n if (this._endTime) {\n return;\n }\n\n this._endTime = spanTimeInputToSeconds(endTimestamp);\n logSpanEnd(this);\n\n this._onSpanEnded();\n }\n\n /**\n * Get JSON representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToJSON(span)` instead.\n */\n public getSpanJSON(): SpanJSON {\n return {\n data: this._attributes,\n description: this._name,\n op: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n parent_span_id: this._parentSpanId,\n span_id: this._spanId,\n start_timestamp: this._startTime,\n status: getStatusMessage(this._status),\n timestamp: this._endTime,\n trace_id: this._traceId,\n origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n profile_id: this._attributes[SEMANTIC_ATTRIBUTE_PROFILE_ID] as string | undefined,\n exclusive_time: this._attributes[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME] as number | undefined,\n measurements: timedEventsToMeasurements(this._events),\n is_segment: (this._isStandaloneSpan && getRootSpan(this) === this) || undefined,\n segment_id: this._isStandaloneSpan ? getRootSpan(this).spanContext().spanId : undefined,\n links: convertSpanLinksForEnvelope(this._links),\n };\n }\n\n /**\n * Get {@link StreamedSpanJSON} representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToStreamedSpanJSON(span)` instead.\n */\n public getStreamedSpanJSON(): StreamedSpanJSON {\n return {\n name: this._name ?? '',\n span_id: this._spanId,\n trace_id: this._traceId,\n parent_span_id: this._parentSpanId,\n start_timestamp: this._startTime,\n // just in case _endTime is not set, we use the start time (i.e. duration 0)\n end_timestamp: this._endTime ?? this._startTime,\n is_segment: this._isStandaloneSpan || this === getRootSpan(this),\n status: getSimpleStatus(this._status),\n attributes: addStatusMessageAttribute(this._attributes, this._status),\n links: getStreamedSpanLinks(this._links),\n };\n }\n\n /** @inheritdoc */\n public isRecording(): boolean {\n return !this._endTime && !!this._sampled;\n }\n\n /**\n * @inheritdoc\n */\n public addEvent(\n name: string,\n attributesOrStartTime?: SpanAttributes | SpanTimeInput,\n startTime?: SpanTimeInput,\n ): this {\n DEBUG_BUILD && debug.log('[Tracing] Adding an event to span:', name);\n\n const time = isSpanTimeInput(attributesOrStartTime) ? attributesOrStartTime : startTime || timestampInSeconds();\n const attributes = isSpanTimeInput(attributesOrStartTime) ? {} : attributesOrStartTime || {};\n\n const event: TimedEvent = {\n name,\n time: spanTimeInputToSeconds(time),\n attributes,\n };\n\n this._events.push(event);\n\n return this;\n }\n\n /**\n * This method should generally not be used,\n * but for now we need a way to publicly check if the `_isStandaloneSpan` flag is set.\n * USE THIS WITH CAUTION!\n * @internal\n * @hidden\n * @experimental\n */\n public isStandaloneSpan(): boolean {\n return !!this._isStandaloneSpan;\n }\n\n /** Emit `spanEnd` when the span is ended. */\n private _onSpanEnded(): void {\n const client = getClient();\n if (client) {\n client.emit('spanEnd', this);\n // Guarding sending standalone v1 spans as v2 streamed spans for now.\n // Otherwise they'd be sent once as v1 spans and again as streamed spans.\n // We'll migrate CLS and LCP spans to streamed spans in a later PR and\n // INP spans in the next major of the SDK. At that point, we can fully remove\n // standalone v1 spans <3\n if (!this._isStandaloneSpan) {\n client.emit('afterSpanEnd', this);\n }\n }\n\n // A segment span is basically the root span of a local span tree.\n // So for now, this is either what we previously refer to as the root span,\n // or a standalone span.\n const isSegmentSpan = this._isStandaloneSpan || this === getRootSpan(this);\n\n if (!isSegmentSpan) {\n return;\n }\n\n // if this is a standalone span, we send it immediately\n if (this._isStandaloneSpan) {\n if (this._sampled) {\n sendSpanEnvelope(createSpanEnvelope([this], client));\n } else {\n DEBUG_BUILD &&\n debug.log('[Tracing] Discarding standalone span because its trace was not chosen to be sampled.');\n if (client) {\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n return;\n } else if (client && hasSpanStreamingEnabled(client)) {\n // TODO (spans): Remove standalone span custom logic in favor of sending simple v2 web vital spans\n client.emit('afterSegmentSpanEnd', this);\n return;\n }\n\n const transactionEvent = this._convertSpanToTransaction();\n if (transactionEvent) {\n const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope();\n scope.captureEvent(transactionEvent);\n }\n }\n\n /**\n * Finish the transaction & prepare the event to send to Sentry.\n */\n private _convertSpanToTransaction(): TransactionEvent | undefined {\n // We can only convert finished spans\n if (!isFullFinishedSpan(spanToJSON(this))) {\n return undefined;\n }\n\n if (!this._name) {\n DEBUG_BUILD && debug.warn('Transaction has no name, falling back to `<unlabeled transaction>`.');\n this._name = '<unlabeled transaction>';\n }\n\n const { scope: capturedSpanScope, isolationScope: capturedSpanIsolationScope } = getCapturedScopesOnSpan(this);\n\n const normalizedRequest = capturedSpanScope?.getScopeData().sdkProcessingMetadata?.normalizedRequest;\n\n if (this._sampled !== true) {\n return undefined;\n }\n\n // The transaction span itself as well as any potential standalone spans should be filtered out\n const finishedSpans = getSpanDescendants(this).filter(span => span !== this && !isStandaloneSpan(span));\n\n const spans = finishedSpans.map(span => spanToJSON(span)).filter(isFullFinishedSpan);\n\n const source = this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n\n // remove internal root span attributes we don't need to send.\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n let hasGenAiSpans = false;\n spans.forEach(span => {\n delete span.data[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n if (span.op?.startsWith('gen_ai.')) {\n hasGenAiSpans = true;\n }\n });\n // eslint-enabled-next-line @typescript-eslint/no-dynamic-delete\n\n const transaction: TransactionEvent = {\n contexts: {\n trace: spanToTransactionTraceContext(this),\n },\n spans:\n // spans.sort() mutates the array, but `spans` is already a copy so we can safely do this here\n // we do not use spans anymore after this point\n spans.length > MAX_SPAN_COUNT\n ? spans.sort((a, b) => a.start_timestamp - b.start_timestamp).slice(0, MAX_SPAN_COUNT)\n : spans,\n start_timestamp: this._startTime,\n timestamp: this._endTime,\n transaction: this._name,\n type: 'transaction',\n sdkProcessingMetadata: {\n capturedSpanScope,\n capturedSpanIsolationScope,\n dynamicSamplingContext: getDynamicSamplingContextFromSpan(this),\n hasGenAiSpans,\n },\n request: normalizedRequest,\n ...(source && {\n transaction_info: {\n source,\n },\n }),\n };\n\n const measurements = timedEventsToMeasurements(this._events);\n const hasMeasurements = measurements && Object.keys(measurements).length;\n\n if (hasMeasurements) {\n DEBUG_BUILD &&\n debug.log(\n '[Measurements] Adding measurements to transaction event',\n JSON.stringify(measurements, undefined, 2),\n );\n transaction.measurements = measurements;\n }\n\n return transaction;\n }\n}\n\nfunction isSpanTimeInput(value: undefined | SpanAttributes | SpanTimeInput): value is SpanTimeInput {\n return (value && typeof value === 'number') || value instanceof Date || Array.isArray(value);\n}\n\n// We want to filter out any incomplete SpanJSON objects\nfunction isFullFinishedSpan(input: Partial<SpanJSON>): input is SpanJSON {\n return !!input.start_timestamp && !!input.timestamp && !!input.span_id && !!input.trace_id;\n}\n\n/** `SentrySpan`s can be sent as a standalone span rather than belonging to a transaction */\nfunction isStandaloneSpan(span: Span): boolean {\n return span instanceof SentrySpan && span.isStandaloneSpan();\n}\n\n/**\n * Sends a `SpanEnvelope`.\n *\n * Note: If the envelope's spans are dropped, e.g. via `beforeSendSpan`,\n * the envelope will not be sent either.\n */\nfunction sendSpanEnvelope(envelope: SpanEnvelope): void {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const spanItems = envelope[1];\n if (!spanItems || spanItems.length === 0) {\n client.recordDroppedEvent('before_send', 'span');\n return;\n }\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n"],"names":["generateTraceId","generateSpanId","timestampInSeconds","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","TRACE_FLAG_SAMPLED","TRACE_FLAG_NONE","spanTimeInputToSeconds","spanShouldInferOtelSource","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","logSpanEnd","getStatusMessage","SEMANTIC_ATTRIBUTE_PROFILE_ID","SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME","timedEventsToMeasurements","getRootSpan","convertSpanLinksForEnvelope","getSimpleStatus","addStatusMessageAttribute","getStreamedSpanLinks","DEBUG_BUILD","debug","time","getClient","createSpanEnvelope","hasSpanStreamingEnabled","getCapturedScopesOnSpan","getCurrentScope","spanToJSON","getSpanDescendants","SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME","spanToTransactionTraceContext","getDynamicSamplingContextFromSpan"],"mappings":";;;;;;;;;;;;;;;;AAmDA,MAAM,cAAA,GAAiB,GAAA;AAKhB,MAAM,UAAA,CAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2B/B,WAAA,CAAY,WAAA,GAAmC,EAAC,EAAG;AACxD,IAAA,IAAA,CAAK,QAAA,GAAW,WAAA,CAAY,OAAA,IAAWA,kCAAA,EAAgB;AACvD,IAAA,IAAA,CAAK,OAAA,GAAU,WAAA,CAAY,MAAA,IAAUC,iCAAA,EAAe;AACpD,IAAA,IAAA,CAAK,UAAA,GAAa,WAAA,CAAY,cAAA,IAAkBC,uBAAA,EAAmB;AACnE,IAAA,IAAA,CAAK,SAAS,WAAA,CAAY,KAAA;AAE1B,IAAA,IAAA,CAAK,cAAc,EAAC;AACpB,IAAA,IAAA,CAAK,aAAA,CAAc;AAAA,MACjB,CAACC,mDAAgC,GAAG,QAAA;AAAA,MACpC,CAACC,+CAA4B,GAAG,WAAA,CAAY,EAAA;AAAA,MAC5C,GAAG,WAAA,CAAY;AAAA,KAChB,CAAA;AAED,IAAA,IAAA,CAAK,QAAQ,WAAA,CAAY,IAAA;AAEzB,IAAA,IAAI,YAAY,YAAA,EAAc;AAC5B,MAAA,IAAA,CAAK,gBAAgB,WAAA,CAAY,YAAA;AAAA,IACnC;AAEA,IAAA,IAAI,aAAa,WAAA,EAAa;AAC5B,MA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AA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAa,iBAAiB,IAAA,IAAQ,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC7F;AAGA,SAAS,mBAAmB,KAAA,EAA6C;AACvE,EAAA,OAAO,CAAC,CAAC,KAAA,CAAM,eAAA,IAAmB,CAAC,CAAC,KAAA,CAAM,SAAA,IAAa,CAAC,CAAC,KAAA,CAAM,OAAA,IAAW,CAAC,CAAC,KAAA,CAAM,QAAA;AACpF;AAGA,SAAS,iBAAiB,IAAA,EAAqB;AAC7C,EAAA,OAAO,IAAA,YAAgB,UAAA,IAAc,IAAA,CAAK,gBAAA,EAAiB;AAC7D;AAQA,SAAS,iBAAiB,QAAA,EAA8B;AACtD,EAAA,MAAM,SAASE,uBAAA,EAAU;AACzB,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,SAAA,GAAY,SAAS,CAAC,CAAA;AAC5B,EAAA,IAAI,CAAC,SAAA,IAAa,SAAA,CAAU,MAAA,KAAW,CAAA,EAAG;AACxC,IAAA,MAAA,CAAO,kBAAA,CAAmB,eAAe,MAAM,CAAA;AAC/C,IAAA;AAAA,EACF;AAIA,EAAA,MAAA,CAAO,aAAa,QAAQ,CAAA;AAC9B;;;;"} | ||
| {"version":3,"file":"sentrySpan.js","sources":["../../../src/tracing/sentrySpan.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { getClient, getCurrentScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { createSpanEnvelope } from '../envelope';\nimport {\n SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,\n SEMANTIC_ATTRIBUTE_PROFILE_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { SpanEnvelope } from '../types/envelope';\nimport type { TransactionEvent } from '../types/event';\nimport type { SpanLink } from '../types/link';\nimport type {\n SentrySpanArguments,\n Span,\n SpanAttributes,\n SpanAttributeValue,\n SpanContextData,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types/span';\nimport type { SpanStatus } from '../types/spanStatus';\nimport type { TimedEvent } from '../types/timedEvent';\nimport { debug } from '../utils/debug-logger';\nimport { generateSpanId, generateTraceId } from '../utils/propagationContext';\nimport {\n addStatusMessageAttribute,\n convertSpanLinksForEnvelope,\n getRootSpan,\n getSimpleStatus,\n getSpanDescendants,\n getStatusMessage,\n getStreamedSpanLinks,\n spanTimeInputToSeconds,\n spanToJSON,\n spanToTransactionTraceContext,\n TRACE_FLAG_NONE,\n TRACE_FLAG_SAMPLED,\n} from '../utils/spanUtils';\nimport { timestampInSeconds } from '../utils/time';\nimport { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanEnd } from './logSpans';\nimport { timedEventsToMeasurements } from './measurement';\nimport { getSegmentSpanCaptureStrategy, type SegmentSpanCaptureConvertOptions } from './segmentSpanCaptureStrategy';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport {\n getCapturedScopesOnSpan,\n markSpanSourceAsExplicit,\n spanIsTracerProviderSpan,\n spanShouldInferOtelSource,\n} from './utils';\n\nconst MAX_SPAN_COUNT = 1000;\n\n/**\n * Span contains all data about a span\n */\nexport class SentrySpan implements Span {\n protected _traceId: string;\n protected _spanId: string;\n protected _parentSpanId?: string | undefined;\n protected _sampled: boolean | undefined;\n protected _name?: string | undefined;\n protected _attributes: SpanAttributes;\n protected _links?: SpanLink[];\n /** Epoch timestamp in seconds when the span started. */\n protected _startTime: number;\n /** Epoch timestamp in seconds when the span ended. */\n protected _endTime?: number | undefined;\n /** Internal keeper of the status */\n protected _status?: SpanStatus;\n /** The timed events added to this span. */\n protected _events: TimedEvent[];\n\n /** if true, treat span as a standalone span (not part of a transaction) */\n private _isStandaloneSpan?: boolean;\n\n /** if true, the span is sealed and ignores further mutations (set after end for tracer-provider spans) */\n private _frozen?: boolean;\n\n /**\n * You should never call the constructor manually, always use `Sentry.startSpan()`\n * or other span methods.\n * @internal\n * @hideconstructor\n * @hidden\n */\n public constructor(spanContext: SentrySpanArguments = {}) {\n this._traceId = spanContext.traceId || generateTraceId();\n this._spanId = spanContext.spanId || generateSpanId();\n this._startTime = spanContext.startTimestamp || timestampInSeconds();\n this._links = spanContext.links;\n\n this._attributes = {};\n this.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: spanContext.op,\n ...spanContext.attributes,\n });\n\n this._name = spanContext.name;\n\n if (spanContext.parentSpanId) {\n this._parentSpanId = spanContext.parentSpanId;\n }\n // We want to include booleans as well here\n if ('sampled' in spanContext) {\n this._sampled = spanContext.sampled;\n }\n if (spanContext.endTimestamp) {\n this._endTime = spanContext.endTimestamp;\n }\n\n this._events = [];\n\n this._isStandaloneSpan = spanContext.isStandalone;\n\n // If the span is already ended, ensure we finalize the span immediately\n if (this._endTime) {\n this._onSpanEnded();\n }\n }\n\n /** @inheritDoc */\n public addLink(link: SpanLink): this {\n if (this._frozen) {\n return this;\n }\n if (this._links) {\n this._links.push(link);\n } else {\n this._links = [link];\n }\n return this;\n }\n\n /** @inheritDoc */\n public addLinks(links: SpanLink[]): this {\n if (this._frozen) {\n return this;\n }\n if (this._links) {\n this._links.push(...links);\n } else {\n this._links = links;\n }\n return this;\n }\n\n /**\n * This should generally not be used,\n * but it is needed for being compliant with the OTEL Span interface.\n *\n * @hidden\n * @internal\n */\n public recordException(_exception: unknown, _time?: SpanTimeInput | undefined): void {\n // noop\n }\n\n /** @inheritdoc */\n public spanContext(): SpanContextData {\n const { _spanId: spanId, _traceId: traceId, _sampled: sampled } = this;\n return {\n spanId,\n traceId,\n traceFlags: sampled ? TRACE_FLAG_SAMPLED : TRACE_FLAG_NONE,\n };\n }\n\n /** @inheritdoc */\n public setAttribute(key: string, value: SpanAttributeValue | undefined): this {\n if (this._frozen) {\n return this;\n }\n\n if (value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n } else {\n this._attributes[key] = value;\n }\n\n // Setting the source on a span branded for OTel-style inference means user code is choosing it\n // explicitly, so flag it to keep `applyOtelSpanData` from overriding it with an inferred source.\n if (key === SEMANTIC_ATTRIBUTE_SENTRY_SOURCE && value !== undefined && spanShouldInferOtelSource(this)) {\n markSpanSourceAsExplicit(this);\n }\n\n return this;\n }\n\n /** @inheritdoc */\n public setAttributes(attributes: SpanAttributes): this {\n Object.keys(attributes).forEach(key => this.setAttribute(key, attributes[key]));\n return this;\n }\n\n /**\n * This should generally not be used,\n * but we need it for browser tracing where we want to adjust the start time afterwards.\n * USE THIS WITH CAUTION!\n *\n * @hidden\n * @internal\n */\n public updateStartTime(timeInput: SpanTimeInput): void {\n if (this._frozen) {\n return;\n }\n this._startTime = spanTimeInputToSeconds(timeInput);\n }\n\n /**\n * @inheritDoc\n */\n public setStatus(value: SpanStatus): this {\n if (this._frozen) {\n return this;\n }\n this._status = value;\n return this;\n }\n\n /**\n * @inheritDoc\n */\n public updateName(name: string): this {\n if (this._frozen) {\n return this;\n }\n this._name = name;\n // Renaming a span marks its name as explicitly chosen, so we stamp `custom`.\n // The exception is spans created by SentryTraceProvider: those are branded for\n // OTel-style source inference at span end (mirroring OTel SDK spans, which have\n // no Sentry source concept), so instrumentations renaming them must not pin\n // `custom` — applyOtelSpanData infers the correct source (e.g. 'route', 'task').\n if (!spanShouldInferOtelSource(this)) {\n this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'custom');\n }\n return this;\n }\n\n /** @inheritdoc */\n public end(endTimestamp?: SpanTimeInput): void {\n // If already ended, skip the end-of-span processing, but still seal a tracer-provider span. The\n // seal at the bottom of this method is skipped on this early return, and `_endTime` may have been\n // set before this first `end()` call (e.g. via the constructor's `endTimestamp`), which would\n // otherwise leave the span mutable after `end()`. End-of-span processing already ran in that case.\n if (this._endTime) {\n this._frozen = spanIsTracerProviderSpan(this);\n return;\n }\n\n this._endTime = spanTimeInputToSeconds(endTimestamp);\n logSpanEnd(this);\n\n this._onSpanEnded();\n\n // A span created by the SentryTracerProvider is handed to OTel instrumentations as an OTel span,\n // so once end-of-span processing is done (including the `spanEnd` hook where `applyOtelSpanData`\n // finalizes status/source) it is sealed against further writes — mirroring the OpenTelemetry SDK,\n // where setters no-op after a span has ended. Without this, an instrumentation that sets\n // status/attributes after `end()` (e.g. Next.js on a render error) would overwrite the finalized\n // values, and the deferred capture would then serialize those late writes. Spans created directly\n // through the core API (e.g. the browser SDK, which backfills resource-timing attributes after a\n // span ends) are not tracer-provider spans and stay mutable.\n this._frozen = spanIsTracerProviderSpan(this);\n }\n\n /**\n * Get JSON representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToJSON(span)` instead.\n */\n public getSpanJSON(): SpanJSON {\n return {\n data: this._attributes,\n description: this._name,\n op: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n parent_span_id: this._parentSpanId,\n span_id: this._spanId,\n start_timestamp: this._startTime,\n status: getStatusMessage(this._status),\n timestamp: this._endTime,\n trace_id: this._traceId,\n origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n profile_id: this._attributes[SEMANTIC_ATTRIBUTE_PROFILE_ID] as string | undefined,\n exclusive_time: this._attributes[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME] as number | undefined,\n measurements: timedEventsToMeasurements(this._events),\n is_segment: (this._isStandaloneSpan && getRootSpan(this) === this) || undefined,\n segment_id: this._isStandaloneSpan ? getRootSpan(this).spanContext().spanId : undefined,\n links: convertSpanLinksForEnvelope(this._links),\n };\n }\n\n /**\n * Get {@link StreamedSpanJSON} representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToStreamedSpanJSON(span)` instead.\n */\n public getStreamedSpanJSON(): StreamedSpanJSON {\n return {\n name: this._name ?? '',\n span_id: this._spanId,\n trace_id: this._traceId,\n parent_span_id: this._parentSpanId,\n start_timestamp: this._startTime,\n // just in case _endTime is not set, we use the start time (i.e. duration 0)\n end_timestamp: this._endTime ?? this._startTime,\n is_segment: this._isStandaloneSpan || this === getRootSpan(this),\n status: getSimpleStatus(this._status),\n attributes: addStatusMessageAttribute(this._attributes, this._status),\n links: getStreamedSpanLinks(this._links),\n };\n }\n\n /** @inheritdoc */\n public isRecording(): boolean {\n return !this._endTime && !!this._sampled;\n }\n\n /**\n * @inheritdoc\n */\n public addEvent(\n name: string,\n attributesOrStartTime?: SpanAttributes | SpanTimeInput,\n startTime?: SpanTimeInput,\n ): this {\n if (this._frozen) {\n return this;\n }\n DEBUG_BUILD && debug.log('[Tracing] Adding an event to span:', name);\n\n const time = isSpanTimeInput(attributesOrStartTime) ? attributesOrStartTime : startTime || timestampInSeconds();\n const attributes = isSpanTimeInput(attributesOrStartTime) ? {} : attributesOrStartTime || {};\n\n const event: TimedEvent = {\n name,\n time: spanTimeInputToSeconds(time),\n attributes,\n };\n\n this._events.push(event);\n\n return this;\n }\n\n /**\n * This method should generally not be used,\n * but for now we need a way to publicly check if the `_isStandaloneSpan` flag is set.\n * USE THIS WITH CAUTION!\n * @internal\n * @hidden\n * @experimental\n */\n public isStandaloneSpan(): boolean {\n return !!this._isStandaloneSpan;\n }\n\n /** Emit `spanEnd` when the span is ended. */\n private _onSpanEnded(): void {\n const client = getClient();\n if (client) {\n client.emit('spanEnd', this);\n // Guarding sending standalone v1 spans as v2 streamed spans for now.\n // Otherwise they'd be sent once as v1 spans and again as streamed spans.\n // We'll migrate CLS and LCP spans to streamed spans in a later PR and\n // INP spans in the next major of the SDK. At that point, we can fully remove\n // standalone v1 spans <3\n if (!this._isStandaloneSpan) {\n client.emit('afterSpanEnd', this);\n }\n }\n\n // A segment span is basically the root span of a local span tree.\n // So for now, this is either what we previously refer to as the root span,\n // or a standalone span.\n const rootSpan = getRootSpan(this);\n const isSegmentSpan = this._isStandaloneSpan || this === rootSpan;\n\n // if this is a standalone span, we send it immediately\n if (this._isStandaloneSpan) {\n if (this._sampled) {\n sendSpanEnvelope(createSpanEnvelope([this], client));\n } else {\n DEBUG_BUILD &&\n debug.log('[Tracing] Discarding standalone span because its trace was not chosen to be sampled.');\n if (client) {\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n return;\n }\n\n // Non-segment children aren't captured on their own. A registered strategy may re-emit a late child\n // as its own orphan transaction; without one, it's dropped.\n if (!isSegmentSpan) {\n const strategy = getSegmentSpanCaptureStrategy();\n if (strategy) {\n const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope();\n strategy.onChildSpanEnded(this, rootSpan, options => this._convertSpanToTransaction(options), scope);\n }\n return;\n }\n\n if (client && hasSpanStreamingEnabled(client)) {\n // TODO (spans): Remove standalone span custom logic in favor of sending simple v2 web vital spans\n client.emit('afterSegmentSpanEnd', this);\n return;\n }\n\n // A registered strategy defers the snapshot so children closing just after the segment still land\n // (and late ones can orphan); without one, assemble synchronously from the live tree.\n const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope();\n const strategy = getSegmentSpanCaptureStrategy();\n if (strategy) {\n strategy.onSegmentSpanEnded(options => this._convertSpanToTransaction(options), scope);\n } else {\n const transactionEvent = this._convertSpanToTransaction();\n if (transactionEvent) {\n scope.captureEvent(transactionEvent);\n }\n }\n }\n\n /**\n * Finish the transaction & prepare the event to send to Sentry.\n */\n private _convertSpanToTransaction(options: SegmentSpanCaptureConvertOptions = {}): TransactionEvent | undefined {\n // We can only convert finished spans\n if (!isFullFinishedSpan(spanToJSON(this))) {\n return undefined;\n }\n\n if (!this._name) {\n DEBUG_BUILD && debug.warn('Transaction has no name, falling back to `<unlabeled transaction>`.');\n this._name = '<unlabeled transaction>';\n }\n\n const { scope: capturedSpanScope, isolationScope: capturedSpanIsolationScope } = getCapturedScopesOnSpan(this);\n\n const normalizedRequest = capturedSpanScope?.getScopeData().sdkProcessingMetadata?.normalizedRequest;\n\n if (this._sampled !== true) {\n return undefined;\n }\n\n // Skip the span itself, standalone spans, and (when a strategy tracks it) spans already sent. The\n // synchronous default passes no hooks, so this bookkeeping stays out of SDKs that don't defer.\n options.onSpanCaptured?.(this);\n const spans: SpanJSON[] = [];\n for (const descendant of getSpanDescendants(this)) {\n if (descendant === this || isStandaloneSpan(descendant) || options.isSpanAlreadyCaptured?.(descendant)) {\n continue;\n }\n const spanJSON = spanToJSON(descendant);\n if (!isFullFinishedSpan(spanJSON)) {\n continue;\n }\n options.onSpanCaptured?.(descendant);\n spans.push(spanJSON);\n }\n\n const source = this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n\n // remove internal root span attributes we don't need to send.\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n let hasGenAiSpans = false;\n spans.forEach(span => {\n delete span.data[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n if (span.op?.startsWith('gen_ai.')) {\n hasGenAiSpans = true;\n }\n });\n // eslint-enabled-next-line @typescript-eslint/no-dynamic-delete\n\n const transaction: TransactionEvent = {\n contexts: {\n trace: spanToTransactionTraceContext(this),\n },\n spans:\n // spans.sort() mutates the array, but `spans` is already a copy so we can safely do this here\n // we do not use spans anymore after this point\n spans.length > MAX_SPAN_COUNT\n ? spans.sort((a, b) => a.start_timestamp - b.start_timestamp).slice(0, MAX_SPAN_COUNT)\n : spans,\n start_timestamp: this._startTime,\n timestamp: this._endTime,\n transaction: this._name,\n type: 'transaction',\n sdkProcessingMetadata: {\n capturedSpanScope,\n capturedSpanIsolationScope,\n dynamicSamplingContext: getDynamicSamplingContextFromSpan(this),\n hasGenAiSpans,\n },\n request: normalizedRequest,\n ...(source && {\n transaction_info: {\n source,\n },\n }),\n };\n\n const measurements = timedEventsToMeasurements(this._events);\n const hasMeasurements = measurements && Object.keys(measurements).length;\n\n if (hasMeasurements) {\n DEBUG_BUILD &&\n debug.log(\n '[Measurements] Adding measurements to transaction event',\n JSON.stringify(measurements, undefined, 2),\n );\n transaction.measurements = measurements;\n }\n\n return transaction;\n }\n}\n\nfunction isSpanTimeInput(value: undefined | SpanAttributes | SpanTimeInput): value is SpanTimeInput {\n return (value && typeof value === 'number') || value instanceof Date || Array.isArray(value);\n}\n\n// We want to filter out any incomplete SpanJSON objects\nfunction isFullFinishedSpan(input: Partial<SpanJSON>): input is SpanJSON {\n return !!input.start_timestamp && !!input.timestamp && !!input.span_id && !!input.trace_id;\n}\n\n/** `SentrySpan`s can be sent as a standalone span rather than belonging to a transaction */\nfunction isStandaloneSpan(span: Span): boolean {\n return span instanceof SentrySpan && span.isStandaloneSpan();\n}\n\n/**\n * Sends a `SpanEnvelope`.\n *\n * Note: If the envelope's spans are dropped, e.g. via `beforeSendSpan`,\n * the envelope will not be sent either.\n */\nfunction sendSpanEnvelope(envelope: SpanEnvelope): void {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const spanItems = envelope[1];\n if (!spanItems || spanItems.length === 0) {\n client.recordDroppedEvent('before_send', 'span');\n return;\n }\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n"],"names":["generateTraceId","generateSpanId","timestampInSeconds","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","TRACE_FLAG_SAMPLED","TRACE_FLAG_NONE","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","spanShouldInferOtelSource","markSpanSourceAsExplicit","spanTimeInputToSeconds","spanIsTracerProviderSpan","logSpanEnd","getStatusMessage","SEMANTIC_ATTRIBUTE_PROFILE_ID","SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME","timedEventsToMeasurements","getRootSpan","convertSpanLinksForEnvelope","getSimpleStatus","addStatusMessageAttribute","getStreamedSpanLinks","DEBUG_BUILD","debug","time","getClient","createSpanEnvelope","strategy","getSegmentSpanCaptureStrategy","scope","getCapturedScopesOnSpan","getCurrentScope","hasSpanStreamingEnabled","spanToJSON","getSpanDescendants","SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME","spanToTransactionTraceContext","getDynamicSamplingContextFromSpan"],"mappings":";;;;;;;;;;;;;;;;;AAyDA,MAAM,cAAA,GAAiB,GAAA;AAKhB,MAAM,UAAA,CAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA8B/B,WAAA,CAAY,WAAA,GAAmC,EAAC,EAAG;AACxD,IAAA,IAAA,CAAK,QAAA,GAAW,WAAA,CAAY,OAAA,IAAWA,kCAAA,EAAgB;AACvD,IAAA,IAAA,CAAK,OAAA,GAAU,WAAA,CAAY,MAAA,IAAUC,iCAAA,EAAe;AACpD,IAAA,IAAA,CAAK,UAAA,GAAa,WAAA,CAAY,cAAA,IAAkBC,uBAAA,EAAmB;AACnE,IAAA,IAAA,CAAK,SAAS,WAAA,CAAY,KAAA;AAE1B,IAAA,IAAA,CAAK,cAAc,EAAC;AACpB,IAAA,IAAA,CAAK,aAAA,CAAc;AAAA,MACjB,CAACC,mDAAgC,GAAG,QAAA;AAAA,MACpC,CAACC,+CAA4B,GAAG,WAAA,CAAY,EAAA;AAAA,MAC5C,GAAG,WAAA,CAAY;AAAA,KAChB,CAAA;AAED,IAAA,IAAA,CAAK,QAAQ,WAAA,CAAY,IAAA;AAEzB,IAAA,IAAI,YAAY,YAAA,EAAc;AAC5B,MAAA,IAAA,CAAK,gBAAgB,WAAA,CAAY,YAAA;AAAA,IACnC;AAEA,IAAA,IAAI,aAAa,WAAA,EAAa;AAC5B,MAAA,IAAA,CAAK,WAAW,WAAA,CAAY,OA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BAAA,CAAM,GAAA;AAAA,QACJ,yDAAA;AAAA,QACA,IAAA,CAAK,SAAA,CAAU,YAAA,EAAc,MAAA,EAAW,CAAC;AAAA,OAC3C;AACF,MAAA,WAAA,CAAY,YAAA,GAAe,YAAA;AAAA,IAC7B;AAEA,IAAA,OAAO,WAAA;AAAA,EACT;AACF;AAEA,SAAS,gBAAgB,KAAA,EAA2E;AAClG,EAAA,OAAQ,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAa,iBAAiB,IAAA,IAAQ,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC7F;AAGA,SAAS,mBAAmB,KAAA,EAA6C;AACvE,EAAA,OAAO,CAAC,CAAC,KAAA,CAAM,eAAA,IAAmB,CAAC,CAAC,KAAA,CAAM,SAAA,IAAa,CAAC,CAAC,KAAA,CAAM,OAAA,IAAW,CAAC,CAAC,KAAA,CAAM,QAAA;AACpF;AAGA,SAAS,iBAAiB,IAAA,EAAqB;AAC7C,EAAA,OAAO,IAAA,YAAgB,UAAA,IAAc,IAAA,CAAK,gBAAA,EAAiB;AAC7D;AAQA,SAAS,iBAAiB,QAAA,EAA8B;AACtD,EAAA,MAAM,SAASE,uBAAA,EAAU;AACzB,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,SAAA,GAAY,SAAS,CAAC,CAAA;AAC5B,EAAA,IAAI,CAAC,SAAA,IAAa,SAAA,CAAU,MAAA,KAAW,CAAA,EAAG;AACxC,IAAA,MAAA,CAAO,kBAAA,CAAmB,eAAe,MAAM,CAAA;AAC/C,IAAA;AAAA,EACF;AAIA,EAAA,MAAA,CAAO,aAAa,QAAQ,CAAA;AAC9B;;;;"} |
@@ -10,2 +10,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const constants = require('../../constants.js'); | ||
| const attributes = require('@sentry/conventions/attributes'); | ||
@@ -32,5 +33,3 @@ function captureSpan(span, client) { | ||
| safeSetSpanJSONAttributes(processedSpan, { | ||
| // Purposefully not using a constant defined here like in other attributes: | ||
| // This will be the name for SEMANTIC_ATTRIBUTE_SENTRY_SOURCE in v11 | ||
| "sentry.span.source": spanNameSource | ||
| [attributes.SENTRY_SPAN_SOURCE]: spanNameSource | ||
| }); | ||
@@ -66,2 +65,3 @@ } | ||
| safeSetSpanJSONAttributes(spanJSON, { | ||
| [attributes.SENTRY_TRACE_LIFECYCLE]: "stream", | ||
| [semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: release, | ||
@@ -68,0 +68,0 @@ [semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: environment || constants.DEFAULT_ENVIRONMENT, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"captureSpan.js","sources":["../../../../src/tracing/spans/captureSpan.ts"],"sourcesContent":["import type { RawAttributes } from '../../attributes';\nimport type { Client } from '../../client';\nimport type { ScopeData } from '../../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT,\n SEMANTIC_ATTRIBUTE_SENTRY_RELEASE,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_USER_EMAIL,\n SEMANTIC_ATTRIBUTE_USER_ID,\n SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS,\n SEMANTIC_ATTRIBUTE_USER_USERNAME,\n} from '../../semanticAttributes';\nimport type { SerializedStreamedSpan, Span, StreamedSpanJSON } from '../../types/span';\nimport { getCombinedScopeData } from '../../utils/scopeData';\nimport {\n INTERNAL_getSegmentSpan,\n showSpanDropWarning,\n spanToStreamedSpanJSON,\n streamedSpanJsonToSerializedSpan,\n} from '../../utils/spanUtils';\nimport { getCapturedScopesOnSpan } from '../utils';\nimport { isStreamedBeforeSendSpanCallback } from './beforeSendSpan';\nimport { scopeContextsToSpanAttributes } from './scopeContextAttributes';\nimport { DEFAULT_ENVIRONMENT } from '../../constants';\n\nexport type SerializedStreamedSpanWithSegmentSpan = SerializedStreamedSpan & {\n _segmentSpan: Span;\n};\n\n/**\n * Captures a span and returns a JSON representation to be enqueued for sending.\n *\n * IMPORTANT: This function converts the span to JSON immediately to avoid writing\n * to an already-ended OTel span instance (which is blocked by the OTel Span class).\n *\n * @returns the final serialized span with a reference to its segment span. This reference\n * is needed later on to compute the DSC for the span envelope.\n */\nexport function captureSpan(span: Span, client: Client): SerializedStreamedSpanWithSegmentSpan {\n // Convert to JSON FIRST - we cannot write to an already-ended span\n const spanJSON = spanToStreamedSpanJSON(span);\n\n const segmentSpan = INTERNAL_getSegmentSpan(span);\n const serializedSegmentSpan = spanToStreamedSpanJSON(segmentSpan);\n\n const { isolationScope: spanIsolationScope, scope: spanScope } = getCapturedScopesOnSpan(span);\n\n const finalScopeData = getCombinedScopeData(spanIsolationScope, spanScope);\n\n applyCommonSpanAttributes(spanJSON, serializedSegmentSpan, client, finalScopeData);\n\n // Access `kind` via duck-typing — OTel span objects have this property but it's not on Sentry's Span type.\n // It is forwarded to `preprocessSpan` subscribers (e.g. the OpenTelemetry SDK backfills op/source/name from it).\n const spanKind = (span as { kind?: number }).kind;\n\n // Preprocess the span JSON before any other hooks run, so that `processSpan`/`processSegmentSpan`\n // subscribers (incl. integrations) and `beforeSendSpan` see fully inferred span data.\n client.emit('preprocessSpan', spanJSON, { spanKind });\n\n if (spanJSON.is_segment) {\n applyScopeToSegmentSpan(spanJSON, finalScopeData);\n applySdkMetadataToSegmentSpan(spanJSON, client);\n // Allow hook subscribers to mutate the segment span JSON\n // This also invokes the `processSegmentSpan` hook of all integrations\n client.emit('processSegmentSpan', spanJSON);\n }\n\n // This allows hook subscribers to mutate the span JSON\n // This also invokes the `processSpan` hook of all integrations\n client.emit('processSpan', spanJSON);\n\n const { beforeSendSpan } = client.getOptions();\n const processedSpan =\n beforeSendSpan && isStreamedBeforeSendSpanCallback(beforeSendSpan)\n ? applyBeforeSendSpanCallback(spanJSON, beforeSendSpan)\n : spanJSON;\n\n // Backfill sentry.span.source from sentry.source. Only `sentry.span.source` is respected by Sentry.\n // TODO(v11): Remove this backfill once we renamed SEMANTIC_ATTRIBUTE_SENTRY_SOURCE to sentry.span.source\n const spanNameSource = processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n if (spanNameSource) {\n safeSetSpanJSONAttributes(processedSpan, {\n // Purposefully not using a constant defined here like in other attributes:\n // This will be the name for SEMANTIC_ATTRIBUTE_SENTRY_SOURCE in v11\n 'sentry.span.source': spanNameSource,\n });\n }\n\n return {\n ...streamedSpanJsonToSerializedSpan(processedSpan),\n _segmentSpan: segmentSpan,\n };\n}\n\nfunction applyScopeToSegmentSpan(segmentSpanJSON: StreamedSpanJSON, scopeData: ScopeData): void {\n const contextAttributes = scopeContextsToSpanAttributes(scopeData.contexts);\n safeSetSpanJSONAttributes(segmentSpanJSON, contextAttributes);\n}\n\n/**\n * Safely set attributes on a span JSON.\n * If an attribute already exists, it will not be overwritten.\n */\nexport function safeSetSpanJSONAttributes(\n spanJSON: StreamedSpanJSON,\n newAttributes: RawAttributes<Record<string, unknown>>,\n): void {\n const originalAttributes = spanJSON.attributes ?? (spanJSON.attributes = {});\n\n Object.entries(newAttributes).forEach(([key, value]) => {\n if (value != null && !(key in originalAttributes)) {\n originalAttributes[key] = value;\n }\n });\n}\n\nfunction applySdkMetadataToSegmentSpan(segmentSpanJSON: StreamedSpanJSON, client: Client): void {\n const integrationNames = client.getIntegrationNames();\n if (!integrationNames.length) return;\n\n safeSetSpanJSONAttributes(segmentSpanJSON, {\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS]: integrationNames,\n });\n}\n\nfunction applyCommonSpanAttributes(\n spanJSON: StreamedSpanJSON,\n serializedSegmentSpan: StreamedSpanJSON,\n client: Client,\n scopeData: ScopeData,\n): void {\n const sdk = client.getSdkMetadata();\n const { release, environment } = client.getOptions();\n\n // avoid overwriting any previously set attributes (from users or potentially our SDK instrumentation)\n safeSetSpanJSONAttributes(spanJSON, {\n [SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: release,\n [SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: environment || DEFAULT_ENVIRONMENT,\n [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME]: serializedSegmentSpan.name,\n [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID]: serializedSegmentSpan.span_id,\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: sdk?.sdk?.name,\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: sdk?.sdk?.version,\n [SEMANTIC_ATTRIBUTE_USER_ID]: scopeData.user?.id,\n [SEMANTIC_ATTRIBUTE_USER_EMAIL]: scopeData.user?.email,\n [SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS]: scopeData.user?.ip_address,\n [SEMANTIC_ATTRIBUTE_USER_USERNAME]: scopeData.user?.username,\n ...scopeData.attributes,\n });\n}\n\n/**\n * Apply a user-provided beforeSendSpan callback to a span JSON.\n */\nexport function applyBeforeSendSpanCallback(\n span: StreamedSpanJSON,\n beforeSendSpan: (span: StreamedSpanJSON) => StreamedSpanJSON,\n): StreamedSpanJSON {\n const modifedSpan = beforeSendSpan(span);\n if (!modifedSpan) {\n showSpanDropWarning();\n return span;\n }\n return modifedSpan;\n}\n"],"names":["spanToStreamedSpanJSON","INTERNAL_getSegmentSpan","getCapturedScopesOnSpan","getCombinedScopeData","beforeSendSpan","isStreamedBeforeSendSpanCallback","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","streamedSpanJsonToSerializedSpan","scopeContextsToSpanAttributes","SEMANTIC_ATTRIB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;;;;"} | ||
| {"version":3,"file":"captureSpan.js","sources":["../../../../src/tracing/spans/captureSpan.ts"],"sourcesContent":["import type { RawAttributes } from '../../attributes';\nimport type { Client } from '../../client';\nimport type { ScopeData } from '../../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT,\n SEMANTIC_ATTRIBUTE_SENTRY_RELEASE,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_USER_EMAIL,\n SEMANTIC_ATTRIBUTE_USER_ID,\n SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS,\n SEMANTIC_ATTRIBUTE_USER_USERNAME,\n} from '../../semanticAttributes';\nimport type { SerializedStreamedSpan, Span, StreamedSpanJSON } from '../../types/span';\nimport { getCombinedScopeData } from '../../utils/scopeData';\nimport {\n INTERNAL_getSegmentSpan,\n showSpanDropWarning,\n spanToStreamedSpanJSON,\n streamedSpanJsonToSerializedSpan,\n} from '../../utils/spanUtils';\nimport { getCapturedScopesOnSpan } from '../utils';\nimport { isStreamedBeforeSendSpanCallback } from './beforeSendSpan';\nimport { scopeContextsToSpanAttributes } from './scopeContextAttributes';\nimport { DEFAULT_ENVIRONMENT } from '../../constants';\nimport { SENTRY_SPAN_SOURCE, SENTRY_TRACE_LIFECYCLE } from '@sentry/conventions/attributes';\n\nexport type SerializedStreamedSpanWithSegmentSpan = SerializedStreamedSpan & {\n _segmentSpan: Span;\n};\n\n/**\n * Captures a span and returns a JSON representation to be enqueued for sending.\n *\n * IMPORTANT: This function converts the span to JSON immediately to avoid writing\n * to an already-ended OTel span instance (which is blocked by the OTel Span class).\n *\n * @returns the final serialized span with a reference to its segment span. This reference\n * is needed later on to compute the DSC for the span envelope.\n */\nexport function captureSpan(span: Span, client: Client): SerializedStreamedSpanWithSegmentSpan {\n // Convert to JSON FIRST - we cannot write to an already-ended span\n const spanJSON = spanToStreamedSpanJSON(span);\n\n const segmentSpan = INTERNAL_getSegmentSpan(span);\n const serializedSegmentSpan = spanToStreamedSpanJSON(segmentSpan);\n\n const { isolationScope: spanIsolationScope, scope: spanScope } = getCapturedScopesOnSpan(span);\n\n const finalScopeData = getCombinedScopeData(spanIsolationScope, spanScope);\n\n applyCommonSpanAttributes(spanJSON, serializedSegmentSpan, client, finalScopeData);\n\n // Access `kind` via duck-typing — OTel span objects have this property but it's not on Sentry's Span type.\n // It is forwarded to `preprocessSpan` subscribers (e.g. the OpenTelemetry SDK backfills op/source/name from it).\n const spanKind = (span as { kind?: number }).kind;\n\n // Preprocess the span JSON before any other hooks run, so that `processSpan`/`processSegmentSpan`\n // subscribers (incl. integrations) and `beforeSendSpan` see fully inferred span data.\n client.emit('preprocessSpan', spanJSON, { spanKind });\n\n if (spanJSON.is_segment) {\n applyScopeToSegmentSpan(spanJSON, finalScopeData);\n applySdkMetadataToSegmentSpan(spanJSON, client);\n // Allow hook subscribers to mutate the segment span JSON\n // This also invokes the `processSegmentSpan` hook of all integrations\n client.emit('processSegmentSpan', spanJSON);\n }\n\n // This allows hook subscribers to mutate the span JSON\n // This also invokes the `processSpan` hook of all integrations\n client.emit('processSpan', spanJSON);\n\n const { beforeSendSpan } = client.getOptions();\n const processedSpan =\n beforeSendSpan && isStreamedBeforeSendSpanCallback(beforeSendSpan)\n ? applyBeforeSendSpanCallback(spanJSON, beforeSendSpan)\n : spanJSON;\n\n // Backfill sentry.span.source from sentry.source. Only `sentry.span.source` is respected by Sentry.\n // TODO(v11): Remove this backfill once we renamed SEMANTIC_ATTRIBUTE_SENTRY_SOURCE to sentry.span.source\n const spanNameSource = processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n if (spanNameSource) {\n safeSetSpanJSONAttributes(processedSpan, {\n [SENTRY_SPAN_SOURCE]: spanNameSource,\n });\n }\n\n return {\n ...streamedSpanJsonToSerializedSpan(processedSpan),\n _segmentSpan: segmentSpan,\n };\n}\n\nfunction applyScopeToSegmentSpan(segmentSpanJSON: StreamedSpanJSON, scopeData: ScopeData): void {\n const contextAttributes = scopeContextsToSpanAttributes(scopeData.contexts);\n safeSetSpanJSONAttributes(segmentSpanJSON, contextAttributes);\n}\n\n/**\n * Safely set attributes on a span JSON.\n * If an attribute already exists, it will not be overwritten.\n */\nexport function safeSetSpanJSONAttributes(\n spanJSON: StreamedSpanJSON,\n newAttributes: RawAttributes<Record<string, unknown>>,\n): void {\n const originalAttributes = spanJSON.attributes ?? (spanJSON.attributes = {});\n\n Object.entries(newAttributes).forEach(([key, value]) => {\n if (value != null && !(key in originalAttributes)) {\n originalAttributes[key] = value;\n }\n });\n}\n\nfunction applySdkMetadataToSegmentSpan(segmentSpanJSON: StreamedSpanJSON, client: Client): void {\n const integrationNames = client.getIntegrationNames();\n if (!integrationNames.length) return;\n\n safeSetSpanJSONAttributes(segmentSpanJSON, {\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS]: integrationNames,\n });\n}\n\nfunction applyCommonSpanAttributes(\n spanJSON: StreamedSpanJSON,\n serializedSegmentSpan: StreamedSpanJSON,\n client: Client,\n scopeData: ScopeData,\n): void {\n const sdk = client.getSdkMetadata();\n const { release, environment } = client.getOptions();\n\n // avoid overwriting any previously set attributes (from users or potentially our SDK instrumentation)\n safeSetSpanJSONAttributes(spanJSON, {\n [SENTRY_TRACE_LIFECYCLE]: 'stream',\n [SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: release,\n [SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: environment || DEFAULT_ENVIRONMENT,\n [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME]: serializedSegmentSpan.name,\n [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID]: serializedSegmentSpan.span_id,\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: sdk?.sdk?.name,\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: sdk?.sdk?.version,\n [SEMANTIC_ATTRIBUTE_USER_ID]: scopeData.user?.id,\n [SEMANTIC_ATTRIBUTE_USER_EMAIL]: scopeData.user?.email,\n [SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS]: scopeData.user?.ip_address,\n [SEMANTIC_ATTRIBUTE_USER_USERNAME]: scopeData.user?.username,\n ...scopeData.attributes,\n });\n}\n\n/**\n * Apply a user-provided beforeSendSpan callback to a span JSON.\n */\nexport function applyBeforeSendSpanCallback(\n span: StreamedSpanJSON,\n beforeSendSpan: (span: StreamedSpanJSON) => StreamedSpanJSON,\n): StreamedSpanJSON {\n const modifedSpan = beforeSendSpan(span);\n if (!modifedSpan) {\n showSpanDropWarning();\n return span;\n }\n return modifedSpan;\n}\n"],"names":["spanToStreamedSpanJSON","INTERNAL_getSegmentSpan","getCapturedScopesOnSpan","getCombinedScopeData","beforeSendSpan","isStreamedBeforeSendSpanCallback","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SENTRY_SPAN_SOURCE","streamedSpanJsonToSerializedSpan","scopeContextsToSpanAttributes","SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS","SENTRY_TRACE_LIFECYCLE","SEMANTIC_ATTRIBUTE_SENTRY_RELEASE","SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT","DEFAULT_ENVIRONMENT","SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME","SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID","SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME","SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION","SEMANTIC_ATTRIBUTE_USER_ID","SEMANTIC_ATTRIBUTE_USER_EMAIL","SEMANTIC_ATTRIBUTE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,QAAA,EAAU;AAAA,IAClC,CAACC,iCAAsB,GAAG,QAAA;AAAA,IAC1B,CAACC,oDAAiC,GAAG,OAAA;AAAA,IACrC,CAACC,wDAAqC,GAAG,WAAA,IAAeC,6BAAA;AAAA,IACxD,CAACC,yDAAsC,GAAG,qBAAA,CAAsB,IAAA;AAAA,IAChE,CAACC,uDAAoC,GAAG,qBAAA,CAAsB,OAAA;AAAA,IAC9D,CAACC,qDAAkC,GAAG,GAAA,EAAK,GAAA,EAAK,IAAA;AAAA,IAChD,CAACC,wDAAqC,GAAG,GAAA,EAAK,GAAA,EAAK,OAAA;AAAA,IACnD,CAACC,6CAA0B,GAAG,SAAA,CAAU,IAAA,EAAM,EAAA;AAAA,IAC9C,CAACC,gDAA6B,GAAG,SAAA,CAAU,IAAA,EAAM,KAAA;AAAA,IACjD,CAACC,qDAAkC,GAAG,SAAA,CAAU,IAAA,EAAM,UAAA;AAAA,IACtD,CAACC,mDAAgC,GAAG,SAAA,CAAU,IAAA,EAAM,QAAA;AAAA,IACpD,GAAG,SAAA,CAAU;AAAA,GACd,CAAA;AACH;AAKO,SAAS,2BAAA,CACd,MACA,cAAA,EACkB;AAClB,EAAA,MAAM,WAAA,GAAc,eAAe,IAAI,CAAA;AACvC,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAAC,6BAAA,EAAoB;AACpB,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,WAAA;AACT;;;;;;"} |
@@ -50,3 +50,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| }); | ||
| if (!_isIgnoredSpan(activeSpan) || !parentSpan) { | ||
| if (!spanIsIgnored(activeSpan) || !parentSpan) { | ||
| spanOnScope._setSpanForScope(scope, activeSpan); | ||
@@ -89,3 +89,3 @@ } | ||
| }); | ||
| if (!_isIgnoredSpan(activeSpan) || !parentSpan) { | ||
| if (!spanIsIgnored(activeSpan) || !parentSpan) { | ||
| spanOnScope._setSpanForScope(scope, activeSpan); | ||
@@ -114,2 +114,8 @@ } | ||
| } | ||
| return _startInactiveSpanImpl(options); | ||
| } | ||
| function _INTERNAL_startInactiveSpan(options) { | ||
| return _startInactiveSpanImpl(options); | ||
| } | ||
| function _startInactiveSpanImpl(options) { | ||
| const spanArguments = parseSentrySpanArguments(options); | ||
@@ -404,3 +410,3 @@ const { forceTransaction, parentSpan: customParentSpan } = options; | ||
| } | ||
| function _isIgnoredSpan(span) { | ||
| function spanIsIgnored(span) { | ||
| return sentryNonRecordingSpan.spanIsNonRecordingSpan(span) && span.dropReason === "ignored"; | ||
@@ -410,4 +416,6 @@ } | ||
| exports.SUPPRESS_TRACING_KEY = SUPPRESS_TRACING_KEY; | ||
| exports._INTERNAL_startInactiveSpan = _INTERNAL_startInactiveSpan; | ||
| exports.continueTrace = continueTrace; | ||
| exports.isTracingSuppressed = isTracingSuppressed; | ||
| exports.spanIsIgnored = spanIsIgnored; | ||
| exports.startInactiveSpan = startInactiveSpan; | ||
@@ -414,0 +422,0 @@ exports.startNewTrace = startNewTrace; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"trace.js","sources":["../../../src/tracing/trace.ts"],"sourcesContent":["/* eslint-disable max-lines */\n\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { AsyncContextStrategy } from '../asyncContext/types';\nimport { getMainCarrier } from '../carrier';\nimport { getClient, getCurrentScope, getIsolationScope, withScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Scope } from '../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { ClientOptions } from '../types/options';\nimport type { SentrySpanArguments, Span, SpanTimeInput } from '../types/span';\nimport type { StartSpanOptions } from '../types/startSpanOptions';\nimport { baggageHeaderToDynamicSamplingContext } from '../utils/baggage';\nimport { debug } from '../utils/debug-logger';\nimport { handleCallbackErrors } from '../utils/handleCallbackErrors';\nimport { hasSpansEnabled } from '../utils/hasSpansEnabled';\nimport { shouldIgnoreSpan } from '../utils/should-ignore-span';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport { parseSampleRate } from '../utils/parseSampleRate';\nimport { generateTraceId } from '../utils/propagationContext';\nimport { safeMathRandom } from '../utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from '../utils/spanOnScope';\nimport { addChildSpanToSpan, getRootSpan, spanIsSampled, spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils';\nimport { propagationContextFromHeaders, shouldContinueTrace } from '../utils/tracing';\nimport { freezeDscOnSpan, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanStart } from './logSpans';\nimport { sampleSpan } from './sampling';\nimport { SentryNonRecordingSpan, spanIsNonRecordingSpan } from './sentryNonRecordingSpan';\nimport { SentrySpan } from './sentrySpan';\nimport { SPAN_STATUS_ERROR } from './spanstatus';\nimport { setCapturedScopesOnSpan } from './utils';\nimport type { Client } from '../client';\n\nexport const SUPPRESS_TRACING_KEY = '__SENTRY_SUPPRESS_TRACING__';\n\n/**\n * Wraps a function with a transaction/span and finishes the span after the function is done.\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * If you want to create a span that is not set as active, use {@link startInactiveSpan}.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T): T {\n const acs = getAcs();\n if (acs.startSpan) {\n return acs.startSpan(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n // We still need to fork a potentially passed scope, as we set the active span on it\n // and we need to ensure that it is cleaned up properly once the span ends.\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n const client = getClient();\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n const activeSpan = missingRequiredParent\n ? startMissingRequiredParentSpan(scope, client)\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n // Ignored root spans still need to be set on scope so that `getActiveSpan()` returns them\n // and descendants are also non-recording. Ignored child spans don't need this because\n // the parent span is already on scope.\n if (!_isIgnoredSpan(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n () => callback(activeSpan),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n () => {\n activeSpan.end();\n },\n );\n });\n });\n}\n\n/**\n * Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span\n * after the function is done automatically. Use `span.end()` to end the span.\n *\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpanManual<T>(options: StartSpanOptions, callback: (span: Span, finish: () => void) => T): T {\n const acs = getAcs();\n if (acs.startSpanManual) {\n return acs.startSpanManual(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n const activeSpan = missingRequiredParent\n ? startMissingRequiredParentSpan(scope, getClient())\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n // We don't set ignored child spans onto the scope because there likely is an active,\n // unignored span on the scope already.\n if (!_isIgnoredSpan(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n // We pass the `finish` function to the callback, so the user can finish the span manually\n // this is mainly here for historic purposes because previously, we instructed users to call\n // `finish` instead of `span.end()` to also clean up the scope. Nowadays, calling `span.end()`\n // or `finish` has the same effect and we simply leave it here to avoid breaking user code.\n () => callback(activeSpan, () => activeSpan.end()),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n );\n });\n });\n}\n\n/**\n * Creates a span. This span is not set as active, so will not get automatic instrumentation spans\n * as children or be able to be accessed via `Sentry.getActiveSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * This function will always return a span,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startInactiveSpan(options: StartSpanOptions): Span {\n const acs = getAcs();\n if (acs.startInactiveSpan) {\n return acs.startInactiveSpan(options);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan } = options;\n\n // If `options.scope` is defined, we use this as as a wrapper,\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = options.scope\n ? (callback: () => Span) => withScope(options.scope, callback)\n : customParentSpan !== undefined\n ? (callback: () => Span) => withActiveSpan(customParentSpan, callback)\n : (callback: () => Span) => callback();\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n const client = getClient();\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n\n if (missingRequiredParent) {\n return startMissingRequiredParentSpan(scope, client);\n }\n\n return createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n });\n}\n\n/**\n * Continue a trace from `sentry-trace` and `baggage` values.\n * These values can be obtained from incoming request headers, or in the browser from `<meta name=\"sentry-trace\">`\n * and `<meta name=\"baggage\">` HTML tags.\n *\n * Spans started with `startSpan`, `startSpanManual` and `startInactiveSpan`, within the callback will automatically\n * be attached to the incoming trace.\n */\nexport const continueTrace = <V>(\n options: {\n sentryTrace: Parameters<typeof propagationContextFromHeaders>[0];\n baggage: Parameters<typeof propagationContextFromHeaders>[1];\n },\n callback: () => V,\n): V => {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.continueTrace) {\n return acs.continueTrace(options, callback);\n }\n\n const { sentryTrace, baggage } = options;\n\n const client = getClient();\n const incomingDsc = baggageHeaderToDynamicSamplingContext(baggage);\n if (client && !shouldContinueTrace(client, incomingDsc?.org_id)) {\n return startNewTrace(callback);\n }\n\n return withScope(scope => {\n const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);\n scope.setPropagationContext(propagationContext);\n _setSpanForScope(scope, undefined);\n return callback();\n });\n};\n\n/**\n * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be\n * passed `null` to start an entirely new span tree.\n *\n * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,\n * spans started within the callback will not be attached to a parent span.\n * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.\n * @returns the value returned from the provided callback function.\n */\nexport function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T {\n const acs = getAcs();\n if (acs.withActiveSpan) {\n return acs.withActiveSpan(span, callback);\n }\n\n return withScope(scope => {\n _setSpanForScope(scope, span || undefined);\n return callback(scope);\n });\n}\n\n/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */\nexport function suppressTracing<T>(callback: () => T): T {\n const acs = getAcs();\n\n if (acs.suppressTracing) {\n return acs.suppressTracing(callback);\n }\n\n return withScope(scope => {\n // Note: We do not wait for the callback to finish before we reset the metadata\n // the reason for this is that otherwise, in the browser this can lead to very weird behavior\n // as there is only a single top scope, if the callback takes longer to finish,\n // other, unrelated spans may also be suppressed, which we do not want\n // so instead, we only suppress tracing synchronoysly in the browser\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });\n const res = callback();\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: undefined });\n return res;\n });\n}\n\n/** Check if tracing is suppressed. */\nexport function isTracingSuppressed(scope = getCurrentScope()): boolean {\n const acs = getAcs();\n\n if (acs.isTracingSuppressed) {\n return acs.isTracingSuppressed(scope);\n }\n\n return scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY] === true;\n}\n\n/**\n * Starts a new trace for the duration of the provided callback. Spans started within the\n * callback will be part of the new trace instead of a potentially previously started trace.\n *\n * Important: Only use this function if you want to override the default trace lifetime and\n * propagation mechanism of the SDK for the duration and scope of the provided callback.\n * The newly created trace will also be the root of a new distributed trace, for example if\n * you make http requests within the callback.\n * This function might be useful if the operation you want to instrument should not be part\n * of a potentially ongoing trace.\n *\n * Default behavior:\n * - Server-side: A new trace is started for each incoming request.\n * - Browser: A new trace is started for each page our route. Navigating to a new route\n * or page will automatically create a new trace.\n */\nexport function startNewTrace<T>(callback: () => T): T {\n const acs = getAcs();\n if (acs.startNewTrace) {\n return acs.startNewTrace(callback);\n }\n\n return withScope(scope => {\n scope.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n DEBUG_BUILD && debug.log(`Starting a new trace with id ${scope.getPropagationContext().traceId}`);\n return withActiveSpan(null, callback);\n });\n}\n\n/**\n * The placeholder returned from `startSpan*` when `onlyIfParent` is set but there is no parent span.\n * It carries the current trace id and captured scopes so the trace data it propagates (and any nested\n * span that resolves it as its root via `getRootSpan`) reads its DSC from the scope, preserving a\n * continued trace's DSC instead of fabricating a fresh client one. Also records the dropped-span outcome.\n */\nfunction startMissingRequiredParentSpan(scope: Scope, client: Client | undefined): SentryNonRecordingSpan {\n client?.recordDroppedEvent('no_parent_span', 'span');\n const span = new SentryNonRecordingSpan({ traceId: scope.getPropagationContext().traceId });\n setCapturedScopesOnSpan(span, scope, getIsolationScope());\n return span;\n}\n\nfunction createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n}: {\n parentSpan: SentrySpan | undefined;\n spanArguments: SentrySpanArguments;\n forceTransaction?: boolean;\n scope: Scope;\n}): Span {\n const isolationScope = getIsolationScope();\n\n if (!hasSpansEnabled()) {\n const scopePropagationContext = { ...isolationScope.getPropagationContext(), ...scope.getPropagationContext() };\n const traceId = parentSpan ? parentSpan.spanContext().traceId : scopePropagationContext.traceId;\n\n // The placeholder is a thin marker; it carries no sampling decision or DSC. Both are read from\n // the scope: the sampling decision in `getTraceData`, the DSC in `getDynamicSamplingContextFromSpan`.\n const span = new SentryNonRecordingSpan({ traceId });\n\n // Nested placeholders link to their parent so `getRootSpan` resolves to the root placeholder,\n // whose captured scope is the source of truth. Root/forced placeholders are their own root.\n if (parentSpan && !forceTransaction) {\n addChildSpanToSpan(parentSpan, span);\n }\n\n // Capture scopes so consumers (e.g. SentryTraceProvider) can read them and so the DSC can be\n // resolved from the scope by `getDynamicSamplingContextFromSpan`. Consistent with `startIdleSpan`.\n setCapturedScopesOnSpan(span, scope, isolationScope);\n\n return span;\n }\n\n const client = getClient();\n if (_shouldIgnoreStreamedSpan(client, spanArguments)) {\n if (!isTracingSuppressed(scope)) {\n // if tracing is actively suppressed (Sentry.suppressTracing(...)),\n // we don't want to record a client outcome for the ignored span\n client?.recordDroppedEvent('ignored', 'span');\n }\n\n const ignoredSpan = new SentryNonRecordingSpan({\n dropReason: 'ignored',\n traceId: parentSpan?.spanContext().traceId ?? scope.getPropagationContext().traceId,\n });\n setCapturedScopesOnSpan(ignoredSpan, scope, isolationScope);\n\n return ignoredSpan;\n }\n\n let span: Span;\n if (parentSpan && !forceTransaction) {\n span = _startChildSpan(parentSpan, scope, spanArguments, isolationScope);\n addChildSpanToSpan(parentSpan, span);\n } else if (parentSpan) {\n // If we forced a transaction but have a parent span, make sure to continue from the parent span, not the scope\n const dsc = getDynamicSamplingContextFromSpan(parentSpan);\n const { traceId, spanId: parentSpanId } = parentSpan.spanContext();\n const parentSampled = spanIsSampled(parentSpan);\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n isolationScope,\n parentSampled,\n );\n\n freezeDscOnSpan(span, dsc);\n } else {\n const {\n traceId,\n dsc,\n parentSpanId,\n sampled: parentSampled,\n } = {\n ...isolationScope.getPropagationContext(),\n ...scope.getPropagationContext(),\n };\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n isolationScope,\n parentSampled,\n );\n\n if (dsc) {\n freezeDscOnSpan(span, dsc);\n }\n }\n\n logSpanStart(span);\n\n return span;\n}\n\n/**\n * This converts StartSpanOptions to SentrySpanArguments.\n * For the most part (for now) we accept the same options,\n * but some of them need to be transformed.\n */\nfunction parseSentrySpanArguments(options: StartSpanOptions): SentrySpanArguments {\n const exp = options.experimental || {};\n const initialCtx: SentrySpanArguments = {\n isStandalone: exp.standalone,\n ...options,\n };\n\n if (options.startTime) {\n const ctx: SentrySpanArguments & { startTime?: SpanTimeInput } = { ...initialCtx };\n ctx.startTimestamp = spanTimeInputToSeconds(options.startTime);\n delete ctx.startTime;\n return ctx;\n }\n\n return initialCtx;\n}\n\nfunction getAcs(): AsyncContextStrategy {\n const carrier = getMainCarrier();\n return getAsyncContextStrategy(carrier);\n}\n\nfunction _startRootSpan(\n spanArguments: SentrySpanArguments,\n scope: Scope,\n isolationScope: Scope,\n parentSampled?: boolean,\n): SentrySpan {\n const client = getClient();\n const options: Partial<ClientOptions> = client?.getOptions() || {};\n\n const { name = '' } = spanArguments;\n\n const mutableSpanSamplingData = { spanAttributes: { ...spanArguments.attributes }, spanName: name, parentSampled };\n\n // we don't care about the decision for the moment; this is just a placeholder\n client?.emit('beforeSampling', mutableSpanSamplingData, { decision: false });\n\n // If hook consumers override the parentSampled flag, we will use that value instead of the actual one\n const finalParentSampled = mutableSpanSamplingData.parentSampled ?? parentSampled;\n const finalAttributes = mutableSpanSamplingData.spanAttributes;\n\n const currentPropagationContext = scope.getPropagationContext();\n const _isTracingSuppressed = isTracingSuppressed(scope);\n\n const [sampled, sampleRate, localSampleRateWasApplied] = _isTracingSuppressed\n ? [false]\n : sampleSpan(\n options,\n {\n name,\n parentSampled: finalParentSampled,\n attributes: finalAttributes,\n normalizedRequest: isolationScope.getScopeData().sdkProcessingMetadata.normalizedRequest,\n parentSampleRate: parseSampleRate(currentPropagationContext.dsc?.sample_rate),\n },\n currentPropagationContext.sampleRand,\n );\n\n const rootSpan = new SentrySpan({\n ...spanArguments,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]:\n sampleRate !== undefined && localSampleRateWasApplied ? sampleRate : undefined,\n ...finalAttributes,\n },\n sampled,\n });\n\n if (!sampled && client && !_isTracingSuppressed) {\n DEBUG_BUILD && debug.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');\n client.recordDroppedEvent('sample_rate', hasSpanStreamingEnabled(client) ? 'span' : 'transaction');\n }\n\n setCapturedScopesOnSpan(rootSpan, scope, isolationScope);\n\n if (client) {\n client.emit('spanStart', rootSpan);\n }\n\n return rootSpan;\n}\n\n/**\n * Creates a new `Span` while setting the current `Span.id` as `parentSpanId`.\n * This inherits the sampling decision from the parent span.\n */\nfunction _startChildSpan(\n parentSpan: Span,\n scope: Scope,\n spanArguments: SentrySpanArguments,\n isolationScope: Scope,\n): Span {\n const { spanId, traceId } = parentSpan.spanContext();\n const _isTracingSuppressed = isTracingSuppressed(scope);\n const sampled = _isTracingSuppressed ? false : spanIsSampled(parentSpan);\n\n const childSpan = sampled\n ? new SentrySpan({\n ...spanArguments,\n parentSpanId: spanId,\n traceId,\n sampled,\n })\n : new SentryNonRecordingSpan({ traceId });\n\n addChildSpanToSpan(parentSpan, childSpan);\n\n setCapturedScopesOnSpan(childSpan, scope, isolationScope);\n\n const client = getClient();\n\n if (!client) {\n return childSpan;\n }\n\n if (hasSpanStreamingEnabled(client) && spanIsNonRecordingSpan(childSpan)) {\n if (spanIsNonRecordingSpan(parentSpan) && parentSpan.dropReason) {\n // We land here if the parent span was a segment span that was ignored (`ignoreSpans`).\n // In this case, the child was also ignored (see `sampled` above) but we need to\n // record a client outcome for the child.\n childSpan.dropReason = parentSpan.dropReason;\n client.recordDroppedEvent(parentSpan.dropReason, 'span');\n } else if (!_isTracingSuppressed) {\n // Otherwise, the child is not sampled due to sampling of the parent span,\n // hence we record a sample_rate client outcome for the child.\n childSpan.dropReason = 'sample_rate';\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n\n client.emit('spanStart', childSpan);\n // If it has an endTimestamp, it's already ended\n if (spanArguments.endTimestamp) {\n client.emit('spanEnd', childSpan);\n client.emit('afterSpanEnd', childSpan);\n }\n\n return childSpan;\n}\n\nfunction getParentSpan(scope: Scope, customParentSpan: Span | null | undefined): SentrySpan | undefined {\n // always use the passed in span directly\n if (customParentSpan) {\n return customParentSpan as SentrySpan;\n }\n\n // This is different from `undefined` as it means the user explicitly wants no parent span\n if (customParentSpan === null) {\n return undefined;\n }\n\n const span = _getSpanForScope(scope) as SentrySpan | undefined;\n\n if (!span) {\n return undefined;\n }\n\n const client = getClient();\n const options: Partial<ClientOptions> = client ? client.getOptions() : {};\n if (options.parentSpanIsAlwaysRootSpan) {\n return getRootSpan(span) as SentrySpan;\n }\n\n return span;\n}\n\nfunction getActiveSpanWrapper<T>(parentSpan: Span | undefined | null): (callback: () => T) => T {\n return parentSpan !== undefined\n ? (callback: () => T) => {\n return withActiveSpan(parentSpan, callback);\n }\n : (callback: () => T) => callback();\n}\n\n/* Checks if `ignoreSpans` applies (extracted for bundle size)*/\nfunction _shouldIgnoreStreamedSpan(client: Client | undefined, spanArguments: SentrySpanArguments): boolean {\n const ignoreSpans = client?.getOptions().ignoreSpans;\n\n if (!client || !hasSpanStreamingEnabled(client) || !ignoreSpans?.length) {\n return false;\n }\n\n return shouldIgnoreSpan(\n {\n description: spanArguments.name || '',\n op: spanArguments.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP] || spanArguments.op,\n attributes: spanArguments.attributes,\n },\n ignoreSpans,\n );\n}\n\nfunction _isIgnoredSpan(span: Span): span is SentryNonRecordingSpan {\n return spanIsNonRecordingSpan(span) && span.dropReason === 'ignored';\n}\n"],"names":["withScope","getCurrentScope","getClient","_setSpanForScope","handleCallbackErrors","spanToJSON","SPAN_STATUS_ERROR","carrier","getMainCarrier","getAsyncContextStrategy","baggage","baggageHeaderToDynamicSamplingContext","shouldContinueTrace","propagationContextFromHeaders","generateTraceId","safeMathRandom","DEBUG_BUILD","debug","SentryNonRecordingSpan","setCapturedScopesOnSpan","getIsolationScope","hasSpansEnabled","span","addChildSpanToSpan","getDynamicSamplingContextFromSpan","spanIsSampled","freezeDscOnSpan","logSpanStart","spanTimeInputToSeconds","sampleSpan","parseSampleRate","SentrySpan","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE","hasSpanStreamingEnabled","spanIsNonRecordingSpan","_getSpanForScope","getRootSpan","shouldIgnoreSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,MAAM,oBAAA,GAAuB;AAY7B,SAAS,SAAA,CAAa,SAA2B,QAAA,EAAgC;AACtF,EAAA,MAAM,MAAM,MAAA,EAAO;AACnB,EAAA,IAAI,IAAI,SAAA,EAAW;AACjB,IAAA,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AGA,SAAS,yBAAA,CAA0B,QAA4B,aAAA,EAA6C;AAC1G,EAAA,MAAM,WAAA,GAAc,MAAA,EAAQ,UAAA,EAAW,CAAE,WAAA;AAEzC,EAAA,IAAI,CAAC,UAAU,CAACH,+CAAA,CAAwB,MAAM,CAAA,IAAK,CAAC,aAAa,MAAA,EAAQ;AACvE,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAOI,iCAAA;AAAA,IACL;AAAA,MACE,WAAA,EAAa,cAAc,IAAA,IAAQ,EAAA;AAAA,MACnC,EAAA,EAAI,aAAA,CAAc,UAAA,GAAaC,+CAA4B,KAAK,aAAA,CAAc,EAAA;AAAA,MAC9E,YAAY,aAAA,CAAc;AAAA,KAC5B;AAAA,IACA;AAAA,GACF;AACF;AAEA,SAAS,eAAe,IAAA,EAA4C;AAClE,EAAA,OAAOJ,6CAAA,CAAuB,IAAI,CAAA,IAAK,IAAA,CAAK,UAAA,KAAe,SAAA;AAC7D;;;;;;;;;;;;"} | ||
| {"version":3,"file":"trace.js","sources":["../../../src/tracing/trace.ts"],"sourcesContent":["/* eslint-disable max-lines */\n\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { AsyncContextStrategy } from '../asyncContext/types';\nimport { getMainCarrier } from '../carrier';\nimport { getClient, getCurrentScope, getIsolationScope, withScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Scope } from '../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { ClientOptions } from '../types/options';\nimport type { SentrySpanArguments, Span, SpanTimeInput } from '../types/span';\nimport type { StartSpanOptions } from '../types/startSpanOptions';\nimport { baggageHeaderToDynamicSamplingContext } from '../utils/baggage';\nimport { debug } from '../utils/debug-logger';\nimport { handleCallbackErrors } from '../utils/handleCallbackErrors';\nimport { hasSpansEnabled } from '../utils/hasSpansEnabled';\nimport { shouldIgnoreSpan } from '../utils/should-ignore-span';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport { parseSampleRate } from '../utils/parseSampleRate';\nimport { generateTraceId } from '../utils/propagationContext';\nimport { safeMathRandom } from '../utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from '../utils/spanOnScope';\nimport { addChildSpanToSpan, getRootSpan, spanIsSampled, spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils';\nimport { propagationContextFromHeaders, shouldContinueTrace } from '../utils/tracing';\nimport { freezeDscOnSpan, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanStart } from './logSpans';\nimport { sampleSpan } from './sampling';\nimport { SentryNonRecordingSpan, spanIsNonRecordingSpan } from './sentryNonRecordingSpan';\nimport { SentrySpan } from './sentrySpan';\nimport { SPAN_STATUS_ERROR } from './spanstatus';\nimport { setCapturedScopesOnSpan } from './utils';\nimport type { Client } from '../client';\n\nexport const SUPPRESS_TRACING_KEY = '__SENTRY_SUPPRESS_TRACING__';\n\n/**\n * Wraps a function with a transaction/span and finishes the span after the function is done.\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * If you want to create a span that is not set as active, use {@link startInactiveSpan}.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T): T {\n const acs = getAcs();\n if (acs.startSpan) {\n return acs.startSpan(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n // We still need to fork a potentially passed scope, as we set the active span on it\n // and we need to ensure that it is cleaned up properly once the span ends.\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n const client = getClient();\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n const activeSpan = missingRequiredParent\n ? startMissingRequiredParentSpan(scope, client)\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n // Ignored root spans still need to be set on scope so that `getActiveSpan()` returns them\n // and descendants are also non-recording. Ignored child spans don't need this because\n // the parent span is already on scope.\n if (!spanIsIgnored(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n () => callback(activeSpan),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n () => {\n activeSpan.end();\n },\n );\n });\n });\n}\n\n/**\n * Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span\n * after the function is done automatically. Use `span.end()` to end the span.\n *\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpanManual<T>(options: StartSpanOptions, callback: (span: Span, finish: () => void) => T): T {\n const acs = getAcs();\n if (acs.startSpanManual) {\n return acs.startSpanManual(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n const activeSpan = missingRequiredParent\n ? startMissingRequiredParentSpan(scope, getClient())\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n // We don't set ignored child spans onto the scope because there likely is an active,\n // unignored span on the scope already.\n if (!spanIsIgnored(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n // We pass the `finish` function to the callback, so the user can finish the span manually\n // this is mainly here for historic purposes because previously, we instructed users to call\n // `finish` instead of `span.end()` to also clean up the scope. Nowadays, calling `span.end()`\n // or `finish` has the same effect and we simply leave it here to avoid breaking user code.\n () => callback(activeSpan, () => activeSpan.end()),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n );\n });\n });\n}\n\n/**\n * Creates a span. This span is not set as active, so will not get automatic instrumentation spans\n * as children or be able to be accessed via `Sentry.getActiveSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * This function will always return a span,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startInactiveSpan(options: StartSpanOptions): Span {\n const acs = getAcs();\n if (acs.startInactiveSpan) {\n return acs.startInactiveSpan(options);\n }\n\n return _startInactiveSpanImpl(options);\n}\n\n/**\n * Internal version of startInactiveSpan that bypasses the ACS check.\n * Used by SentryTracerProvider to create spans without triggering recursion\n * through ACS overrides.\n * @hidden\n */\nexport function _INTERNAL_startInactiveSpan(options: StartSpanOptions): Span {\n return _startInactiveSpanImpl(options);\n}\n\nfunction _startInactiveSpanImpl(options: StartSpanOptions): Span {\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan } = options;\n\n // If `options.scope` is defined, we use this as as a wrapper,\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = options.scope\n ? (callback: () => Span) => withScope(options.scope, callback)\n : customParentSpan !== undefined\n ? (callback: () => Span) => withActiveSpan(customParentSpan, callback)\n : (callback: () => Span) => callback();\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n const client = getClient();\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n\n if (missingRequiredParent) {\n return startMissingRequiredParentSpan(scope, client);\n }\n\n return createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n });\n}\n\n/**\n * Continue a trace from `sentry-trace` and `baggage` values.\n * These values can be obtained from incoming request headers, or in the browser from `<meta name=\"sentry-trace\">`\n * and `<meta name=\"baggage\">` HTML tags.\n *\n * Spans started with `startSpan`, `startSpanManual` and `startInactiveSpan`, within the callback will automatically\n * be attached to the incoming trace.\n */\nexport const continueTrace = <V>(\n options: {\n sentryTrace: Parameters<typeof propagationContextFromHeaders>[0];\n baggage: Parameters<typeof propagationContextFromHeaders>[1];\n },\n callback: () => V,\n): V => {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.continueTrace) {\n return acs.continueTrace(options, callback);\n }\n\n const { sentryTrace, baggage } = options;\n\n const client = getClient();\n const incomingDsc = baggageHeaderToDynamicSamplingContext(baggage);\n if (client && !shouldContinueTrace(client, incomingDsc?.org_id)) {\n return startNewTrace(callback);\n }\n\n return withScope(scope => {\n const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);\n scope.setPropagationContext(propagationContext);\n _setSpanForScope(scope, undefined);\n return callback();\n });\n};\n\n/**\n * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be\n * passed `null` to start an entirely new span tree.\n *\n * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,\n * spans started within the callback will not be attached to a parent span.\n * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.\n * @returns the value returned from the provided callback function.\n */\nexport function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T {\n const acs = getAcs();\n if (acs.withActiveSpan) {\n return acs.withActiveSpan(span, callback);\n }\n\n return withScope(scope => {\n _setSpanForScope(scope, span || undefined);\n return callback(scope);\n });\n}\n\n/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */\nexport function suppressTracing<T>(callback: () => T): T {\n const acs = getAcs();\n\n if (acs.suppressTracing) {\n return acs.suppressTracing(callback);\n }\n\n return withScope(scope => {\n // Note: We do not wait for the callback to finish before we reset the metadata\n // the reason for this is that otherwise, in the browser this can lead to very weird behavior\n // as there is only a single top scope, if the callback takes longer to finish,\n // other, unrelated spans may also be suppressed, which we do not want\n // so instead, we only suppress tracing synchronoysly in the browser\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });\n const res = callback();\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: undefined });\n return res;\n });\n}\n\n/** Check if tracing is suppressed. */\nexport function isTracingSuppressed(scope = getCurrentScope()): boolean {\n const acs = getAcs();\n\n if (acs.isTracingSuppressed) {\n return acs.isTracingSuppressed(scope);\n }\n\n return scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY] === true;\n}\n\n/**\n * Starts a new trace for the duration of the provided callback. Spans started within the\n * callback will be part of the new trace instead of a potentially previously started trace.\n *\n * Important: Only use this function if you want to override the default trace lifetime and\n * propagation mechanism of the SDK for the duration and scope of the provided callback.\n * The newly created trace will also be the root of a new distributed trace, for example if\n * you make http requests within the callback.\n * This function might be useful if the operation you want to instrument should not be part\n * of a potentially ongoing trace.\n *\n * Default behavior:\n * - Server-side: A new trace is started for each incoming request.\n * - Browser: A new trace is started for each page our route. Navigating to a new route\n * or page will automatically create a new trace.\n */\nexport function startNewTrace<T>(callback: () => T): T {\n const acs = getAcs();\n if (acs.startNewTrace) {\n return acs.startNewTrace(callback);\n }\n\n return withScope(scope => {\n scope.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n DEBUG_BUILD && debug.log(`Starting a new trace with id ${scope.getPropagationContext().traceId}`);\n return withActiveSpan(null, callback);\n });\n}\n\n/**\n * The placeholder returned from `startSpan*` when `onlyIfParent` is set but there is no parent span.\n * It carries the current trace id and captured scopes so the trace data it propagates (and any nested\n * span that resolves it as its root via `getRootSpan`) reads its DSC from the scope, preserving a\n * continued trace's DSC instead of fabricating a fresh client one. Also records the dropped-span outcome.\n */\nfunction startMissingRequiredParentSpan(scope: Scope, client: Client | undefined): SentryNonRecordingSpan {\n client?.recordDroppedEvent('no_parent_span', 'span');\n const span = new SentryNonRecordingSpan({ traceId: scope.getPropagationContext().traceId });\n setCapturedScopesOnSpan(span, scope, getIsolationScope());\n return span;\n}\n\nfunction createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n}: {\n parentSpan: SentrySpan | undefined;\n spanArguments: SentrySpanArguments;\n forceTransaction?: boolean;\n scope: Scope;\n}): Span {\n const isolationScope = getIsolationScope();\n\n if (!hasSpansEnabled()) {\n const scopePropagationContext = { ...isolationScope.getPropagationContext(), ...scope.getPropagationContext() };\n const traceId = parentSpan ? parentSpan.spanContext().traceId : scopePropagationContext.traceId;\n\n // The placeholder is a thin marker; it carries no sampling decision or DSC. Both are read from\n // the scope: the sampling decision in `getTraceData`, the DSC in `getDynamicSamplingContextFromSpan`.\n const span = new SentryNonRecordingSpan({ traceId });\n\n // Nested placeholders link to their parent so `getRootSpan` resolves to the root placeholder,\n // whose captured scope is the source of truth. Root/forced placeholders are their own root.\n if (parentSpan && !forceTransaction) {\n addChildSpanToSpan(parentSpan, span);\n }\n\n // Capture scopes so consumers (e.g. SentryTraceProvider) can read them and so the DSC can be\n // resolved from the scope by `getDynamicSamplingContextFromSpan`. Consistent with `startIdleSpan`.\n setCapturedScopesOnSpan(span, scope, isolationScope);\n\n return span;\n }\n\n const client = getClient();\n if (_shouldIgnoreStreamedSpan(client, spanArguments)) {\n if (!isTracingSuppressed(scope)) {\n // if tracing is actively suppressed (Sentry.suppressTracing(...)),\n // we don't want to record a client outcome for the ignored span\n client?.recordDroppedEvent('ignored', 'span');\n }\n\n const ignoredSpan = new SentryNonRecordingSpan({\n dropReason: 'ignored',\n traceId: parentSpan?.spanContext().traceId ?? scope.getPropagationContext().traceId,\n });\n setCapturedScopesOnSpan(ignoredSpan, scope, isolationScope);\n\n return ignoredSpan;\n }\n\n let span: Span;\n if (parentSpan && !forceTransaction) {\n span = _startChildSpan(parentSpan, scope, spanArguments, isolationScope);\n addChildSpanToSpan(parentSpan, span);\n } else if (parentSpan) {\n // If we forced a transaction but have a parent span, make sure to continue from the parent span, not the scope\n const dsc = getDynamicSamplingContextFromSpan(parentSpan);\n const { traceId, spanId: parentSpanId } = parentSpan.spanContext();\n const parentSampled = spanIsSampled(parentSpan);\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n isolationScope,\n parentSampled,\n );\n\n freezeDscOnSpan(span, dsc);\n } else {\n const {\n traceId,\n dsc,\n parentSpanId,\n sampled: parentSampled,\n } = {\n ...isolationScope.getPropagationContext(),\n ...scope.getPropagationContext(),\n };\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n isolationScope,\n parentSampled,\n );\n\n if (dsc) {\n freezeDscOnSpan(span, dsc);\n }\n }\n\n logSpanStart(span);\n\n return span;\n}\n\n/**\n * This converts StartSpanOptions to SentrySpanArguments.\n * For the most part (for now) we accept the same options,\n * but some of them need to be transformed.\n */\nfunction parseSentrySpanArguments(options: StartSpanOptions): SentrySpanArguments {\n const exp = options.experimental || {};\n const initialCtx: SentrySpanArguments = {\n isStandalone: exp.standalone,\n ...options,\n };\n\n if (options.startTime) {\n const ctx: SentrySpanArguments & { startTime?: SpanTimeInput } = { ...initialCtx };\n ctx.startTimestamp = spanTimeInputToSeconds(options.startTime);\n delete ctx.startTime;\n return ctx;\n }\n\n return initialCtx;\n}\n\nfunction getAcs(): AsyncContextStrategy {\n const carrier = getMainCarrier();\n return getAsyncContextStrategy(carrier);\n}\n\nfunction _startRootSpan(\n spanArguments: SentrySpanArguments,\n scope: Scope,\n isolationScope: Scope,\n parentSampled?: boolean,\n): SentrySpan {\n const client = getClient();\n const options: Partial<ClientOptions> = client?.getOptions() || {};\n\n const { name = '' } = spanArguments;\n\n const mutableSpanSamplingData = { spanAttributes: { ...spanArguments.attributes }, spanName: name, parentSampled };\n\n // we don't care about the decision for the moment; this is just a placeholder\n client?.emit('beforeSampling', mutableSpanSamplingData, { decision: false });\n\n // If hook consumers override the parentSampled flag, we will use that value instead of the actual one\n const finalParentSampled = mutableSpanSamplingData.parentSampled ?? parentSampled;\n const finalAttributes = mutableSpanSamplingData.spanAttributes;\n\n const currentPropagationContext = scope.getPropagationContext();\n const _isTracingSuppressed = isTracingSuppressed(scope);\n\n const [sampled, sampleRate, localSampleRateWasApplied] = _isTracingSuppressed\n ? [false]\n : sampleSpan(\n options,\n {\n name,\n parentSampled: finalParentSampled,\n attributes: finalAttributes,\n normalizedRequest: isolationScope.getScopeData().sdkProcessingMetadata.normalizedRequest,\n parentSampleRate: parseSampleRate(currentPropagationContext.dsc?.sample_rate),\n },\n currentPropagationContext.sampleRand,\n );\n\n const rootSpan = new SentrySpan({\n ...spanArguments,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]:\n sampleRate !== undefined && localSampleRateWasApplied ? sampleRate : undefined,\n ...finalAttributes,\n },\n sampled,\n });\n\n if (!sampled && client && !_isTracingSuppressed) {\n DEBUG_BUILD && debug.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');\n client.recordDroppedEvent('sample_rate', hasSpanStreamingEnabled(client) ? 'span' : 'transaction');\n }\n\n setCapturedScopesOnSpan(rootSpan, scope, isolationScope);\n\n if (client) {\n client.emit('spanStart', rootSpan);\n }\n\n return rootSpan;\n}\n\n/**\n * Creates a new `Span` while setting the current `Span.id` as `parentSpanId`.\n * This inherits the sampling decision from the parent span.\n */\nfunction _startChildSpan(\n parentSpan: Span,\n scope: Scope,\n spanArguments: SentrySpanArguments,\n isolationScope: Scope,\n): Span {\n const { spanId, traceId } = parentSpan.spanContext();\n const _isTracingSuppressed = isTracingSuppressed(scope);\n const sampled = _isTracingSuppressed ? false : spanIsSampled(parentSpan);\n\n const childSpan = sampled\n ? new SentrySpan({\n ...spanArguments,\n parentSpanId: spanId,\n traceId,\n sampled,\n })\n : new SentryNonRecordingSpan({ traceId });\n\n addChildSpanToSpan(parentSpan, childSpan);\n\n setCapturedScopesOnSpan(childSpan, scope, isolationScope);\n\n const client = getClient();\n\n if (!client) {\n return childSpan;\n }\n\n if (hasSpanStreamingEnabled(client) && spanIsNonRecordingSpan(childSpan)) {\n if (spanIsNonRecordingSpan(parentSpan) && parentSpan.dropReason) {\n // We land here if the parent span was a segment span that was ignored (`ignoreSpans`).\n // In this case, the child was also ignored (see `sampled` above) but we need to\n // record a client outcome for the child.\n childSpan.dropReason = parentSpan.dropReason;\n client.recordDroppedEvent(parentSpan.dropReason, 'span');\n } else if (!_isTracingSuppressed) {\n // Otherwise, the child is not sampled due to sampling of the parent span,\n // hence we record a sample_rate client outcome for the child.\n childSpan.dropReason = 'sample_rate';\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n\n client.emit('spanStart', childSpan);\n // If it has an endTimestamp, it's already ended\n if (spanArguments.endTimestamp) {\n client.emit('spanEnd', childSpan);\n client.emit('afterSpanEnd', childSpan);\n }\n\n return childSpan;\n}\n\nfunction getParentSpan(scope: Scope, customParentSpan: Span | null | undefined): SentrySpan | undefined {\n // always use the passed in span directly\n if (customParentSpan) {\n return customParentSpan as SentrySpan;\n }\n\n // This is different from `undefined` as it means the user explicitly wants no parent span\n if (customParentSpan === null) {\n return undefined;\n }\n\n const span = _getSpanForScope(scope) as SentrySpan | undefined;\n\n if (!span) {\n return undefined;\n }\n\n const client = getClient();\n const options: Partial<ClientOptions> = client ? client.getOptions() : {};\n if (options.parentSpanIsAlwaysRootSpan) {\n return getRootSpan(span) as SentrySpan;\n }\n\n return span;\n}\n\nfunction getActiveSpanWrapper<T>(parentSpan: Span | undefined | null): (callback: () => T) => T {\n return parentSpan !== undefined\n ? (callback: () => T) => {\n return withActiveSpan(parentSpan, callback);\n }\n : (callback: () => T) => callback();\n}\n\n/* Checks if `ignoreSpans` applies (extracted for bundle size)*/\nfunction _shouldIgnoreStreamedSpan(client: Client | undefined, spanArguments: SentrySpanArguments): boolean {\n const ignoreSpans = client?.getOptions().ignoreSpans;\n\n if (!client || !hasSpanStreamingEnabled(client) || !ignoreSpans?.length) {\n return false;\n }\n\n return shouldIgnoreSpan(\n {\n description: spanArguments.name || '',\n op: spanArguments.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP] || spanArguments.op,\n attributes: spanArguments.attributes,\n },\n ignoreSpans,\n );\n}\n\n/**\n * Whether a span is an ignored (`ignoreSpans`) placeholder. Such a span must not be set as the active\n * span when it has a parent, so its children attach to that parent and get re-parented rather than\n * dropped with it. Shared with the OTel-based provider so both span pipelines apply the same rule.\n */\nexport function spanIsIgnored(span: Span): span is SentryNonRecordingSpan {\n return spanIsNonRecordingSpan(span) && span.dropReason === 'ignored';\n}\n"],"names":["withScope","getCurrentScope","getClient","_setSpanForScope","handleCallbackErrors","spanToJSON","SPAN_STATUS_ERROR","carrier","getMainCarrier","getAsyncContextStrategy","baggage","baggageHeaderToDynamicSamplingContext","shouldContinueTrace","propagationContextFromHeaders","generateTraceId","safeMathRandom","DEBUG_BUILD","debug","SentryNonRecordingSpan","setCapturedScopesOnSpan","getIsolationScope","hasSpansEnabled","span","addChildSpanToSpan","getDynamicSamplingContextFromSpan","spanIsSampled","freezeDscOnSpan","logSpanStart","spanTimeInputToSeconds","sampleSpan","parseSampleRate","SentrySpan","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_S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||
| const OTEL_SOURCE_EXPLICITLY_SET_SPAN_FIELD = /* @__PURE__ */ Symbol.for("sentry.otelSourceExplicitlySet"); | ||
| const TRACER_PROVIDER_SPAN_FIELD = /* @__PURE__ */ Symbol.for("sentry.tracerProviderSpan"); | ||
| function setCapturedScopesOnSpan(span, scope, isolationScope) { | ||
@@ -29,7 +31,23 @@ if (span) { | ||
| } | ||
| function markSpanSourceAsExplicit(span) { | ||
| object.addNonEnumerableProperty(span, OTEL_SOURCE_EXPLICITLY_SET_SPAN_FIELD, true); | ||
| } | ||
| function spanSourceWasExplicitlySet(span) { | ||
| return span[OTEL_SOURCE_EXPLICITLY_SET_SPAN_FIELD] === true; | ||
| } | ||
| function markSpanAsTracerProviderSpan(span) { | ||
| object.addNonEnumerableProperty(span, TRACER_PROVIDER_SPAN_FIELD, true); | ||
| } | ||
| function spanIsTracerProviderSpan(span) { | ||
| return span[TRACER_PROVIDER_SPAN_FIELD] === true; | ||
| } | ||
| exports.getCapturedScopesOnSpan = getCapturedScopesOnSpan; | ||
| exports.markSpanAsTracerProviderSpan = markSpanAsTracerProviderSpan; | ||
| exports.markSpanForOtelSourceInference = markSpanForOtelSourceInference; | ||
| exports.markSpanSourceAsExplicit = markSpanSourceAsExplicit; | ||
| exports.setCapturedScopesOnSpan = setCapturedScopesOnSpan; | ||
| exports.spanIsTracerProviderSpan = spanIsTracerProviderSpan; | ||
| exports.spanShouldInferOtelSource = spanShouldInferOtelSource; | ||
| exports.spanSourceWasExplicitlySet = spanSourceWasExplicitlySet; | ||
| //# sourceMappingURL=utils.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"utils.js","sources":["../../../src/tracing/utils.ts"],"sourcesContent":["import type { Scope } from '../scope';\nimport type { Span } from '../types/span';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { derefWeakRef, makeWeakRef, type MaybeWeakRef } from '../utils/weakRef';\n\nconst SCOPE_ON_START_SPAN_FIELD = '_sentryScope';\nconst ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';\n\n// Brand marking a span whose `sentry.source` should be inferred OTel-style at span end (by\n// `applyOtelSpanData`) rather than pinned. `SentryTraceProvider` sets it on the spans it creates\n// so they behave like OTel SDK spans, which carry no Sentry source concept. We use `Symbol.for`\n// so the key is shared across duplicated copies of `@sentry/core`.\nconst OTEL_SOURCE_INFERENCE_SPAN_FIELD = Symbol.for('sentry.otelSourceInference');\n\ntype SpanWithScopes = Span & {\n [SCOPE_ON_START_SPAN_FIELD]?: Scope;\n [ISOLATION_SCOPE_ON_START_SPAN_FIELD]?: MaybeWeakRef<Scope>;\n};\n\ntype SpanWithOtelSourceInference = Span & {\n [OTEL_SOURCE_INFERENCE_SPAN_FIELD]?: boolean;\n};\n\n/** Store the scope & isolation scope for a span, which can the be used when it is finished. */\nexport function setCapturedScopesOnSpan(span: Span | undefined, scope: Scope, isolationScope: Scope): void {\n if (span) {\n addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, makeWeakRef(isolationScope));\n // We don't wrap the scope with a WeakRef here because webkit aggressively garbage collects\n // and scopes are not held in memory for long periods of time.\n addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);\n }\n}\n\n/**\n * Grabs the scope and isolation scope off a span that were active when the span was started.\n * If WeakRef was used and scopes have been garbage collected, returns undefined for those scopes.\n */\nexport function getCapturedScopesOnSpan(span: Span): { scope?: Scope; isolationScope?: Scope } {\n const spanWithScopes = span as SpanWithScopes;\n\n return {\n scope: spanWithScopes[SCOPE_ON_START_SPAN_FIELD],\n isolationScope: derefWeakRef(spanWithScopes[ISOLATION_SCOPE_ON_START_SPAN_FIELD]),\n };\n}\n\n/**\n * Mark a span as eligible for OTel-style `sentry.source` inference at span end.\n * Set by `SentryTraceProvider` on the spans it creates; read by `SentrySpan.updateName()` and\n * `applyOtelSpanData()`.\n */\nexport function markSpanForOtelSourceInference(span: Span): void {\n addNonEnumerableProperty(span, OTEL_SOURCE_INFERENCE_SPAN_FIELD, true);\n}\n\n/** Whether a span is marked for OTel-style `sentry.source` inference (see {@link markSpanForOtelSourceInference}). */\nexport function spanShouldInferOtelSource(span: Span): boolean {\n return (span as SpanWithOtelSourceInference)[OTEL_SOURCE_INFERENCE_SPAN_FIELD] === true;\n}\n"],"names":["addNonEnumerableProperty","makeWeakRef","derefWeakRef"],"mappings":";;;;;AAKA,MAAM,yBAAA,GAA4B,cAAA;AAClC,MAAM,mCAAA,GAAsC,uBAAA;AAM5C,MAAM,gCAAA,mBAAmC,MAAA,CAAO,GAAA,CAAI,4BAA4B,CAAA;AAYzE,SAAS,uBAAA,CAAwB,IAAA,EAAwB,KAAA,EAAc,cAAA,EAA6B;AACzG,EAAA,IAAI,IAAA,EAAM;AACR,IAAAA,+BAAA,CAAyB,IAAA,EAAM,mCAAA,EAAqCC,mBAAA,CAAY,cAAc,CAAC,CAAA;AAG/F,IAAAD,+BAAA,CAAyB,IAAA,EAAM,2BAA2B,KAAK,CAAA;AAAA,EACjE;AACF;AAMO,SAAS,wBAAwB,IAAA,EAAuD;AAC7F,EAAA,MAAM,cAAA,GAAiB,IAAA;AAEvB,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,eAAe,yBAAyB,CAAA;AAAA,IAC/C,cAAA,EAAgBE,oBAAA,CAAa,cAAA,CAAe,mCAAmC,CAAC;AAAA,GAClF;AACF;AAOO,SAAS,+BAA+B,IAAA,EAAkB;AAC/D,EAAAF,+BAAA,CAAyB,IAAA,EAAM,kCAAkC,IAAI,CAAA;AACvE;AAGO,SAAS,0BAA0B,IAAA,EAAqB;AAC7D,EAAA,OAAQ,IAAA,CAAqC,gCAAgC,CAAA,KAAM,IAAA;AACrF;;;;;;;"} | ||
| {"version":3,"file":"utils.js","sources":["../../../src/tracing/utils.ts"],"sourcesContent":["import type { Scope } from '../scope';\nimport type { Span } from '../types/span';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { derefWeakRef, makeWeakRef, type MaybeWeakRef } from '../utils/weakRef';\n\nconst SCOPE_ON_START_SPAN_FIELD = '_sentryScope';\nconst ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';\n\n// Brand marking a span whose `sentry.source` should be inferred OTel-style at span end (by\n// `applyOtelSpanData`) rather than pinned. `SentryTraceProvider` sets it on the spans it creates\n// so they behave like OTel SDK spans, which carry no Sentry source concept. We use `Symbol.for`\n// so the key is shared across duplicated copies of `@sentry/core`.\nconst OTEL_SOURCE_INFERENCE_SPAN_FIELD = Symbol.for('sentry.otelSourceInference');\n\n// Brand marking a span (otherwise subject to OTel-style source inference, see above) whose\n// `sentry.source` was explicitly set by user code after creation, so `applyOtelSpanData` stops\n// inferring and respects the chosen source and name. This is what tells a user-set `custom` source\n// apart from the default `custom` that `_startRootSpan` stamps on every root span.\nconst OTEL_SOURCE_EXPLICITLY_SET_SPAN_FIELD = Symbol.for('sentry.otelSourceExplicitlySet');\n\n// Brand marking a span created by the `SentryTracerProvider` (i.e. via the OTel tracer) rather than\n// directly through the core span API. Such a span is handed to OTel instrumentations as an OTel span,\n// so it must become immutable after `end()` like a real OTel SDK span (see `SentrySpan.end()`). Spans\n// created directly through core (e.g. the browser SDK) are not branded and stay mutable.\nconst TRACER_PROVIDER_SPAN_FIELD = Symbol.for('sentry.tracerProviderSpan');\n\ntype SpanWithScopes = Span & {\n [SCOPE_ON_START_SPAN_FIELD]?: Scope;\n [ISOLATION_SCOPE_ON_START_SPAN_FIELD]?: MaybeWeakRef<Scope>;\n};\n\ntype SpanWithOtelSourceInference = Span & {\n [OTEL_SOURCE_INFERENCE_SPAN_FIELD]?: boolean;\n [OTEL_SOURCE_EXPLICITLY_SET_SPAN_FIELD]?: boolean;\n};\n\ntype SpanWithTracerProviderBrand = Span & {\n [TRACER_PROVIDER_SPAN_FIELD]?: boolean;\n};\n\n/** Store the scope & isolation scope for a span, which can the be used when it is finished. */\nexport function setCapturedScopesOnSpan(span: Span | undefined, scope: Scope, isolationScope: Scope): void {\n if (span) {\n addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, makeWeakRef(isolationScope));\n // We don't wrap the scope with a WeakRef here because webkit aggressively garbage collects\n // and scopes are not held in memory for long periods of time.\n addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);\n }\n}\n\n/**\n * Grabs the scope and isolation scope off a span that were active when the span was started.\n * If WeakRef was used and scopes have been garbage collected, returns undefined for those scopes.\n */\nexport function getCapturedScopesOnSpan(span: Span): { scope?: Scope; isolationScope?: Scope } {\n const spanWithScopes = span as SpanWithScopes;\n\n return {\n scope: spanWithScopes[SCOPE_ON_START_SPAN_FIELD],\n isolationScope: derefWeakRef(spanWithScopes[ISOLATION_SCOPE_ON_START_SPAN_FIELD]),\n };\n}\n\n/**\n * Mark a span as eligible for OTel-style `sentry.source` inference at span end.\n * Set by `SentryTraceProvider` on the spans it creates; read by `SentrySpan.updateName()` and\n * `applyOtelSpanData()`.\n */\nexport function markSpanForOtelSourceInference(span: Span): void {\n addNonEnumerableProperty(span, OTEL_SOURCE_INFERENCE_SPAN_FIELD, true);\n}\n\n/** Whether a span is marked for OTel-style `sentry.source` inference (see {@link markSpanForOtelSourceInference}). */\nexport function spanShouldInferOtelSource(span: Span): boolean {\n return (span as SpanWithOtelSourceInference)[OTEL_SOURCE_INFERENCE_SPAN_FIELD] === true;\n}\n\n/**\n * Mark that user code explicitly set `sentry.source` on a span subject to OTel-style inference, so\n * `applyOtelSpanData` keeps that source (and name) instead of overriding it. Set by `SentrySpan`\n * when `setAttribute` writes the source on an already-branded span (the default `custom` source is\n * stamped at construction, before the brand, so it doesn't trip this).\n */\nexport function markSpanSourceAsExplicit(span: Span): void {\n addNonEnumerableProperty(span, OTEL_SOURCE_EXPLICITLY_SET_SPAN_FIELD, true);\n}\n\n/** Whether user code explicitly set `sentry.source` on a span (see {@link markSpanSourceAsExplicit}). */\nexport function spanSourceWasExplicitlySet(span: Span): boolean {\n return (span as SpanWithOtelSourceInference)[OTEL_SOURCE_EXPLICITLY_SET_SPAN_FIELD] === true;\n}\n\n/**\n * Mark a span as created by the `SentryTracerProvider` (via the OTel tracer). Set by `SentryTracer`\n * on every span it creates; read by `SentrySpan.end()` to seal the span against further writes once\n * it has ended, mirroring OTel SDK spans (which are immutable after `end()`).\n */\nexport function markSpanAsTracerProviderSpan(span: Span): void {\n addNonEnumerableProperty(span, TRACER_PROVIDER_SPAN_FIELD, true);\n}\n\n/** Whether a span was created by the `SentryTracerProvider` (see {@link markSpanAsTracerProviderSpan}). */\nexport function spanIsTracerProviderSpan(span: Span): boolean {\n return (span as SpanWithTracerProviderBrand)[TRACER_PROVIDER_SPAN_FIELD] === true;\n}\n"],"names":["addNonEnumerableProperty","makeWeakRef","derefWeakRef"],"mappings":";;;;;AAKA,MAAM,yBAAA,GAA4B,cAAA;AAClC,MAAM,mCAAA,GAAsC,uBAAA;AAM5C,MAAM,gCAAA,mBAAmC,MAAA,CAAO,GAAA,CAAI,4BAA4B,CAAA;AAMhF,MAAM,qCAAA,mBAAwC,MAAA,CAAO,GAAA,CAAI,gCAAgC,CAAA;AAMzF,MAAM,0BAAA,mBAA6B,MAAA,CAAO,GAAA,CAAI,2BAA2B,CAAA;AAiBlE,SAAS,uBAAA,CAAwB,IAAA,EAAwB,KAAA,EAAc,cAAA,EAA6B;AACzG,EAAA,IAAI,IAAA,EAAM;AACR,IAAAA,+BAAA,CAAyB,IAAA,EAAM,mCAAA,EAAqCC,mBAAA,CAAY,cAAc,CAAC,CAAA;AAG/F,IAAAD,+BAAA,CAAyB,IAAA,EAAM,2BAA2B,KAAK,CAAA;AAAA,EACjE;AACF;AAMO,SAAS,wBAAwB,IAAA,EAAuD;AAC7F,EAAA,MAAM,cAAA,GAAiB,IAAA;AAEvB,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,eAAe,yBAAyB,CAAA;AAAA,IAC/C,cAAA,EAAgBE,oBAAA,CAAa,cAAA,CAAe,mCAAmC,CAAC;AAAA,GAClF;AACF;AAOO,SAAS,+BAA+B,IAAA,EAAkB;AAC/D,EAAAF,+BAAA,CAAyB,IAAA,EAAM,kCAAkC,IAAI,CAAA;AACvE;AAGO,SAAS,0BAA0B,IAAA,EAAqB;AAC7D,EAAA,OAAQ,IAAA,CAAqC,gCAAgC,CAAA,KAAM,IAAA;AACrF;AAQO,SAAS,yBAAyB,IAAA,EAAkB;AACzD,EAAAA,+BAAA,CAAyB,IAAA,EAAM,uCAAuC,IAAI,CAAA;AAC5E;AAGO,SAAS,2BAA2B,IAAA,EAAqB;AAC9D,EAAA,OAAQ,IAAA,CAAqC,qCAAqC,CAAA,KAAM,IAAA;AAC1F;AAOO,SAAS,6BAA6B,IAAA,EAAkB;AAC7D,EAAAA,+BAAA,CAAyB,IAAA,EAAM,4BAA4B,IAAI,CAAA;AACjE;AAGO,SAAS,yBAAyB,IAAA,EAAqB;AAC5D,EAAA,OAAQ,IAAA,CAAqC,0BAA0B,CAAA,KAAM,IAAA;AAC/E;;;;;;;;;;;"} |
@@ -6,3 +6,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| function getTraceMetaTags(traceData$1) { | ||
| return Object.entries(traceData$1 || traceData.getTraceData()).map(([key, value]) => `<meta name="${key}" content="${value}"/>`).join("\n"); | ||
| return Object.entries(traceData$1 || traceData.getTraceData()).map(([key, value]) => `<meta name="${key}" content="${value}"/>`).join(""); | ||
| } | ||
@@ -9,0 +9,0 @@ |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"meta.js","sources":["../../../src/utils/meta.ts"],"sourcesContent":["import type { SerializedTraceData } from '../types/tracing';\nimport { getTraceData } from './traceData';\n\n/**\n * Returns a string of meta tags that represent the current trace data.\n *\n * You can use this to propagate a trace from your server-side rendered Html to the browser.\n * This function returns up to two meta tags, `sentry-trace` and `baggage`, depending on the\n * current trace data state.\n *\n * @example\n * Usage example:\n *\n * ```js\n * function renderHtml() {\n * return `\n * <head>\n * ${getTraceMetaTags()}\n * </head>\n * `;\n * }\n * ```\n *\n */\nexport function getTraceMetaTags(traceData?: SerializedTraceData): string {\n return Object.entries(traceData || getTraceData())\n .map(([key, value]) => `<meta name=\"${key}\" content=\"${value}\"/>`)\n .join('\\n');\n}\n"],"names":["traceData","getTraceData"],"mappings":";;;;AAwBO,SAAS,iBAAiBA,WAAA,EAAyC;AACxE,EAAA,OAAO,OAAO,OAAA,CAAQA,WAAA,IAAaC,wBAAc,CAAA,CAC9C,IAAI,CAAC,CAAC,KAAK,KAAK,CAAA,KAAM,eAAe,GAAG,CAAA,WAAA,EAAc,KAAK,CAAA,GAAA,CAAK,CAAA,CAChE,KAAK,IAAI,CAAA;AACd;;;;"} | ||
| {"version":3,"file":"meta.js","sources":["../../../src/utils/meta.ts"],"sourcesContent":["import type { SerializedTraceData } from '../types/tracing';\nimport { getTraceData } from './traceData';\n\n/**\n * Returns a string of meta tags that represent the current trace data.\n *\n * You can use this to propagate a trace from your server-side rendered Html to the browser.\n * This function returns up to two meta tags, `sentry-trace` and `baggage`, depending on the\n * current trace data state.\n *\n * @example\n * Usage example:\n *\n * ```js\n * function renderHtml() {\n * return `\n * <head>\n * ${getTraceMetaTags()}\n * </head>\n * `;\n * }\n * ```\n *\n */\nexport function getTraceMetaTags(traceData?: SerializedTraceData): string {\n return (\n Object.entries(traceData || getTraceData())\n .map(([key, value]) => `<meta name=\"${key}\" content=\"${value}\"/>`)\n // Joined without whitespace on purpose: a separator between the tags becomes a text node when\n // injected into `<head>`, which breaks React 19 whole-document hydration (#21915).\n .join('')\n );\n}\n"],"names":["traceData","getTraceData"],"mappings":";;;;AAwBO,SAAS,iBAAiBA,WAAA,EAAyC;AACxE,EAAA,OACE,OAAO,OAAA,CAAQA,WAAA,IAAaC,wBAAc,CAAA,CACvC,IAAI,CAAC,CAAC,KAAK,KAAK,CAAA,KAAM,eAAe,GAAG,CAAA,WAAA,EAAc,KAAK,CAAA,GAAA,CAAK,CAAA,CAGhE,KAAK,EAAE,CAAA;AAEd;;;;"} |
@@ -275,2 +275,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| exports.spanIsSampled = spanIsSampled; | ||
| exports.spanIsSentrySpan = spanIsSentrySpan; | ||
| exports.spanTimeInputToSeconds = spanTimeInputToSeconds; | ||
@@ -277,0 +278,0 @@ exports.spanToJSON = spanToJSON; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"spanUtils.js","sources":["../../../src/utils/spanUtils.ts"],"sourcesContent":["// oxlint-disable max-lines\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { RawAttributes } from '../attributes';\nimport { serializeAttributes } from '../attributes';\nimport { getMainCarrier } from '../carrier';\nimport { getCurrentScope } from '../currentScopes';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE,\n} from '../semanticAttributes';\nimport type { SentrySpan } from '../tracing/sentrySpan';\nimport { SPAN_STATUS_OK, SPAN_STATUS_UNSET } from '../tracing/spanstatus';\nimport { getCapturedScopesOnSpan } from '../tracing/utils';\nimport type { TraceContext } from '../types/context';\nimport type { SpanLink, SpanLinkJSON } from '../types/link';\nimport type {\n SerializedStreamedSpan,\n Span,\n SpanAttributes,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types/span';\nimport type { SpanStatus } from '../types/spanStatus';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { generateSpanId } from '../utils/propagationContext';\nimport { timestampInSeconds } from '../utils/time';\nimport { generateSentryTraceHeader, generateTraceparentHeader } from '../utils/tracing';\nimport { consoleSandbox } from './debug-logger';\nimport { _getSpanForScope } from './spanOnScope';\n\n// These are aligned with OpenTelemetry trace flags\nexport const TRACE_FLAG_NONE = 0x0;\nexport const TRACE_FLAG_SAMPLED = 0x1;\n\nlet hasShownSpanDropWarning = false;\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in an event.\n * By default, this will only include trace_id, span_id & parent_span_id.\n * If `includeAllData` is true, it will also include data, op, status & origin.\n */\nexport function spanToTransactionTraceContext(span: Span): TraceContext {\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n const { data, op, parent_span_id, status, origin, links } = spanToJSON(span);\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n data,\n op,\n status,\n origin,\n links,\n };\n}\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in a non-transaction event.\n */\nexport function spanToTraceContext(span: Span): TraceContext {\n const { spanId, traceId: trace_id, isRemote } = span.spanContext();\n\n // If the span is remote, we use a random/virtual span as span_id to the trace context,\n // and the remote span as parent_span_id\n const parent_span_id = isRemote ? spanId : spanToJSON(span).parent_span_id;\n const scope = getCapturedScopesOnSpan(span).scope;\n\n const span_id = isRemote ? scope?.getPropagationContext().propagationSpanId || generateSpanId() : spanId;\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n };\n}\n\n/**\n * Convert a Span to a Sentry trace header.\n */\nexport function spanToTraceHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateSentryTraceHeader(traceId, spanId, sampled);\n}\n\n/**\n * Convert a Span to a W3C traceparent header.\n */\nexport function spanToTraceparentHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateTraceparentHeader(traceId, spanId, sampled);\n}\n\n/**\n * Converts the span links array to a flattened version to be sent within an envelope.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function convertSpanLinksForEnvelope(links?: SpanLink[]): SpanLinkJSON[] | undefined {\n if (links && links.length > 0) {\n return links.map(({ context: { spanId, traceId, traceFlags, ...restContext }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n ...restContext,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Converts the span links array to a flattened version with serialized attributes for V2 spans.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function getStreamedSpanLinks(\n links?: SpanLink[],\n): SpanLinkJSON<RawAttributes<Record<string, unknown>>>[] | undefined {\n if (links?.length) {\n return links.map(({ context: { spanId, traceId, traceFlags }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Convert a span time input into a timestamp in seconds.\n */\nexport function spanTimeInputToSeconds(input: SpanTimeInput | undefined): number {\n if (typeof input === 'number') {\n return ensureTimestampInSeconds(input);\n }\n\n if (Array.isArray(input)) {\n // See {@link HrTime} for the array-based time format\n return input[0] + input[1] / 1e9;\n }\n\n if (input instanceof Date) {\n return ensureTimestampInSeconds(input.getTime());\n }\n\n return timestampInSeconds();\n}\n\n/**\n * Converts a timestamp to second, if it was in milliseconds, or keeps it as second.\n */\nfunction ensureTimestampInSeconds(timestamp: number): number {\n const isMs = timestamp > 9999999999;\n return isMs ? timestamp / 1000 : timestamp;\n}\n\n/**\n * Convert a span to a JSON representation.\n */\n// Note: Because of this, we currently have a circular type dependency (which we opted out of in package.json).\n// This is not avoidable as we need `spanToJSON` in `spanUtils.ts`, which in turn is needed by `span.ts` for backwards compatibility.\n// And `spanToJSON` needs the Span class from `span.ts` to check here.\nexport function spanToJSON(span: Span): SpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n span_id,\n trace_id,\n data: attributes,\n description: name,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n // This is [0,0] by default in OTEL, in which case we want to interpret this as no end time\n timestamp: spanTimeInputToSeconds(endTime) || undefined,\n status: getStatusMessage(status),\n op: attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n origin: attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n links: convertSpanLinksForEnvelope(links),\n };\n }\n\n // Finally, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n data: {},\n };\n}\n\n/**\n * Convert a span to the intermediate {@link StreamedSpanJSON} representation.\n */\nexport function spanToStreamedSpanJSON(span: Span): StreamedSpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getStreamedSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n name,\n span_id,\n trace_id,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n end_timestamp: spanTimeInputToSeconds(endTime),\n is_segment: span === INTERNAL_getSegmentSpan(span),\n status: getSimpleStatus(status),\n attributes: addStatusMessageAttribute(attributes, status),\n links: getStreamedSpanLinks(links),\n };\n }\n\n // Finally, as a fallback, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n name: '',\n end_timestamp: 0,\n status: 'ok',\n is_segment: span === INTERNAL_getSegmentSpan(span),\n };\n}\n\n/**\n * In preparation for the next major of OpenTelemetry, we want to support\n * looking up the parent span id according to the new API\n * In OTel v1, the parent span id is accessed as `parentSpanId`\n * In OTel v2, the parent span id is accessed as `spanId` on the `parentSpanContext`\n */\nfunction getOtelParentSpanId(span: OpenTelemetrySdkTraceBaseSpan): string | undefined {\n return 'parentSpanId' in span\n ? span.parentSpanId\n : 'parentSpanContext' in span\n ? (span.parentSpanContext as { spanId?: string } | undefined)?.spanId\n : undefined;\n}\n\n/**\n * Converts a {@link StreamedSpanJSON} to a {@link SerializedSpan}.\n * This is the final serialized span format that is sent to Sentry.\n * The returned serilaized spans must not be consumed by users or SDK integrations.\n */\nexport function streamedSpanJsonToSerializedSpan(spanJson: StreamedSpanJSON): SerializedStreamedSpan {\n return {\n ...spanJson,\n attributes: serializeAttributes(spanJson.attributes),\n links: spanJson.links?.map(link => ({\n ...link,\n attributes: serializeAttributes(link.attributes),\n })),\n };\n}\n\nfunction spanIsOpenTelemetrySdkTraceBaseSpan(span: Span): span is OpenTelemetrySdkTraceBaseSpan {\n const castSpan = span as Partial<OpenTelemetrySdkTraceBaseSpan>;\n return !!castSpan.attributes && !!castSpan.startTime && !!castSpan.name && !!castSpan.endTime && !!castSpan.status;\n}\n\n/** Exported only for tests. */\nexport interface OpenTelemetrySdkTraceBaseSpan extends Span {\n attributes: SpanAttributes;\n startTime: SpanTimeInput;\n name: string;\n status: SpanStatus;\n endTime: SpanTimeInput;\n parentSpanId?: string;\n links?: SpanLink[];\n}\n\n/**\n * Sadly, due to circular dependency checks we cannot actually import the Span class here and check for instanceof.\n * :( So instead we approximate this by checking if it has the `getSpanJSON` method.\n */\nfunction spanIsSentrySpan(span: Span): span is SentrySpan {\n return typeof (span as SentrySpan).getSpanJSON === 'function';\n}\n\n/**\n * Returns true if a span is sampled.\n * In most cases, you should just use `span.isRecording()` instead.\n * However, this has a slightly different semantic, as it also returns false if the span is finished.\n * So in the case where this distinction is important, use this method.\n */\nexport function spanIsSampled(span: Span): boolean {\n // We align our trace flags with the ones OpenTelemetry use\n // So we also check for sampled the same way they do.\n const { traceFlags } = span.spanContext();\n return traceFlags === TRACE_FLAG_SAMPLED;\n}\n\n/** Get the status message to use for a JSON representation of a span. */\nexport function getStatusMessage(status: SpanStatus | undefined): string | undefined {\n if (!status || status.code === SPAN_STATUS_UNSET) {\n return undefined;\n }\n\n if (status.code === SPAN_STATUS_OK) {\n return 'ok';\n }\n\n return status.message || 'internal_error';\n}\n\n/**\n * Convert the various statuses to the simple ones expected by Sentry for streamed spans ('ok' is default).\n */\nexport function getSimpleStatus(status: SpanStatus | undefined): 'ok' | 'error' {\n return !status ||\n status.code === SPAN_STATUS_OK ||\n status.code === SPAN_STATUS_UNSET ||\n status.message === 'cancelled'\n ? 'ok'\n : 'error';\n}\n\n/**\n * Returns the span's attributes with the SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE attribute added\n * if the span has an error status message worth preserving.\n *\n * An explicitly set attribute is never overwritten.\n */\nexport function addStatusMessageAttribute(\n attributes: SpanAttributes,\n status: SpanStatus | undefined,\n): RawAttributes<Record<string, unknown>> {\n const statusMessage = getSimpleStatus(status) === 'error' ? status?.message : undefined;\n return {\n ...(statusMessage && { [SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE]: statusMessage }),\n ...attributes,\n };\n}\n\nconst CHILD_SPANS_FIELD = '_sentryChildSpans';\nconst ROOT_SPAN_FIELD = '_sentryRootSpan';\n\ntype SpanWithPotentialChildren = Span & {\n [CHILD_SPANS_FIELD]?: Set<Span>;\n [ROOT_SPAN_FIELD]?: Span;\n};\n\n/**\n * Adds an opaque child span reference to a span.\n */\nexport function addChildSpanToSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n // We store the root span reference on the child span\n // We need this for `getRootSpan()` to work\n const rootSpan = span[ROOT_SPAN_FIELD] || span;\n addNonEnumerableProperty(childSpan as SpanWithPotentialChildren, ROOT_SPAN_FIELD, rootSpan);\n\n // We store a list of child spans on the parent span\n // We need this for `getSpanDescendants()` to work\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].add(childSpan);\n } else {\n addNonEnumerableProperty(span, CHILD_SPANS_FIELD, new Set([childSpan]));\n }\n}\n\n/** This is only used internally by Idle Spans. */\nexport function removeChildSpanFromSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].delete(childSpan);\n }\n}\n\n/**\n * Returns an array of the given span and all of its descendants.\n */\nexport function getSpanDescendants(span: SpanWithPotentialChildren): Span[] {\n const resultSet = new Set<Span>();\n\n function addSpanChildren(span: SpanWithPotentialChildren): void {\n // This exit condition is required to not infinitely loop in case of a circular dependency.\n if (resultSet.has(span)) {\n return;\n // We want to ignore unsampled spans (e.g. non recording spans)\n } else if (spanIsSampled(span)) {\n resultSet.add(span);\n const childSpans = span[CHILD_SPANS_FIELD] ? Array.from(span[CHILD_SPANS_FIELD]) : [];\n for (const childSpan of childSpans) {\n addSpanChildren(childSpan);\n }\n }\n }\n\n addSpanChildren(span);\n\n return Array.from(resultSet);\n}\n\n/**\n * Returns the root span of a given span.\n */\nexport const getRootSpan = INTERNAL_getSegmentSpan;\n\n/**\n * Returns the segment span of a given span.\n */\nexport function INTERNAL_getSegmentSpan(span: SpanWithPotentialChildren): Span {\n return span[ROOT_SPAN_FIELD] || span;\n}\n\n/**\n * Returns the currently active span.\n */\nexport function getActiveSpan(): Span | undefined {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.getActiveSpan) {\n return acs.getActiveSpan();\n }\n\n return _getSpanForScope(getCurrentScope());\n}\n\n/**\n * Logs a warning once if `beforeSendSpan` is used to drop spans.\n */\nexport function showSpanDropWarning(): void {\n if (!hasShownSpanDropWarning) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.',\n );\n });\n hasShownSpanDropWarning = true;\n }\n}\n\n/**\n * Updates the name of the given span and ensures that the span name is not\n * overwritten by the Sentry SDK.\n *\n * Use this function instead of `span.updateName()` if you want to make sure that\n * your name is kept. For some spans, for example root `http.server` spans the\n * Sentry SDK would otherwise overwrite the span name with a high-quality name\n * it infers when the span ends.\n *\n * Use this function in server code or when your span is started on the server\n * and on the client (browser). If you only update a span name on the client,\n * you can also use `span.updateName()` the SDK does not overwrite the name.\n *\n * @param span - The span to update the name of.\n * @param name - The name to set on the span.\n */\nexport function updateSpanName(span: Span, name: string): void {\n span.updateName(name);\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]: name,\n });\n}\n"],"names":["getCapturedScopesOnSpan","generateSpanId","generateSentryTraceHeader","generateTraceparentHeader","timestampInSeconds","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","serializeAttributes","SPAN_STATUS_UNSET","SPAN_STATUS_OK","SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE","addNonEnumerableProperty","span","carrier","getMainCarrier","getAsyncContextStrategy","_getSpanForScope","getCurrentScope","consoleSandbox","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME"],"mappings":";;;;;;;;;;;;;;;;AAoCO,MAAM,eAAA,GAAkB;AACxB,MAAM,kBAAA,GAAqB;AAElC,IAAI,uBAAA,GAA0B,KAAA;AAOvB,SAAS,8BAA8B,IAAA,EAA0B;AACtE,EAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAS,SAAS,QAAA,EAAS,GAAI,KAAK,WAAA,EAAY;AAChE,EAAA,MAAM,EAAE,MAAM,EAAA,EAAI,cAAA,EAAgB,QAAQ,MAAA,EAAQ,KAAA,EAAM,GAAI,UAAA,CAAW,IAAI,CAAA;AAE3E,EAAA,OAAO;AAAA,IACL,cAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,EAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF;AAKO,SAAS,mBAAmB,IAAA,EAA0B;AAC3D,EAAA,MAAM,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AM,WAAA,GAAc;AAKpB,SAAS,wBAAwB,IAAA,EAAuC;AAC7E,EAAA,OAAO,IAAA,CAAK,eAAe,CAAA,IAAK,IAAA;AAClC;AAKO,SAAS,aAAA,GAAkC;AAChD,EAAA,MAAMC,YAAUC,sBAAA,EAAe;AAC/B,EAAA,MAAM,GAAA,GAAMC,8BAAwBF,SAAO,CAAA;AAC3C,EAAA,IAAI,IAAI,aAAA,EAAe;AACrB,IAAA,OAAO,IAAI,aAAA,EAAc;AAAA,EAC3B;AAEA,EAAA,OAAOG,4BAAA,CAAiBC,+BAAiB,CAAA;AAC3C;AAKO,SAAS,mBAAA,GAA4B;AAC1C,EAAA,IAAI,CAAC,uBAAA,EAAyB;AAC5B,IAAAC,0BAAA,CAAe,MAAM;AAEnB,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN;AAAA,OACF;AAAA,IACF,CAAC,CAAA;AACD,IAAA,uBAAA,GAA0B,IAAA;AAAA,EAC5B;AACF;AAkBO,SAAS,cAAA,CAAe,MAAY,IAAA,EAAoB;AAC7D,EAAA,IAAA,CAAK,WAAW,IAAI,CAAA;AACpB,EAAA,IAAA,CAAK,aAAA,CAAc;AAAA,IACjB,CAACC,mDAAgC,GAAG,QAAA;AAAA,IACpC,CAACC,6DAA0C,GAAG;AAAA,GAC/C,CAAA;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"spanUtils.js","sources":["../../../src/utils/spanUtils.ts"],"sourcesContent":["// oxlint-disable max-lines\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { RawAttributes } from '../attributes';\nimport { serializeAttributes } from '../attributes';\nimport { getMainCarrier } from '../carrier';\nimport { getCurrentScope } from '../currentScopes';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE,\n} from '../semanticAttributes';\nimport type { SentrySpan } from '../tracing/sentrySpan';\nimport { SPAN_STATUS_OK, SPAN_STATUS_UNSET } from '../tracing/spanstatus';\nimport { getCapturedScopesOnSpan } from '../tracing/utils';\nimport type { TraceContext } from '../types/context';\nimport type { SpanLink, SpanLinkJSON } from '../types/link';\nimport type {\n SerializedStreamedSpan,\n Span,\n SpanAttributes,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types/span';\nimport type { SpanStatus } from '../types/spanStatus';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { generateSpanId } from '../utils/propagationContext';\nimport { timestampInSeconds } from '../utils/time';\nimport { generateSentryTraceHeader, generateTraceparentHeader } from '../utils/tracing';\nimport { consoleSandbox } from './debug-logger';\nimport { _getSpanForScope } from './spanOnScope';\n\n// These are aligned with OpenTelemetry trace flags\nexport const TRACE_FLAG_NONE = 0x0;\nexport const TRACE_FLAG_SAMPLED = 0x1;\n\nlet hasShownSpanDropWarning = false;\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in an event.\n * By default, this will only include trace_id, span_id & parent_span_id.\n * If `includeAllData` is true, it will also include data, op, status & origin.\n */\nexport function spanToTransactionTraceContext(span: Span): TraceContext {\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n const { data, op, parent_span_id, status, origin, links } = spanToJSON(span);\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n data,\n op,\n status,\n origin,\n links,\n };\n}\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in a non-transaction event.\n */\nexport function spanToTraceContext(span: Span): TraceContext {\n const { spanId, traceId: trace_id, isRemote } = span.spanContext();\n\n // If the span is remote, we use a random/virtual span as span_id to the trace context,\n // and the remote span as parent_span_id\n const parent_span_id = isRemote ? spanId : spanToJSON(span).parent_span_id;\n const scope = getCapturedScopesOnSpan(span).scope;\n\n const span_id = isRemote ? scope?.getPropagationContext().propagationSpanId || generateSpanId() : spanId;\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n };\n}\n\n/**\n * Convert a Span to a Sentry trace header.\n */\nexport function spanToTraceHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateSentryTraceHeader(traceId, spanId, sampled);\n}\n\n/**\n * Convert a Span to a W3C traceparent header.\n */\nexport function spanToTraceparentHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateTraceparentHeader(traceId, spanId, sampled);\n}\n\n/**\n * Converts the span links array to a flattened version to be sent within an envelope.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function convertSpanLinksForEnvelope(links?: SpanLink[]): SpanLinkJSON[] | undefined {\n if (links && links.length > 0) {\n return links.map(({ context: { spanId, traceId, traceFlags, ...restContext }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n ...restContext,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Converts the span links array to a flattened version with serialized attributes for V2 spans.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function getStreamedSpanLinks(\n links?: SpanLink[],\n): SpanLinkJSON<RawAttributes<Record<string, unknown>>>[] | undefined {\n if (links?.length) {\n return links.map(({ context: { spanId, traceId, traceFlags }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Convert a span time input into a timestamp in seconds.\n */\nexport function spanTimeInputToSeconds(input: SpanTimeInput | undefined): number {\n if (typeof input === 'number') {\n return ensureTimestampInSeconds(input);\n }\n\n if (Array.isArray(input)) {\n // See {@link HrTime} for the array-based time format\n return input[0] + input[1] / 1e9;\n }\n\n if (input instanceof Date) {\n return ensureTimestampInSeconds(input.getTime());\n }\n\n return timestampInSeconds();\n}\n\n/**\n * Converts a timestamp to second, if it was in milliseconds, or keeps it as second.\n */\nfunction ensureTimestampInSeconds(timestamp: number): number {\n const isMs = timestamp > 9999999999;\n return isMs ? timestamp / 1000 : timestamp;\n}\n\n/**\n * Convert a span to a JSON representation.\n */\n// Note: Because of this, we currently have a circular type dependency (which we opted out of in package.json).\n// This is not avoidable as we need `spanToJSON` in `spanUtils.ts`, which in turn is needed by `span.ts` for backwards compatibility.\n// And `spanToJSON` needs the Span class from `span.ts` to check here.\nexport function spanToJSON(span: Span): SpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n span_id,\n trace_id,\n data: attributes,\n description: name,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n // This is [0,0] by default in OTEL, in which case we want to interpret this as no end time\n timestamp: spanTimeInputToSeconds(endTime) || undefined,\n status: getStatusMessage(status),\n op: attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n origin: attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n links: convertSpanLinksForEnvelope(links),\n };\n }\n\n // Finally, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n data: {},\n };\n}\n\n/**\n * Convert a span to the intermediate {@link StreamedSpanJSON} representation.\n */\nexport function spanToStreamedSpanJSON(span: Span): StreamedSpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getStreamedSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n name,\n span_id,\n trace_id,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n end_timestamp: spanTimeInputToSeconds(endTime),\n is_segment: span === INTERNAL_getSegmentSpan(span),\n status: getSimpleStatus(status),\n attributes: addStatusMessageAttribute(attributes, status),\n links: getStreamedSpanLinks(links),\n };\n }\n\n // Finally, as a fallback, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n name: '',\n end_timestamp: 0,\n status: 'ok',\n is_segment: span === INTERNAL_getSegmentSpan(span),\n };\n}\n\n/**\n * In preparation for the next major of OpenTelemetry, we want to support\n * looking up the parent span id according to the new API\n * In OTel v1, the parent span id is accessed as `parentSpanId`\n * In OTel v2, the parent span id is accessed as `spanId` on the `parentSpanContext`\n */\nfunction getOtelParentSpanId(span: OpenTelemetrySdkTraceBaseSpan): string | undefined {\n return 'parentSpanId' in span\n ? span.parentSpanId\n : 'parentSpanContext' in span\n ? (span.parentSpanContext as { spanId?: string } | undefined)?.spanId\n : undefined;\n}\n\n/**\n * Converts a {@link StreamedSpanJSON} to a {@link SerializedSpan}.\n * This is the final serialized span format that is sent to Sentry.\n * The returned serilaized spans must not be consumed by users or SDK integrations.\n */\nexport function streamedSpanJsonToSerializedSpan(spanJson: StreamedSpanJSON): SerializedStreamedSpan {\n return {\n ...spanJson,\n attributes: serializeAttributes(spanJson.attributes),\n links: spanJson.links?.map(link => ({\n ...link,\n attributes: serializeAttributes(link.attributes),\n })),\n };\n}\n\nfunction spanIsOpenTelemetrySdkTraceBaseSpan(span: Span): span is OpenTelemetrySdkTraceBaseSpan {\n const castSpan = span as Partial<OpenTelemetrySdkTraceBaseSpan>;\n return !!castSpan.attributes && !!castSpan.startTime && !!castSpan.name && !!castSpan.endTime && !!castSpan.status;\n}\n\n/** Exported only for tests. */\nexport interface OpenTelemetrySdkTraceBaseSpan extends Span {\n attributes: SpanAttributes;\n startTime: SpanTimeInput;\n name: string;\n status: SpanStatus;\n endTime: SpanTimeInput;\n parentSpanId?: string;\n links?: SpanLink[];\n}\n\n/**\n * Sadly, due to circular dependency checks we cannot actually import the Span class here and check for instanceof.\n * :( So instead we approximate this by checking if it has the `getSpanJSON` method.\n */\nexport function spanIsSentrySpan(span: Span): span is SentrySpan {\n return typeof (span as SentrySpan).getSpanJSON === 'function';\n}\n\n/**\n * Returns true if a span is sampled.\n * In most cases, you should just use `span.isRecording()` instead.\n * However, this has a slightly different semantic, as it also returns false if the span is finished.\n * So in the case where this distinction is important, use this method.\n */\nexport function spanIsSampled(span: Span): boolean {\n // We align our trace flags with the ones OpenTelemetry use\n // So we also check for sampled the same way they do.\n const { traceFlags } = span.spanContext();\n return traceFlags === TRACE_FLAG_SAMPLED;\n}\n\n/** Get the status message to use for a JSON representation of a span. */\nexport function getStatusMessage(status: SpanStatus | undefined): string | undefined {\n if (!status || status.code === SPAN_STATUS_UNSET) {\n return undefined;\n }\n\n if (status.code === SPAN_STATUS_OK) {\n return 'ok';\n }\n\n return status.message || 'internal_error';\n}\n\n/**\n * Convert the various statuses to the simple ones expected by Sentry for streamed spans ('ok' is default).\n */\nexport function getSimpleStatus(status: SpanStatus | undefined): 'ok' | 'error' {\n return !status ||\n status.code === SPAN_STATUS_OK ||\n status.code === SPAN_STATUS_UNSET ||\n status.message === 'cancelled'\n ? 'ok'\n : 'error';\n}\n\n/**\n * Returns the span's attributes with the SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE attribute added\n * if the span has an error status message worth preserving.\n *\n * An explicitly set attribute is never overwritten.\n */\nexport function addStatusMessageAttribute(\n attributes: SpanAttributes,\n status: SpanStatus | undefined,\n): RawAttributes<Record<string, unknown>> {\n const statusMessage = getSimpleStatus(status) === 'error' ? status?.message : undefined;\n return {\n ...(statusMessage && { [SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE]: statusMessage }),\n ...attributes,\n };\n}\n\nconst CHILD_SPANS_FIELD = '_sentryChildSpans';\nconst ROOT_SPAN_FIELD = '_sentryRootSpan';\n\ntype SpanWithPotentialChildren = Span & {\n [CHILD_SPANS_FIELD]?: Set<Span>;\n [ROOT_SPAN_FIELD]?: Span;\n};\n\n/**\n * Adds an opaque child span reference to a span.\n */\nexport function addChildSpanToSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n // We store the root span reference on the child span\n // We need this for `getRootSpan()` to work\n const rootSpan = span[ROOT_SPAN_FIELD] || span;\n addNonEnumerableProperty(childSpan as SpanWithPotentialChildren, ROOT_SPAN_FIELD, rootSpan);\n\n // We store a list of child spans on the parent span\n // We need this for `getSpanDescendants()` to work\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].add(childSpan);\n } else {\n addNonEnumerableProperty(span, CHILD_SPANS_FIELD, new Set([childSpan]));\n }\n}\n\n/** This is only used internally by Idle Spans. */\nexport function removeChildSpanFromSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].delete(childSpan);\n }\n}\n\n/**\n * Returns an array of the given span and all of its descendants.\n */\nexport function getSpanDescendants(span: SpanWithPotentialChildren): Span[] {\n const resultSet = new Set<Span>();\n\n function addSpanChildren(span: SpanWithPotentialChildren): void {\n // This exit condition is required to not infinitely loop in case of a circular dependency.\n if (resultSet.has(span)) {\n return;\n // We want to ignore unsampled spans (e.g. non recording spans)\n } else if (spanIsSampled(span)) {\n resultSet.add(span);\n const childSpans = span[CHILD_SPANS_FIELD] ? Array.from(span[CHILD_SPANS_FIELD]) : [];\n for (const childSpan of childSpans) {\n addSpanChildren(childSpan);\n }\n }\n }\n\n addSpanChildren(span);\n\n return Array.from(resultSet);\n}\n\n/**\n * Returns the root span of a given span.\n */\nexport const getRootSpan = INTERNAL_getSegmentSpan;\n\n/**\n * Returns the segment span of a given span.\n */\nexport function INTERNAL_getSegmentSpan(span: SpanWithPotentialChildren): Span {\n return span[ROOT_SPAN_FIELD] || span;\n}\n\n/**\n * Returns the currently active span.\n */\nexport function getActiveSpan(): Span | undefined {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.getActiveSpan) {\n return acs.getActiveSpan();\n }\n\n return _getSpanForScope(getCurrentScope());\n}\n\n/**\n * Logs a warning once if `beforeSendSpan` is used to drop spans.\n */\nexport function showSpanDropWarning(): void {\n if (!hasShownSpanDropWarning) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.',\n );\n });\n hasShownSpanDropWarning = true;\n }\n}\n\n/**\n * Updates the name of the given span and ensures that the span name is not\n * overwritten by the Sentry SDK.\n *\n * Use this function instead of `span.updateName()` if you want to make sure that\n * your name is kept. For some spans, for example root `http.server` spans the\n * Sentry SDK would otherwise overwrite the span name with a high-quality name\n * it infers when the span ends.\n *\n * Use this function in server code or when your span is started on the server\n * and on the client (browser). If you only update a span name on the client,\n * you can also use `span.updateName()` the SDK does not overwrite the name.\n *\n * @param span - The span to update the name of.\n * @param name - The name to set on the span.\n */\nexport function updateSpanName(span: Span, name: string): void {\n span.updateName(name);\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]: name,\n });\n}\n"],"names":["getCapturedScopesOnSpan","generateSpanId","generateSentryTraceHeader","generateTraceparentHeader","timestampInSeconds","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","serializeAttributes","SPAN_STATUS_UNSET","SPAN_STATUS_OK","SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE","addNonEnumerableProperty","span","carrier","getMainCarrier","getAsyncContextStrategy","_getSpanForScope","getCurrentScope","consoleSandbox","SEMANTIC_ATTRI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AC5B;AACF;AAkBO,SAAS,cAAA,CAAe,MAAY,IAAA,EAAoB;AAC7D,EAAA,IAAA,CAAK,WAAW,IAAI,CAAA;AACpB,EAAA,IAAA,CAAK,aAAA,CAAc;AAAA,IACjB,CAACC,mDAAgC,GAAG,QAAA;AAAA,IACpC,CAACC,6DAA0C,GAAG;AAAA,GAC/C,CAAA;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
| Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const SDK_VERSION = "10.63.0" ; | ||
| const SDK_VERSION = "10.64.0" ; | ||
| exports.SDK_VERSION = SDK_VERSION; | ||
| //# sourceMappingURL=version.js.map |
+11
-7
| export { registerSpanErrorInstrumentation } from './tracing/errors.js'; | ||
| export { getCapturedScopesOnSpan, markSpanForOtelSourceInference, setCapturedScopesOnSpan, spanShouldInferOtelSource } from './tracing/utils.js'; | ||
| export { getCapturedScopesOnSpan, markSpanAsTracerProviderSpan, markSpanForOtelSourceInference, markSpanSourceAsExplicit, setCapturedScopesOnSpan, spanIsTracerProviderSpan, spanShouldInferOtelSource, spanSourceWasExplicitlySet } from './tracing/utils.js'; | ||
| export { TRACING_DEFAULTS, startIdleSpan } from './tracing/idleSpan.js'; | ||
| export { SentrySpan } from './tracing/sentrySpan.js'; | ||
| export { _INTERNAL_setDeferSegmentSpanCapture } from './tracing/deferSegmentSpanCapture.js'; | ||
| export { SentryNonRecordingSpan } from './tracing/sentryNonRecordingSpan.js'; | ||
| export { SPAN_STATUS_ERROR, SPAN_STATUS_OK, SPAN_STATUS_UNSET, getSpanStatusFromHttpCode, setHttpStatus } from './tracing/spanstatus.js'; | ||
| export { SUPPRESS_TRACING_KEY, continueTrace, isTracingSuppressed, startInactiveSpan, startNewTrace, startSpan, startSpanManual, suppressTracing, withActiveSpan } from './tracing/trace.js'; | ||
| export { SUPPRESS_TRACING_KEY, _INTERNAL_startInactiveSpan, continueTrace, isTracingSuppressed, spanIsIgnored, startInactiveSpan, startNewTrace, startSpan, startSpanManual, suppressTracing, withActiveSpan } from './tracing/trace.js'; | ||
| export { bindScopeToEmitter } from './tracing/bindScopeToEmitter.js'; | ||
@@ -47,3 +48,3 @@ export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromScope, getDynamicSamplingContextFromSpan, spanToBaggageHeader } from './tracing/dynamicSamplingContext.js'; | ||
| export { addAutoIpAddressToSession, addAutoIpAddressToUser } from './utils/ipAddress.js'; | ||
| export { INTERNAL_getSegmentSpan, addChildSpanToSpan, convertSpanLinksForEnvelope, getActiveSpan, getRootSpan, getSpanDescendants, getStatusMessage, spanIsSampled, spanTimeInputToSeconds, spanToJSON, spanToStreamedSpanJSON, spanToTraceContext, spanToTraceHeader, updateSpanName } from './utils/spanUtils.js'; | ||
| export { INTERNAL_getSegmentSpan, addChildSpanToSpan, convertSpanLinksForEnvelope, getActiveSpan, getRootSpan, getSpanDescendants, getStatusMessage, spanIsSampled, spanIsSentrySpan, spanTimeInputToSeconds, spanToJSON, spanToStreamedSpanJSON, spanToTraceContext, spanToTraceHeader, updateSpanName } from './utils/spanUtils.js'; | ||
| export { _setSpanForScope as _INTERNAL_setSpanForScope } from './utils/spanOnScope.js'; | ||
@@ -90,9 +91,12 @@ export { parseSampleRate } from './utils/parseSampleRate.js'; | ||
| export { addVercelAiProcessors, getProviderMetadataAttributes } from './tracing/vercel-ai/index.js'; | ||
| export { getTruncatedJsonString, shouldEnableTruncation } from './tracing/ai/utils.js'; | ||
| export { GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE } from './tracing/ai/gen-ai-attributes.js'; | ||
| export { getTruncatedJsonString, resolveAIRecordingOptions, shouldEnableTruncation } from './tracing/ai/utils.js'; | ||
| export { GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE } from './tracing/ai/gen-ai-attributes.js'; | ||
| export { _INTERNAL_cleanupToolCallSpanContext, _INTERNAL_getSpanContextForToolCallId } from './tracing/vercel-ai/utils.js'; | ||
| export { toolCallSpanContextMap as _INTERNAL_toolCallSpanContextMap } from './tracing/vercel-ai/constants.js'; | ||
| export { instrumentOpenAiClient } from './tracing/openai/index.js'; | ||
| export { addRequestAttributes as addOpenAiRequestAttributes, extractRequestAttributes as extractOpenAiRequestAttributes, instrumentOpenAiClient } from './tracing/openai/index.js'; | ||
| export { addResponseAttributes as addOpenAiResponseAttributes, extractRequestParameters as extractOpenAiRequestParameters } from './tracing/openai/utils.js'; | ||
| export { instrumentStream as instrumentOpenAiStream } from './tracing/openai/streaming.js'; | ||
| export { OPENAI_INTEGRATION_NAME } from './tracing/openai/constants.js'; | ||
| export { instrumentAnthropicAiClient } from './tracing/anthropic-ai/index.js'; | ||
| export { addPrivateRequestAttributes as addAnthropicRequestAttributes, addResponseAttributes as addAnthropicResponseAttributes, extractRequestAttributes as extractAnthropicRequestAttributes, instrumentAnthropicAiClient } from './tracing/anthropic-ai/index.js'; | ||
| export { instrumentAsyncIterableStream, instrumentMessageStream } from './tracing/anthropic-ai/streaming.js'; | ||
| export { ANTHROPIC_AI_INTEGRATION_NAME } from './tracing/anthropic-ai/constants.js'; | ||
@@ -99,0 +103,0 @@ export { instrumentGoogleGenAIClient } from './tracing/google-genai/index.js'; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"browser.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"browser.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"carrier.js","sources":["../../src/carrier.ts"],"sourcesContent":["import type { AsyncContextStack } from './asyncContext/stackStrategy';\nimport type { AsyncContextStrategy } from './asyncContext/types';\nimport type { Client } from './client';\nimport type { Scope } from './scope';\nimport type { SerializedLog } from './types/log';\nimport type { SerializedMetric } from './types/metric';\nimport { SDK_VERSION } from './utils/version';\nimport { GLOBAL_OBJ } from './utils/worldwide';\n\n/**\n * An object that contains globally accessible properties and maintains a scope stack.\n * @hidden\n */\nexport interface Carrier {\n __SENTRY__?: VersionedCarrier;\n}\n\ntype VersionedCarrier = {\n version?: string;\n} & Record<Exclude<string, 'version'>, SentryCarrier>;\n\nexport interface SentryCarrier {\n acs?: AsyncContextStrategy;\n stack?: AsyncContextStack;\n\n globalScope?: Scope;\n defaultIsolationScope?: Scope;\n defaultCurrentScope?: Scope;\n loggerSettings?: { enabled: boolean };\n /**\n * A map of Sentry clients to their log buffers.\n * This is used to store logs that are sent to Sentry.\n */\n clientToLogBufferMap?: WeakMap<Client, Array<SerializedLog>>;\n\n /**\n * A map of Sentry clients to their metric buffers.\n * This is used to store metrics that are sent to Sentry.\n */\n clientToMetricBufferMap?: WeakMap<Client, Array<SerializedMetric>>;\n\n /** Overwrites TextEncoder used in `@sentry/core`, need for `react-native@0.73` and older */\n encodePolyfill?: (input: string) => Uint8Array;\n /** Overwrites TextDecoder used in `@sentry/core`, need for `react-native@0.73` and older */\n decodePolyfill?: (input: Uint8Array) => string;\n}\n\n/**\n * Returns the global shim registry.\n *\n * FIXME: This function is problematic, because despite always returning a valid Carrier,\n * it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check\n * at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there.\n **/\nexport function getMainCarrier(): Carrier {\n // This ensures a Sentry carrier exists\n getSentryCarrier(GLOBAL_OBJ);\n return GLOBAL_OBJ;\n}\n\n/** Will either get the existing sentry carrier, or create a new one. */\nexport function getSentryCarrier(carrier: Carrier): SentryCarrier {\n const __SENTRY__ = (carrier.__SENTRY__ = carrier.__SENTRY__ || {});\n\n // For now: First SDK that sets the .version property wins\n __SENTRY__.version = __SENTRY__.version || SDK_VERSION;\n\n // Intentionally populating and returning the version of \"this\" SDK instance\n // rather than what's set in .version so that \"this\" SDK always gets its carrier\n return (__SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {});\n}\n\n/**\n * Returns a global singleton contained in the global `__SENTRY__[]` object.\n *\n * If the singleton doesn't already exist in `__SENTRY__`, it will be created using the given factory\n * function and added to the `__SENTRY__` object.\n *\n * @param name name of the global singleton on __SENTRY__\n * @param creator creator Factory function to create the singleton if it doesn't already exist on `__SENTRY__`\n * @param obj (Optional) The global object on which to look for `__SENTRY__`, if not `GLOBAL_OBJ`'s return value\n * @returns the singleton\n */\nexport function getGlobalSingleton<Prop extends keyof SentryCarrier>(\n name: Prop,\n creator: () => NonNullable<SentryCarrier[Prop]>,\n obj = GLOBAL_OBJ,\n): NonNullable<SentryCarrier[Prop]> {\n const __SENTRY__ = (obj.__SENTRY__ = obj.__SENTRY__ || {});\n const carrier = (__SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {});\n // Note: We do not want to set `carrier.version` here, as this may be called before any `init` is called, e.g. for the default scopes\n return carrier[name] || (carrier[name] = creator());\n}\n"],"names":[],"mappings":";;;AAsDO,SAAS,cAAA,GAA0B;AAExC,EAAA,gBAAA,CAAiB,UAAU,CAAA;AAC3B,EAAA,OAAO,UAAA;AACT;AAGO,SAAS,iBAAiB,OAAA,EAAiC;AAChE,EAAA,MAAM,UAAA,GAAc,OAAA,CAAQ,UAAA,GAAa,OAAA,CAAQ,cAAc,EAAC;AAGhE,EAAA,UAAA,CAAW,OAAA,GAAU,WAAW,OAAA,IAAW,WAAA;AAI3C,EAAA,OAAQ,WAAW,WAAW,CAAA,GAAI,UAAA,CAAW,WAAW,KAAK,EAAC;AAChE;AAaO,SAAS,kBAAA,CACd,IAAA,EACA,OAAA,EACA,GAAA,GAAM,UAAA,EAC4B;AAClC,EAAA,MAAM,UAAA,GAAc,GAAA,CAAI,UAAA,GAAa,GAAA,CAAI,cAAc,EAAC;AACxD,EAAA,MAAM,UAAW,UAAA,CAAW,WAAW,IAAI,UAAA,CAAW,WAAW,KAAK,EAAC;AAEvE,EAAA,OAAO,QAAQ,IAAI,CAAA,KAAM,OAAA,CAAQ,IAAI,IAAI,OAAA,EAAQ,CAAA;AACnD;;;;"} | ||
| {"version":3,"file":"carrier.js","sources":["../../src/carrier.ts"],"sourcesContent":["import type { AsyncContextStack } from './asyncContext/stackStrategy';\nimport type { AsyncContextStrategy } from './asyncContext/types';\nimport type { Client } from './client';\nimport type { Scope } from './scope';\nimport type { SegmentSpanCaptureStrategy } from './tracing/segmentSpanCaptureStrategy';\nimport type { SerializedLog } from './types/log';\nimport type { SerializedMetric } from './types/metric';\nimport { SDK_VERSION } from './utils/version';\nimport { GLOBAL_OBJ } from './utils/worldwide';\n\n/**\n * An object that contains globally accessible properties and maintains a scope stack.\n * @hidden\n */\nexport interface Carrier {\n __SENTRY__?: VersionedCarrier;\n}\n\ntype VersionedCarrier = {\n version?: string;\n} & Record<Exclude<string, 'version'>, SentryCarrier>;\n\nexport interface SentryCarrier {\n acs?: AsyncContextStrategy;\n stack?: AsyncContextStack;\n\n globalScope?: Scope;\n defaultIsolationScope?: Scope;\n defaultCurrentScope?: Scope;\n loggerSettings?: { enabled: boolean };\n /**\n * A map of Sentry clients to their log buffers.\n * This is used to store logs that are sent to Sentry.\n */\n clientToLogBufferMap?: WeakMap<Client, Array<SerializedLog>>;\n\n /**\n * A map of Sentry clients to their metric buffers.\n * This is used to store metrics that are sent to Sentry.\n */\n clientToMetricBufferMap?: WeakMap<Client, Array<SerializedMetric>>;\n\n /** Strategy for assembling segment spans into transactions; set by SDKs that defer capture. */\n segmentSpanCaptureStrategy?: SegmentSpanCaptureStrategy;\n\n /** Overwrites TextEncoder used in `@sentry/core`, need for `react-native@0.73` and older */\n encodePolyfill?: (input: string) => Uint8Array;\n /** Overwrites TextDecoder used in `@sentry/core`, need for `react-native@0.73` and older */\n decodePolyfill?: (input: Uint8Array) => string;\n}\n\n/**\n * Returns the global shim registry.\n *\n * FIXME: This function is problematic, because despite always returning a valid Carrier,\n * it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check\n * at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there.\n **/\nexport function getMainCarrier(): Carrier {\n // This ensures a Sentry carrier exists\n getSentryCarrier(GLOBAL_OBJ);\n return GLOBAL_OBJ;\n}\n\n/** Will either get the existing sentry carrier, or create a new one. */\nexport function getSentryCarrier(carrier: Carrier): SentryCarrier {\n const __SENTRY__ = (carrier.__SENTRY__ = carrier.__SENTRY__ || {});\n\n // For now: First SDK that sets the .version property wins\n __SENTRY__.version = __SENTRY__.version || SDK_VERSION;\n\n // Intentionally populating and returning the version of \"this\" SDK instance\n // rather than what's set in .version so that \"this\" SDK always gets its carrier\n return (__SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {});\n}\n\n/**\n * Returns a global singleton contained in the global `__SENTRY__[]` object.\n *\n * If the singleton doesn't already exist in `__SENTRY__`, it will be created using the given factory\n * function and added to the `__SENTRY__` object.\n *\n * @param name name of the global singleton on __SENTRY__\n * @param creator creator Factory function to create the singleton if it doesn't already exist on `__SENTRY__`\n * @param obj (Optional) The global object on which to look for `__SENTRY__`, if not `GLOBAL_OBJ`'s return value\n * @returns the singleton\n */\nexport function getGlobalSingleton<Prop extends keyof SentryCarrier>(\n name: Prop,\n creator: () => NonNullable<SentryCarrier[Prop]>,\n obj = GLOBAL_OBJ,\n): NonNullable<SentryCarrier[Prop]> {\n const __SENTRY__ = (obj.__SENTRY__ = obj.__SENTRY__ || {});\n const carrier = (__SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {});\n // Note: We do not want to set `carrier.version` here, as this may be called before any `init` is called, e.g. for the default scopes\n return carrier[name] || (carrier[name] = creator());\n}\n"],"names":[],"mappings":";;;AA0DO,SAAS,cAAA,GAA0B;AAExC,EAAA,gBAAA,CAAiB,UAAU,CAAA;AAC3B,EAAA,OAAO,UAAA;AACT;AAGO,SAAS,iBAAiB,OAAA,EAAiC;AAChE,EAAA,MAAM,UAAA,GAAc,OAAA,CAAQ,UAAA,GAAa,OAAA,CAAQ,cAAc,EAAC;AAGhE,EAAA,UAAA,CAAW,OAAA,GAAU,WAAW,OAAA,IAAW,WAAA;AAI3C,EAAA,OAAQ,WAAW,WAAW,CAAA,GAAI,UAAA,CAAW,WAAW,KAAK,EAAC;AAChE;AAaO,SAAS,kBAAA,CACd,IAAA,EACA,OAAA,EACA,GAAA,GAAM,UAAA,EAC4B;AAClC,EAAA,MAAM,UAAA,GAAc,GAAA,CAAI,UAAA,GAAa,GAAA,CAAI,cAAc,EAAC;AACxD,EAAA,MAAM,UAAW,UAAA,CAAW,WAAW,IAAI,UAAA,CAAW,WAAW,KAAK,EAAC;AAEvE,EAAA,OAAO,QAAQ,IAAI,CAAA,KAAM,OAAA,CAAQ,IAAI,IAAI,OAAA,EAAQ,CAAA;AACnD;;;;"} |
+11
-7
| export { registerSpanErrorInstrumentation } from './tracing/errors.js'; | ||
| export { getCapturedScopesOnSpan, markSpanForOtelSourceInference, setCapturedScopesOnSpan, spanShouldInferOtelSource } from './tracing/utils.js'; | ||
| export { getCapturedScopesOnSpan, markSpanAsTracerProviderSpan, markSpanForOtelSourceInference, markSpanSourceAsExplicit, setCapturedScopesOnSpan, spanIsTracerProviderSpan, spanShouldInferOtelSource, spanSourceWasExplicitlySet } from './tracing/utils.js'; | ||
| export { TRACING_DEFAULTS, startIdleSpan } from './tracing/idleSpan.js'; | ||
| export { SentrySpan } from './tracing/sentrySpan.js'; | ||
| export { _INTERNAL_setDeferSegmentSpanCapture } from './tracing/deferSegmentSpanCapture.js'; | ||
| export { SentryNonRecordingSpan } from './tracing/sentryNonRecordingSpan.js'; | ||
| export { SPAN_STATUS_ERROR, SPAN_STATUS_OK, SPAN_STATUS_UNSET, getSpanStatusFromHttpCode, setHttpStatus } from './tracing/spanstatus.js'; | ||
| export { SUPPRESS_TRACING_KEY, continueTrace, isTracingSuppressed, startInactiveSpan, startNewTrace, startSpan, startSpanManual, suppressTracing, withActiveSpan } from './tracing/trace.js'; | ||
| export { SUPPRESS_TRACING_KEY, _INTERNAL_startInactiveSpan, continueTrace, isTracingSuppressed, spanIsIgnored, startInactiveSpan, startNewTrace, startSpan, startSpanManual, suppressTracing, withActiveSpan } from './tracing/trace.js'; | ||
| export { bindScopeToEmitter } from './tracing/bindScopeToEmitter.js'; | ||
@@ -47,3 +48,3 @@ export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromScope, getDynamicSamplingContextFromSpan, spanToBaggageHeader } from './tracing/dynamicSamplingContext.js'; | ||
| export { addAutoIpAddressToSession, addAutoIpAddressToUser } from './utils/ipAddress.js'; | ||
| export { INTERNAL_getSegmentSpan, addChildSpanToSpan, convertSpanLinksForEnvelope, getActiveSpan, getRootSpan, getSpanDescendants, getStatusMessage, spanIsSampled, spanTimeInputToSeconds, spanToJSON, spanToStreamedSpanJSON, spanToTraceContext, spanToTraceHeader, updateSpanName } from './utils/spanUtils.js'; | ||
| export { INTERNAL_getSegmentSpan, addChildSpanToSpan, convertSpanLinksForEnvelope, getActiveSpan, getRootSpan, getSpanDescendants, getStatusMessage, spanIsSampled, spanIsSentrySpan, spanTimeInputToSeconds, spanToJSON, spanToStreamedSpanJSON, spanToTraceContext, spanToTraceHeader, updateSpanName } from './utils/spanUtils.js'; | ||
| export { _setSpanForScope as _INTERNAL_setSpanForScope } from './utils/spanOnScope.js'; | ||
@@ -90,9 +91,12 @@ export { parseSampleRate } from './utils/parseSampleRate.js'; | ||
| export { addVercelAiProcessors, getProviderMetadataAttributes } from './tracing/vercel-ai/index.js'; | ||
| export { getTruncatedJsonString, shouldEnableTruncation } from './tracing/ai/utils.js'; | ||
| export { GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE } from './tracing/ai/gen-ai-attributes.js'; | ||
| export { getTruncatedJsonString, resolveAIRecordingOptions, shouldEnableTruncation } from './tracing/ai/utils.js'; | ||
| export { GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE } from './tracing/ai/gen-ai-attributes.js'; | ||
| export { _INTERNAL_cleanupToolCallSpanContext, _INTERNAL_getSpanContextForToolCallId } from './tracing/vercel-ai/utils.js'; | ||
| export { toolCallSpanContextMap as _INTERNAL_toolCallSpanContextMap } from './tracing/vercel-ai/constants.js'; | ||
| export { instrumentOpenAiClient } from './tracing/openai/index.js'; | ||
| export { addRequestAttributes as addOpenAiRequestAttributes, extractRequestAttributes as extractOpenAiRequestAttributes, instrumentOpenAiClient } from './tracing/openai/index.js'; | ||
| export { addResponseAttributes as addOpenAiResponseAttributes, extractRequestParameters as extractOpenAiRequestParameters } from './tracing/openai/utils.js'; | ||
| export { instrumentStream as instrumentOpenAiStream } from './tracing/openai/streaming.js'; | ||
| export { OPENAI_INTEGRATION_NAME } from './tracing/openai/constants.js'; | ||
| export { instrumentAnthropicAiClient } from './tracing/anthropic-ai/index.js'; | ||
| export { addPrivateRequestAttributes as addAnthropicRequestAttributes, addResponseAttributes as addAnthropicResponseAttributes, extractRequestAttributes as extractAnthropicRequestAttributes, instrumentAnthropicAiClient } from './tracing/anthropic-ai/index.js'; | ||
| export { instrumentAsyncIterableStream, instrumentMessageStream } from './tracing/anthropic-ai/streaming.js'; | ||
| export { ANTHROPIC_AI_INTEGRATION_NAME } from './tracing/anthropic-ai/constants.js'; | ||
@@ -99,0 +103,0 @@ export { instrumentGoogleGenAIClient } from './tracing/google-genai/index.js'; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"growthbook.js","sources":["../../../../src/integrations/featureFlags/growthbook.ts"],"sourcesContent":["import type { Client } from '../../client';\nimport { defineIntegration } from '../../integration';\nimport type { Event, EventHint } from '../../types/event';\nimport type { IntegrationFn } from '../../types/integration';\nimport {\n _INTERNAL_addFeatureFlagToActiveSpan,\n _INTERNAL_copyFlagsFromScopeToEvent,\n _INTERNAL_insertFlagToScope,\n} from '../../utils/featureFlags';\nimport { fill } from '../../utils/object';\n\ninterface GrowthBookLike {\n isOn(this: GrowthBookLike, featureKey: string, ...rest: unknown[]): boolean;\n getFeatureValue(this: GrowthBookLike, featureKey: string, defaultValue: unknown, ...rest: unknown[]): unknown;\n}\n\nexport type GrowthBookClassLike = new (...args: unknown[]) => GrowthBookLike;\n\n/**\n * Sentry integration for capturing feature flag evaluations from GrowthBook.\n *\n * Only boolean results are captured at this time.\n *\n * @example\n * ```typescript\n * import { GrowthBook } from '@growthbook/growthbook';\n * import * as Sentry from '@sentry/browser'; // or '@sentry/node'\n *\n * Sentry.init({\n * dsn: 'your-dsn',\n * integrations: [\n * Sentry.growthbookIntegration({ growthbookClass: GrowthBook })\n * ]\n * });\n * ```\n */\nexport const growthbookIntegration: IntegrationFn = defineIntegration(\n ({ growthbookClass }: { growthbookClass: GrowthBookClassLike }) => {\n return {\n name: 'GrowthBook' as const,\n\n setupOnce() {\n const proto = growthbookClass.prototype as GrowthBookLike;\n\n // Type guard and wrap isOn\n if (typeof proto.isOn === 'function') {\n fill(proto, 'isOn', _wrapAndCaptureBooleanResult);\n }\n\n // Type guard and wrap getFeatureValue\n if (typeof proto.getFeatureValue === 'function') {\n fill(proto, 'getFeatureValue', _wrapAndCaptureBooleanResult);\n }\n },\n\n processEvent(event: Event, _hint: EventHint, _client: Client): Event {\n return _INTERNAL_copyFlagsFromScopeToEvent(event);\n },\n };\n },\n);\n\nfunction _wrapAndCaptureBooleanResult(\n original: (this: GrowthBookLike, ...args: unknown[]) => unknown,\n): (this: GrowthBookLike, ...args: unknown[]) => unknown {\n return function (this: GrowthBookLike, ...args: unknown[]): unknown {\n const flagName = args[0];\n const result = original.apply(this, args);\n\n if (typeof flagName === 'string' && typeof result === 'boolean') {\n _INTERNAL_insertFlagToScope(flagName, result);\n _INTERNAL_addFeatureFlagToActiveSpan(flagName, result);\n }\n\n return result;\n };\n}\n"],"names":[],"mappings":";;;;AAoCO,MAAM,qBAAA,GAAuC,iBAAA;AAAA,EAClD,CAAC,EAAE,eAAA,EAAgB,KAAgD;AACjE,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,YAAA;AAAA,MAEN,SAAA,GAAY;AACV,QAAA,MAAM,QAAQ,eAAA,CAAgB,SAAA;AAG9B,QAAA,IAAI,OAAO,KAAA,CAAM,IAAA,KAAS,UAAA,EAAY;AACpC,UAAA,IAAA,CAAK,KAAA,EAAO,QAAQ,4BAA4B,CAAA;AAAA,QAClD;AAGA,QAAA,IAAI,OAAO,KAAA,CAAM,eAAA,KAAoB,UAAA,EAAY;AAC/C,UAAA,IAAA,CAAK,KAAA,EAAO,mBAAmB,4BAA4B,CAAA;AAAA,QAC7D;AAAA,MACF,CAAA;AAAA,MAEA,YAAA,CAAa,KAAA,EAAc,KAAA,EAAkB,OAAA,EAAwB;AACnE,QAAA,OAAO,oCAAoC,KAAK,CAAA;AAAA,MAClD;AAAA,KACF;AAAA,EACF;AACF;AAEA,SAAS,6BACP,QAAA,EACuD;AACvD,EAAA,OAAO,YAAmC,IAAA,EAA0B;AAClE,IAAA,MAAM,QAAA,GAAW,KAAK,CAAC,CAAA;AACvB,IAAA,MAAM,MAAA,GAAS,QAAA,CAAS,KAAA,CAAM,IAAA,EAAM,IAAI,CAAA;AAExC,IAAA,IAAI,OAAO,QAAA,KAAa,QAAA,IAAY,OAAO,WAAW,SAAA,EAAW;AAC/D,MAAA,2BAAA,CAA4B,UAAU,MAAM,CAAA;AAC5C,MAAA,oCAAA,CAAqC,UAAU,MAAM,CAAA;AAAA,IACvD;AAEA,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AACF;;;;"} | ||
| {"version":3,"file":"growthbook.js","sources":["../../../../src/integrations/featureFlags/growthbook.ts"],"sourcesContent":["import type { Client } from '../../client';\nimport { defineIntegration } from '../../integration';\nimport type { Event, EventHint } from '../../types/event';\nimport type { IntegrationFn } from '../../types/integration';\nimport {\n _INTERNAL_addFeatureFlagToActiveSpan,\n _INTERNAL_copyFlagsFromScopeToEvent,\n _INTERNAL_insertFlagToScope,\n} from '../../utils/featureFlags';\nimport { fill } from '../../utils/object';\n\ninterface GrowthBookLike {\n isOn(this: GrowthBookLike, featureKey: string, ...rest: unknown[]): boolean;\n getFeatureValue(this: GrowthBookLike, featureKey: string, defaultValue: unknown, ...rest: unknown[]): unknown;\n}\n\n// `unknown[]` is contravariantly incompatible with real constructors (e.g. GrowthBook's), so use `any[]`.\n// oxlint-disable-next-line typescript-eslint/no-explicit-any\nexport type GrowthBookClassLike = new (...args: any[]) => GrowthBookLike;\n\n/**\n * Sentry integration for capturing feature flag evaluations from GrowthBook.\n *\n * Only boolean results are captured at this time.\n *\n * @example\n * ```typescript\n * import { GrowthBook } from '@growthbook/growthbook';\n * import * as Sentry from '@sentry/browser'; // or '@sentry/node'\n *\n * Sentry.init({\n * dsn: 'your-dsn',\n * integrations: [\n * Sentry.growthbookIntegration({ growthbookClass: GrowthBook })\n * ]\n * });\n * ```\n */\nexport const growthbookIntegration: IntegrationFn = defineIntegration(\n ({ growthbookClass }: { growthbookClass: GrowthBookClassLike }) => {\n return {\n name: 'GrowthBook' as const,\n\n setupOnce() {\n const proto = growthbookClass.prototype as GrowthBookLike;\n\n // Type guard and wrap isOn\n if (typeof proto.isOn === 'function') {\n fill(proto, 'isOn', _wrapAndCaptureBooleanResult);\n }\n\n // Type guard and wrap getFeatureValue\n if (typeof proto.getFeatureValue === 'function') {\n fill(proto, 'getFeatureValue', _wrapAndCaptureBooleanResult);\n }\n },\n\n processEvent(event: Event, _hint: EventHint, _client: Client): Event {\n return _INTERNAL_copyFlagsFromScopeToEvent(event);\n },\n };\n },\n);\n\nfunction _wrapAndCaptureBooleanResult(\n original: (this: GrowthBookLike, ...args: unknown[]) => unknown,\n): (this: GrowthBookLike, ...args: unknown[]) => unknown {\n return function (this: GrowthBookLike, ...args: unknown[]): unknown {\n const flagName = args[0];\n const result = original.apply(this, args);\n\n if (typeof flagName === 'string' && typeof result === 'boolean') {\n _INTERNAL_insertFlagToScope(flagName, result);\n _INTERNAL_addFeatureFlagToActiveSpan(flagName, result);\n }\n\n return result;\n };\n}\n"],"names":[],"mappings":";;;;AAsCO,MAAM,qBAAA,GAAuC,iBAAA;AAAA,EAClD,CAAC,EAAE,eAAA,EAAgB,KAAgD;AACjE,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,YAAA;AAAA,MAEN,SAAA,GAAY;AACV,QAAA,MAAM,QAAQ,eAAA,CAAgB,SAAA;AAG9B,QAAA,IAAI,OAAO,KAAA,CAAM,IAAA,KAAS,UAAA,EAAY;AACpC,UAAA,IAAA,CAAK,KAAA,EAAO,QAAQ,4BAA4B,CAAA;AAAA,QAClD;AAGA,QAAA,IAAI,OAAO,KAAA,CAAM,eAAA,KAAoB,UAAA,EAAY;AAC/C,UAAA,IAAA,CAAK,KAAA,EAAO,mBAAmB,4BAA4B,CAAA;AAAA,QAC7D;AAAA,MACF,CAAA;AAAA,MAEA,YAAA,CAAa,KAAA,EAAc,KAAA,EAAkB,OAAA,EAAwB;AACnE,QAAA,OAAO,oCAAoC,KAAK,CAAA;AAAA,MAClD;AAAA,KACF;AAAA,EACF;AACF;AAEA,SAAS,6BACP,QAAA,EACuD;AACvD,EAAA,OAAO,YAAmC,IAAA,EAA0B;AAClE,IAAA,MAAM,QAAA,GAAW,KAAK,CAAC,CAAA;AACvB,IAAA,MAAM,MAAA,GAAS,QAAA,CAAS,KAAA,CAAM,IAAA,EAAM,IAAI,CAAA;AAExC,IAAA,IAAI,OAAO,QAAA,KAAa,QAAA,IAAY,OAAO,WAAW,SAAA,EAAW;AAC/D,MAAA,2BAAA,CAA4B,UAAU,MAAM,CAAA;AAC5C,MAAA,oCAAA,CAAqC,UAAU,MAAM,CAAA;AAAA,IACvD;AAEA,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AACF;;;;"} |
@@ -1,1 +0,1 @@ | ||
| {"type":"module","version":"10.63.0","sideEffects":false} | ||
| {"type":"module","version":"10.64.0","sideEffects":false} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"semanticAttributes.js","sources":["../../src/semanticAttributes.ts"],"sourcesContent":["/**\n * Use this attribute to represent the source of a span name.\n * Must be one of: custom, url, route, view, component, task\n * TODO(v11): rename this to sentry.span.source'\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = 'sentry.source';\n\n/**\n * Attributes that holds the sample rate that was locally applied to a span.\n * If this attribute is not defined, it means that the span inherited a sampling decision.\n *\n * NOTE: Is only defined on root spans.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = 'sentry.sample_rate';\n\n/**\n * Attribute holding the sample rate of the previous trace.\n * This is used to sample consistently across subsequent traces in the browser SDK.\n *\n * Note: Only defined on root spans, if opted into consistent sampling\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE = 'sentry.previous_trace_sample_rate';\n\n/**\n * Use this attribute to represent the operation of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_OP = 'sentry.op';\n\n/**\n * Use this attribute to represent the origin of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = 'sentry.origin';\n\n/**\n * Holds the human-readable span status message (e.g. set via\n * `span.setStatus({ code, message })`).\n *\n * Streamed (v2) span statuses are reduced to `ok`/`error`, so we preserve the\n * message as an attribute instead of dropping it. This mirrors the attribute\n * Sentry's OTLP ingestion uses for the same purpose.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE = 'sentry.status.message';\n\n/** The reason why an idle span finished. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON = 'sentry.idle_span_finish_reason';\n\n/** The unit of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT = 'sentry.measurement_unit';\n\n/** The value of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE = 'sentry.measurement_value';\n\n/** The release version of the application */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = 'sentry.release';\n/** The environment name (e.g., \"production\", \"staging\", \"development\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = 'sentry.environment';\n/** The segment name (e.g., \"GET /users\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME = 'sentry.segment.name';\n/** The id of the segment that this span belongs to. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID = 'sentry.segment.id';\n/** The name of the Sentry SDK (e.g., \"sentry.php\", \"sentry.javascript\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = 'sentry.sdk.name';\n/** The version of the Sentry SDK */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = 'sentry.sdk.version';\n/** The list of integrations enabled in the Sentry SDK (e.g., [\"InboundFilters\", \"BrowserTracing\"]) */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS = 'sentry.sdk.integrations';\n\n/** The user ID */\nexport const SEMANTIC_ATTRIBUTE_USER_ID = 'user.id';\n/** The user email */\nexport const SEMANTIC_ATTRIBUTE_USER_EMAIL = 'user.email';\n/** The user IP address */\nexport const SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = 'user.ip_address';\n/** The user username */\nexport const SEMANTIC_ATTRIBUTE_USER_USERNAME = 'user.name';\n\n/**\n * A custom span name set by users guaranteed to be taken over any automatically\n * inferred name. This attribute is removed before the span is sent.\n *\n * @internal only meant for internal SDK usage\n * @hidden\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME = 'sentry.custom_span_name';\n\n/**\n * The id of the profile that this span occurred in.\n */\nexport const SEMANTIC_ATTRIBUTE_PROFILE_ID = 'sentry.profile_id';\n\nexport const SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = 'sentry.exclusive_time';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_HIT = 'cache.hit';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_KEY = 'cache.key';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = 'cache.item_size';\n\n/** TODO: Remove these once we update to latest semantic conventions */\nexport const SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = 'http.request.method';\nexport const SEMANTIC_ATTRIBUTE_URL_FULL = 'url.full';\n\n/**\n * A span link attribute to mark the link as a special span link.\n *\n * Known values:\n * - `previous_trace`: The span links to the frontend root span of the previous trace.\n * - `next_trace`: The span links to the frontend root span of the next trace. (Not set by the SDK)\n *\n * Other values may be set as appropriate.\n * @see https://develop.sentry.dev/sdk/telemetry/traces/span-links/#link-types\n */\nexport const SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = 'sentry.link.type';\n\n/**\n * =============================================================================\n * GEN AI ATTRIBUTES\n * Based on OpenTelemetry Semantic Conventions for Generative AI\n * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/\n * =============================================================================\n */\n\n/**\n * The conversation ID for linking messages across API calls.\n * For OpenAI Assistants API: thread_id\n * For LangGraph: configurable.thread_id\n */\nexport const GEN_AI_CONVERSATION_ID_ATTRIBUTE = 'gen_ai.conversation.id';\n"],"names":[],"mappings":"AAKO,MAAM,gCAAA,GAAmC;AAQzC,MAAM,qCAAA,GAAwC;AAQ9C,MAAM,oDAAA,GAAuD;AAK7D,MAAM,4BAAA,GAA+B;AAKrC,MAAM,gCAAA,GAAmC;AAUzC,MAAM,wCAAA,GAA2C;AAGjD,MAAM,iDAAA,GAAoD;AAG1D,MAAM,0CAAA,GAA6C;AAGnD,MAAM,2CAAA,GAA8C;AAGpD,MAAM,iCAAA,GAAoC;AAE1C,MAAM,qCAAA,GAAwC;AAE9C,MAAM,sCAAA,GAAyC;AAE/C,MAAM,oCAAA,GAAuC;AAE7C,MAAM,kCAAA,GAAqC;AAE3C,MAAM,qCAAA,GAAwC;AAE9C,MAAM,0CAAA,GAA6C;AAGnD,MAAM,0BAAA,GAA6B;AAEnC,MAAM,6BAAA,GAAgC;AAEtC,MAAM,kCAAA,GAAqC;AAE3C,MAAM,gCAAA,GAAmC;AASzC,MAAM,0CAAA,GAA6C;AAKnD,MAAM,6BAAA,GAAgC;AAEtC,MAAM,iCAAA,GAAoC;AAE1C,MAAM,4BAAA,GAA+B;AAErC,MAAM,4BAAA,GAA+B;AAErC,MAAM,kCAAA,GAAqC;AAG3C,MAAM,sCAAA,GAAyC;AAC/C,MAAM,2BAAA,GAA8B;AAYpC,MAAM,iCAAA,GAAoC;AAe1C,MAAM,gCAAA,GAAmC;;;;"} | ||
| {"version":3,"file":"semanticAttributes.js","sources":["../../src/semanticAttributes.ts"],"sourcesContent":["/**\n * Use this attribute to represent the source of a span name.\n * Must be one of: custom, url, route, view, component, task\n * TODO(v11): remove this export\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = 'sentry.source';\n\n/**\n * Attributes that holds the sample rate that was locally applied to a span.\n * If this attribute is not defined, it means that the span inherited a sampling decision.\n *\n * NOTE: Is only defined on root spans.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = 'sentry.sample_rate';\n\n/**\n * Attribute holding the sample rate of the previous trace.\n * This is used to sample consistently across subsequent traces in the browser SDK.\n *\n * Note: Only defined on root spans, if opted into consistent sampling\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE = 'sentry.previous_trace_sample_rate';\n\n/**\n * Use this attribute to represent the operation of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_OP = 'sentry.op';\n\n/**\n * Use this attribute to represent the origin of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = 'sentry.origin';\n\n/**\n * Holds the human-readable span status message (e.g. set via\n * `span.setStatus({ code, message })`).\n *\n * Streamed (v2) span statuses are reduced to `ok`/`error`, so we preserve the\n * message as an attribute instead of dropping it. This mirrors the attribute\n * Sentry's OTLP ingestion uses for the same purpose.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE = 'sentry.status.message';\n\n/** The reason why an idle span finished. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON = 'sentry.idle_span_finish_reason';\n\n/** The unit of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT = 'sentry.measurement_unit';\n\n/** The value of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE = 'sentry.measurement_value';\n\n/** The release version of the application */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = 'sentry.release';\n/** The environment name (e.g., \"production\", \"staging\", \"development\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = 'sentry.environment';\n/** The segment name (e.g., \"GET /users\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME = 'sentry.segment.name';\n/** The id of the segment that this span belongs to. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID = 'sentry.segment.id';\n/** The name of the Sentry SDK (e.g., \"sentry.php\", \"sentry.javascript\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = 'sentry.sdk.name';\n/** The version of the Sentry SDK */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = 'sentry.sdk.version';\n/** The list of integrations enabled in the Sentry SDK (e.g., [\"InboundFilters\", \"BrowserTracing\"]) */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS = 'sentry.sdk.integrations';\n\n/** The user ID */\nexport const SEMANTIC_ATTRIBUTE_USER_ID = 'user.id';\n/** The user email */\nexport const SEMANTIC_ATTRIBUTE_USER_EMAIL = 'user.email';\n/** The user IP address */\nexport const SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = 'user.ip_address';\n/** The user username */\nexport const SEMANTIC_ATTRIBUTE_USER_USERNAME = 'user.name';\n\n/**\n * A custom span name set by users guaranteed to be taken over any automatically\n * inferred name. This attribute is removed before the span is sent.\n *\n * @internal only meant for internal SDK usage\n * @hidden\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME = 'sentry.custom_span_name';\n\n/**\n * The id of the profile that this span occurred in.\n */\nexport const SEMANTIC_ATTRIBUTE_PROFILE_ID = 'sentry.profile_id';\n\nexport const SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = 'sentry.exclusive_time';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_HIT = 'cache.hit';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_KEY = 'cache.key';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = 'cache.item_size';\n\n/** TODO: Remove these once we update to latest semantic conventions */\nexport const SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = 'http.request.method';\nexport const SEMANTIC_ATTRIBUTE_URL_FULL = 'url.full';\n\n/**\n * A span link attribute to mark the link as a special span link.\n *\n * Known values:\n * - `previous_trace`: The span links to the frontend root span of the previous trace.\n * - `next_trace`: The span links to the frontend root span of the next trace. (Not set by the SDK)\n *\n * Other values may be set as appropriate.\n * @see https://develop.sentry.dev/sdk/telemetry/traces/span-links/#link-types\n */\nexport const SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = 'sentry.link.type';\n\n/**\n * =============================================================================\n * GEN AI ATTRIBUTES\n * Based on OpenTelemetry Semantic Conventions for Generative AI\n * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/\n * =============================================================================\n */\n\n/**\n * The conversation ID for linking messages across API calls.\n * For OpenAI Assistants API: thread_id\n * For LangGraph: configurable.thread_id\n */\nexport const GEN_AI_CONVERSATION_ID_ATTRIBUTE = 'gen_ai.conversation.id';\n"],"names":[],"mappings":"AAKO,MAAM,gCAAA,GAAmC;AAQzC,MAAM,qCAAA,GAAwC;AAQ9C,MAAM,oDAAA,GAAuD;AAK7D,MAAM,4BAAA,GAA+B;AAKrC,MAAM,gCAAA,GAAmC;AAUzC,MAAM,wCAAA,GAA2C;AAGjD,MAAM,iDAAA,GAAoD;AAG1D,MAAM,0CAAA,GAA6C;AAGnD,MAAM,2CAAA,GAA8C;AAGpD,MAAM,iCAAA,GAAoC;AAE1C,MAAM,qCAAA,GAAwC;AAE9C,MAAM,sCAAA,GAAyC;AAE/C,MAAM,oCAAA,GAAuC;AAE7C,MAAM,kCAAA,GAAqC;AAE3C,MAAM,qCAAA,GAAwC;AAE9C,MAAM,0CAAA,GAA6C;AAGnD,MAAM,0BAAA,GAA6B;AAEnC,MAAM,6BAAA,GAAgC;AAEtC,MAAM,kCAAA,GAAqC;AAE3C,MAAM,gCAAA,GAAmC;AASzC,MAAM,0CAAA,GAA6C;AAKnD,MAAM,6BAAA,GAAgC;AAEtC,MAAM,iCAAA,GAAoC;AAE1C,MAAM,4BAAA,GAA+B;AAErC,MAAM,4BAAA,GAA+B;AAErC,MAAM,kCAAA,GAAqC;AAG3C,MAAM,sCAAA,GAAyC;AAC/C,MAAM,2BAAA,GAA8B;AAYpC,MAAM,iCAAA,GAAoC;AAe1C,MAAM,gCAAA,GAAmC;;;;"} |
+11
-7
| export { registerSpanErrorInstrumentation } from './tracing/errors.js'; | ||
| export { getCapturedScopesOnSpan, markSpanForOtelSourceInference, setCapturedScopesOnSpan, spanShouldInferOtelSource } from './tracing/utils.js'; | ||
| export { getCapturedScopesOnSpan, markSpanAsTracerProviderSpan, markSpanForOtelSourceInference, markSpanSourceAsExplicit, setCapturedScopesOnSpan, spanIsTracerProviderSpan, spanShouldInferOtelSource, spanSourceWasExplicitlySet } from './tracing/utils.js'; | ||
| export { TRACING_DEFAULTS, startIdleSpan } from './tracing/idleSpan.js'; | ||
| export { SentrySpan } from './tracing/sentrySpan.js'; | ||
| export { _INTERNAL_setDeferSegmentSpanCapture } from './tracing/deferSegmentSpanCapture.js'; | ||
| export { SentryNonRecordingSpan } from './tracing/sentryNonRecordingSpan.js'; | ||
| export { SPAN_STATUS_ERROR, SPAN_STATUS_OK, SPAN_STATUS_UNSET, getSpanStatusFromHttpCode, setHttpStatus } from './tracing/spanstatus.js'; | ||
| export { SUPPRESS_TRACING_KEY, continueTrace, isTracingSuppressed, startInactiveSpan, startNewTrace, startSpan, startSpanManual, suppressTracing, withActiveSpan } from './tracing/trace.js'; | ||
| export { SUPPRESS_TRACING_KEY, _INTERNAL_startInactiveSpan, continueTrace, isTracingSuppressed, spanIsIgnored, startInactiveSpan, startNewTrace, startSpan, startSpanManual, suppressTracing, withActiveSpan } from './tracing/trace.js'; | ||
| export { bindScopeToEmitter } from './tracing/bindScopeToEmitter.js'; | ||
@@ -47,3 +48,3 @@ export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromScope, getDynamicSamplingContextFromSpan, spanToBaggageHeader } from './tracing/dynamicSamplingContext.js'; | ||
| export { addAutoIpAddressToSession, addAutoIpAddressToUser } from './utils/ipAddress.js'; | ||
| export { INTERNAL_getSegmentSpan, addChildSpanToSpan, convertSpanLinksForEnvelope, getActiveSpan, getRootSpan, getSpanDescendants, getStatusMessage, spanIsSampled, spanTimeInputToSeconds, spanToJSON, spanToStreamedSpanJSON, spanToTraceContext, spanToTraceHeader, updateSpanName } from './utils/spanUtils.js'; | ||
| export { INTERNAL_getSegmentSpan, addChildSpanToSpan, convertSpanLinksForEnvelope, getActiveSpan, getRootSpan, getSpanDescendants, getStatusMessage, spanIsSampled, spanIsSentrySpan, spanTimeInputToSeconds, spanToJSON, spanToStreamedSpanJSON, spanToTraceContext, spanToTraceHeader, updateSpanName } from './utils/spanUtils.js'; | ||
| export { _setSpanForScope as _INTERNAL_setSpanForScope } from './utils/spanOnScope.js'; | ||
@@ -90,9 +91,12 @@ export { parseSampleRate } from './utils/parseSampleRate.js'; | ||
| export { addVercelAiProcessors, getProviderMetadataAttributes } from './tracing/vercel-ai/index.js'; | ||
| export { getTruncatedJsonString, shouldEnableTruncation } from './tracing/ai/utils.js'; | ||
| export { GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE } from './tracing/ai/gen-ai-attributes.js'; | ||
| export { getTruncatedJsonString, resolveAIRecordingOptions, shouldEnableTruncation } from './tracing/ai/utils.js'; | ||
| export { GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE } from './tracing/ai/gen-ai-attributes.js'; | ||
| export { _INTERNAL_cleanupToolCallSpanContext, _INTERNAL_getSpanContextForToolCallId } from './tracing/vercel-ai/utils.js'; | ||
| export { toolCallSpanContextMap as _INTERNAL_toolCallSpanContextMap } from './tracing/vercel-ai/constants.js'; | ||
| export { instrumentOpenAiClient } from './tracing/openai/index.js'; | ||
| export { addRequestAttributes as addOpenAiRequestAttributes, extractRequestAttributes as extractOpenAiRequestAttributes, instrumentOpenAiClient } from './tracing/openai/index.js'; | ||
| export { addResponseAttributes as addOpenAiResponseAttributes, extractRequestParameters as extractOpenAiRequestParameters } from './tracing/openai/utils.js'; | ||
| export { instrumentStream as instrumentOpenAiStream } from './tracing/openai/streaming.js'; | ||
| export { OPENAI_INTEGRATION_NAME } from './tracing/openai/constants.js'; | ||
| export { instrumentAnthropicAiClient } from './tracing/anthropic-ai/index.js'; | ||
| export { addPrivateRequestAttributes as addAnthropicRequestAttributes, addResponseAttributes as addAnthropicResponseAttributes, extractRequestAttributes as extractAnthropicRequestAttributes, instrumentAnthropicAiClient } from './tracing/anthropic-ai/index.js'; | ||
| export { instrumentAsyncIterableStream, instrumentMessageStream } from './tracing/anthropic-ai/streaming.js'; | ||
| export { ANTHROPIC_AI_INTEGRATION_NAME } from './tracing/anthropic-ai/constants.js'; | ||
@@ -99,0 +103,0 @@ export { instrumentGoogleGenAIClient } from './tracing/google-genai/index.js'; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
@@ -5,4 +5,4 @@ import { captureException } from '../../exports.js'; | ||
| import { startSpan, startSpanManual } from '../trace.js'; | ||
| import { GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE, GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE, GEN_AI_REQUEST_TOP_P_ATTRIBUTE, GEN_AI_REQUEST_STREAM_ATTRIBUTE, GEN_AI_REQUEST_TOP_K_ATTRIBUTE, GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE, GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE, GEN_AI_PROMPT_ATTRIBUTE, GEN_AI_OPERATION_NAME_ATTRIBUTE, GEN_AI_SYSTEM_ATTRIBUTE, GEN_AI_RESPONSE_TEXT_ATTRIBUTE, GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE, GEN_AI_RESPONSE_MODEL_ATTRIBUTE, GEN_AI_RESPONSE_ID_ATTRIBUTE } from '../ai/gen-ai-attributes.js'; | ||
| import { resolveAIRecordingOptions, shouldEnableTruncation, wrapPromiseWithMethods, buildMethodPath, setTokenUsageAttributes } from '../ai/utils.js'; | ||
| import { GEN_AI_PROMPT_ATTRIBUTE, GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE, GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE, GEN_AI_REQUEST_TOP_P_ATTRIBUTE, GEN_AI_REQUEST_STREAM_ATTRIBUTE, GEN_AI_REQUEST_TOP_K_ATTRIBUTE, GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE, GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE, GEN_AI_RESPONSE_TEXT_ATTRIBUTE, GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE, GEN_AI_RESPONSE_MODEL_ATTRIBUTE, GEN_AI_RESPONSE_ID_ATTRIBUTE, GEN_AI_OPERATION_NAME_ATTRIBUTE, GEN_AI_SYSTEM_ATTRIBUTE } from '../ai/gen-ai-attributes.js'; | ||
| import { resolveAIRecordingOptions, setTokenUsageAttributes, shouldEnableTruncation, wrapPromiseWithMethods, buildMethodPath } from '../ai/utils.js'; | ||
| import { ANTHROPIC_METHOD_REGISTRY } from './constants.js'; | ||
@@ -240,3 +240,3 @@ import { instrumentAsyncIterableStream, instrumentMessageStream } from './streaming.js'; | ||
| export { instrumentAnthropicAiClient }; | ||
| export { addPrivateRequestAttributes, addResponseAttributes, extractRequestAttributes, instrumentAnthropicAiClient }; | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/anthropic-ai/index.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpan, startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types/span';\nimport {\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_PROMPT_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_REQUEST_STREAM_ATTRIBUTE,\n GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_K_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_P_ATTRIBUTE,\n GEN_AI_RESPONSE_ID_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_TEXT_ATTRIBUTE,\n GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { InstrumentedMethodEntry } from '../ai/utils';\nimport {\n buildMethodPath,\n resolveAIRecordingOptions,\n setTokenUsageAttributes,\n shouldEnableTruncation,\n wrapPromiseWithMethods,\n} from '../ai/utils';\nimport { ANTHROPIC_METHOD_REGISTRY } from './constants';\nimport { instrumentAsyncIterableStream, instrumentMessageStream } from './streaming';\nimport type { AnthropicAiOptions, AnthropicAiResponse, AnthropicAiStreamingEvent, ContentBlock } from './types';\nimport { handleResponseError, messagesFromParams, setMessagesAttribute } from './utils';\n\n/**\n * Extract request attributes from method arguments\n */\nfunction extractRequestAttributes(args: unknown[], methodPath: string, operationName: string): Record<string, unknown> {\n const attributes: Record<string, unknown> = {\n [GEN_AI_SYSTEM_ATTRIBUTE]: 'anthropic',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: operationName,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.anthropic',\n };\n\n if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null) {\n const params = args[0] as Record<string, unknown>;\n if (params.tools && Array.isArray(params.tools)) {\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = JSON.stringify(params.tools);\n }\n\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = params.model ?? 'unknown';\n if ('temperature' in params) attributes[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE] = params.temperature;\n if ('top_p' in params) attributes[GEN_AI_REQUEST_TOP_P_ATTRIBUTE] = params.top_p;\n if ('stream' in params) attributes[GEN_AI_REQUEST_STREAM_ATTRIBUTE] = params.stream;\n if ('top_k' in params) attributes[GEN_AI_REQUEST_TOP_K_ATTRIBUTE] = params.top_k;\n if ('frequency_penalty' in params)\n attributes[GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE] = params.frequency_penalty;\n if ('max_tokens' in params) attributes[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE] = params.max_tokens;\n } else {\n if (methodPath === 'models.retrieve' || methodPath === 'models.get') {\n // models.retrieve(model-id) and models.get(model-id)\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = args[0];\n } else {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = 'unknown';\n }\n }\n\n return attributes;\n}\n\n/**\n * Add private request attributes to spans.\n * This is only recorded if recordInputs is true.\n */\nfunction addPrivateRequestAttributes(span: Span, params: Record<string, unknown>, enableTruncation: boolean): void {\n const messages = messagesFromParams(params);\n setMessagesAttribute(span, messages, enableTruncation);\n\n if ('prompt' in params) {\n span.setAttributes({ [GEN_AI_PROMPT_ATTRIBUTE]: JSON.stringify(params.prompt) });\n }\n}\n\n/**\n * Add content attributes when recordOutputs is enabled\n */\nfunction addContentAttributes(span: Span, response: AnthropicAiResponse): void {\n // Messages.create\n if ('content' in response) {\n if (Array.isArray(response.content)) {\n span.setAttributes({\n [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: response.content\n .map((item: ContentBlock) => item.text)\n .filter(text => !!text)\n .join(''),\n });\n\n const toolCalls: Array<ContentBlock> = [];\n\n for (const item of response.content) {\n if (item.type === 'tool_use' || item.type === 'server_tool_use') {\n toolCalls.push(item);\n }\n }\n if (toolCalls.length > 0) {\n span.setAttributes({ [GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE]: JSON.stringify(toolCalls) });\n }\n }\n }\n // Completions.create\n if ('completion' in response) {\n span.setAttributes({ [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: response.completion });\n }\n // Models.countTokens\n if ('input_tokens' in response) {\n span.setAttributes({ [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: JSON.stringify(response.input_tokens) });\n }\n}\n\n/**\n * Add basic metadata attributes from the response\n */\nfunction addMetadataAttributes(span: Span, response: AnthropicAiResponse): void {\n if ('id' in response && 'model' in response) {\n span.setAttributes({\n [GEN_AI_RESPONSE_ID_ATTRIBUTE]: response.id,\n [GEN_AI_RESPONSE_MODEL_ATTRIBUTE]: response.model,\n });\n\n if ('usage' in response && response.usage) {\n setTokenUsageAttributes(\n span,\n response.usage.input_tokens,\n response.usage.output_tokens,\n response.usage.cache_creation_input_tokens,\n response.usage.cache_read_input_tokens,\n );\n }\n }\n}\n\n/**\n * Add response attributes to spans\n */\nfunction addResponseAttributes(span: Span, response: AnthropicAiResponse, recordOutputs?: boolean): void {\n if (!response || typeof response !== 'object') return;\n\n // capture error, do not add attributes if error (they shouldn't exist)\n if ('type' in response && response.type === 'error') {\n handleResponseError(span, response);\n return;\n }\n\n // Private response attributes that are only recorded if recordOutputs is true.\n if (recordOutputs) {\n addContentAttributes(span, response);\n }\n\n // Add basic metadata attributes\n addMetadataAttributes(span, response);\n}\n\n/**\n * Handle common error catching and reporting for streaming requests\n */\nfunction handleStreamingError(error: unknown, span: Span, methodPath: string): never {\n captureException(error, {\n mechanism: { handled: false, type: 'auto.ai.anthropic', data: { function: methodPath } },\n });\n\n if (span.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n span.end();\n }\n throw error;\n}\n\n/**\n * Handle streaming cases with common logic\n */\nfunction handleStreamingRequest<T extends unknown[], R>(\n originalMethod: (...args: T) => R | Promise<R>,\n target: (...args: T) => R | Promise<R>,\n context: unknown,\n args: T,\n requestAttributes: Record<string, unknown>,\n operationName: string,\n methodPath: string,\n params: Record<string, unknown> | undefined,\n options: AnthropicAiOptions,\n isStreamRequested: boolean,\n isStreamingMethod: boolean,\n): R | Promise<R> {\n const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? 'unknown';\n const spanConfig = {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n };\n\n // messages.stream() always returns a sync MessageStream, even with stream: true param\n if (isStreamRequested && !isStreamingMethod) {\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpanManual(spanConfig, (span: Span) => {\n originalResult = originalMethod.apply(context, args) as Promise<R>;\n\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n\n return (async () => {\n try {\n const result = await originalResult;\n return instrumentAsyncIterableStream(\n result as AsyncIterable<AnthropicAiStreamingEvent>,\n span,\n options.recordOutputs ?? false,\n ) as unknown as R;\n } catch (error) {\n return handleStreamingError(error, span, methodPath);\n }\n })();\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.anthropic');\n } else {\n return startSpanManual(spanConfig, span => {\n try {\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n const messageStream = target.apply(context, args);\n return instrumentMessageStream(messageStream, span, options.recordOutputs ?? false);\n } catch (error) {\n return handleStreamingError(error, span, methodPath);\n }\n });\n }\n}\n\n/**\n * Instrument a method with Sentry spans\n * Following Sentry AI Agents Manual Instrumentation conventions\n * @see https://docs.sentry.io/platforms/javascript/guides/node/tracing/instrumentation/ai-agents-module/#manual-instrumentation\n */\nfunction instrumentMethod<T extends unknown[], R>(\n originalMethod: (...args: T) => R | Promise<R>,\n methodPath: string,\n instrumentedMethod: InstrumentedMethodEntry,\n context: unknown,\n options: AnthropicAiOptions,\n): (...args: T) => R | Promise<R> {\n return new Proxy(originalMethod, {\n apply(target, thisArg, args: T): R | Promise<R> {\n const operationName = instrumentedMethod.operation || 'unknown';\n const requestAttributes = extractRequestAttributes(args, methodPath, operationName);\n const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? 'unknown';\n\n const params = typeof args[0] === 'object' ? (args[0] as Record<string, unknown>) : undefined;\n const isStreamRequested = Boolean(params?.stream);\n const isStreamingMethod = instrumentedMethod.streaming === true;\n\n if (isStreamRequested || isStreamingMethod) {\n return handleStreamingRequest(\n originalMethod,\n target,\n context,\n args,\n requestAttributes,\n operationName,\n methodPath,\n params,\n options,\n isStreamRequested,\n isStreamingMethod,\n );\n }\n\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpan(\n {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n },\n span => {\n originalResult = target.apply(context, args) as Promise<R>;\n\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n\n return originalResult.then(\n result => {\n addResponseAttributes(span, result as AnthropicAiResponse, options.recordOutputs);\n return result;\n },\n error => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic',\n data: {\n function: methodPath,\n },\n },\n });\n throw error;\n },\n );\n },\n );\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.anthropic');\n },\n }) as (...args: T) => R | Promise<R>;\n}\n\n/**\n * Create a deep proxy for Anthropic AI client instrumentation\n */\nfunction createDeepProxy<T extends object>(target: T, currentPath = '', options: AnthropicAiOptions): T {\n return new Proxy(target, {\n get(obj: object, prop: string): unknown {\n const value = (obj as Record<string, unknown>)[prop];\n const methodPath = buildMethodPath(currentPath, String(prop));\n\n const instrumentedMethod = ANTHROPIC_METHOD_REGISTRY[methodPath as keyof typeof ANTHROPIC_METHOD_REGISTRY];\n if (typeof value === 'function' && instrumentedMethod) {\n return instrumentMethod(\n value as (...args: unknown[]) => unknown | Promise<unknown>,\n methodPath,\n instrumentedMethod,\n obj,\n options,\n );\n }\n\n if (typeof value === 'function') {\n // Bind non-instrumented functions to preserve the original `this` context,\n return value.bind(obj);\n }\n\n if (value && typeof value === 'object') {\n return createDeepProxy(value, methodPath, options);\n }\n\n return value;\n },\n }) as T;\n}\n\n/**\n * Instrument an Anthropic AI client with Sentry tracing\n * Can be used across Node.js, Cloudflare Workers, and Vercel Edge\n *\n * @template T - The type of the client that extends object\n * @param client - The Anthropic AI client to instrument\n * @param options - Optional configuration for recording inputs and outputs\n * @returns The instrumented client with the same type as the input\n */\nexport function instrumentAnthropicAiClient<T extends object>(anthropicAiClient: T, options?: AnthropicAiOptions): T {\n return createDeepProxy(anthropicAiClient, '', resolveAIRecordingOptions(options));\n}\n"],"names":[],"mappings":";;;;;;;;;;AAsCA,SAAS,wBAAA,CAAyB,IAAA,EAAiB,UAAA,EAAoB,aAAA,EAAgD;AACrH,EAAA,MAAM,UAAA,GAAsC;AAAA,IAC1C,CAAC,uBAAuB,GAAG,WAAA;AAAA,IAC3B,CAAC,+BAA+B,GAAG,aAAA;AAAA,IACnC,CAAC,gCAAgC,GAAG;AAAA,GACtC;AAEA,EAAA,IAAI,IAAA,CAAK,MAAA,GAAS,CAAA,IAAK,OAAO,IAAA,CAAK,CAAC,CAAA,KAAM,QAAA,IAAY,IAAA,CAAK,CAAC,CAAA,KAAM,IAAA,EAAM;AACtE,IAAA,MAAM,MAAA,GAAS,KAAK,CAAC,CAAA;AACrB,IAAA,IAAI,OAAO,KAAA,IAAS,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO,KAAK,CAAA,EAAG;AAC/C,MAAA,UAAA,CAAW,wCAAwC,CAAA,GAAI,IAAA,CAAK,SAAA,CAAU,OAAO,KAAK,CAAA;AAAA,IACpF;AAEA,IAAA,UAAA,CAAW,8BAA8B,CAAA,GAAI,MAAA,CAAO,KAAA,IAAS,SAAA;AAC7D,IAAA,IAAI,aAAA,IAAiB,MAAA,EAAQ,UAAA,CAAW,oCAAoC,IAAI,MAAA,CAAO,WAAA;AACvF,IAAA,IAAI,OAAA,IAAW,MAAA,EAAQ,UAAA,CAAW,8BAA8B,IAAI,MAAA,CAAO,KAAA;AAC3E,IAAA,IAAI,QAAA,IAAY,MAAA,EAAQ,UAAA,CAAW,+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Q;AAAA,IACvB,GAAA,CAAI,KAAa,IAAA,EAAuB;AACtC,MAAA,MAAM,KAAA,GAAS,IAAgC,IAAI,CAAA;AACnD,MAAA,MAAM,UAAA,GAAa,eAAA,CAAgB,WAAA,EAAa,MAAA,CAAO,IAAI,CAAC,CAAA;AAE5D,MAAA,MAAM,kBAAA,GAAqB,0BAA0B,UAAoD,CAAA;AACzG,MAAA,IAAI,OAAO,KAAA,KAAU,UAAA,IAAc,kBAAA,EAAoB;AACrD,QAAA,OAAO,gBAAA;AAAA,UACL,KAAA;AAAA,UACA,UAAA;AAAA,UACA,kBAAA;AAAA,UACA,GAAA;AAAA,UACA;AAAA,SACF;AAAA,MACF;AAEA,MAAA,IAAI,OAAO,UAAU,UAAA,EAAY;AAE/B,QAAA,OAAO,KAAA,CAAM,KAAK,GAAG,CAAA;AAAA,MACvB;AAEA,MAAA,IAAI,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,EAAU;AACtC,QAAA,OAAO,eAAA,CAAgB,KAAA,EAAO,UAAA,EAAY,OAAO,CAAA;AAAA,MACnD;AAEA,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,GACD,CAAA;AACH;AAWO,SAAS,2BAAA,CAA8C,mBAAsB,OAAA,EAAiC;AACnH,EAAA,OAAO,eAAA,CAAgB,iBAAA,EAAmB,EAAA,EAAI,yBAAA,CAA0B,OAAO,CAAC,CAAA;AAClF;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/anthropic-ai/index.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpan, startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types/span';\nimport {\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_PROMPT_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE,\n GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_REQUEST_STREAM_ATTRIBUTE,\n GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_K_ATTRIBUTE,\n GEN_AI_REQUEST_TOP_P_ATTRIBUTE,\n GEN_AI_RESPONSE_ID_ATTRIBUTE,\n GEN_AI_RESPONSE_MODEL_ATTRIBUTE,\n GEN_AI_RESPONSE_TEXT_ATTRIBUTE,\n GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { InstrumentedMethodEntry } from '../ai/utils';\nimport {\n buildMethodPath,\n resolveAIRecordingOptions,\n setTokenUsageAttributes,\n shouldEnableTruncation,\n wrapPromiseWithMethods,\n} from '../ai/utils';\nimport { ANTHROPIC_METHOD_REGISTRY } from './constants';\nimport { instrumentAsyncIterableStream, instrumentMessageStream } from './streaming';\nimport type { AnthropicAiOptions, AnthropicAiResponse, AnthropicAiStreamingEvent, ContentBlock } from './types';\nimport { handleResponseError, messagesFromParams, setMessagesAttribute } from './utils';\n\n/**\n * Extract request attributes from method arguments\n */\nexport function extractRequestAttributes(\n args: unknown[],\n methodPath: string,\n operationName: string,\n): Record<string, unknown> {\n const attributes: Record<string, unknown> = {\n [GEN_AI_SYSTEM_ATTRIBUTE]: 'anthropic',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: operationName,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.anthropic',\n };\n\n if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null) {\n const params = args[0] as Record<string, unknown>;\n if (params.tools && Array.isArray(params.tools)) {\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = JSON.stringify(params.tools);\n }\n\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = params.model ?? 'unknown';\n if ('temperature' in params) attributes[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE] = params.temperature;\n if ('top_p' in params) attributes[GEN_AI_REQUEST_TOP_P_ATTRIBUTE] = params.top_p;\n if ('stream' in params) attributes[GEN_AI_REQUEST_STREAM_ATTRIBUTE] = params.stream;\n if ('top_k' in params) attributes[GEN_AI_REQUEST_TOP_K_ATTRIBUTE] = params.top_k;\n if ('frequency_penalty' in params)\n attributes[GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE] = params.frequency_penalty;\n if ('max_tokens' in params) attributes[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE] = params.max_tokens;\n } else {\n if (methodPath === 'models.retrieve' || methodPath === 'models.get') {\n // models.retrieve(model-id) and models.get(model-id)\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = args[0];\n } else {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = 'unknown';\n }\n }\n\n return attributes;\n}\n\n/**\n * Add private request attributes to spans.\n * This is only recorded if recordInputs is true.\n */\nexport function addPrivateRequestAttributes(\n span: Span,\n params: Record<string, unknown>,\n enableTruncation: boolean,\n): void {\n const messages = messagesFromParams(params);\n setMessagesAttribute(span, messages, enableTruncation);\n\n if ('prompt' in params) {\n span.setAttributes({ [GEN_AI_PROMPT_ATTRIBUTE]: JSON.stringify(params.prompt) });\n }\n}\n\n/**\n * Add content attributes when recordOutputs is enabled\n */\nfunction addContentAttributes(span: Span, response: AnthropicAiResponse): void {\n // Messages.create\n if ('content' in response) {\n if (Array.isArray(response.content)) {\n span.setAttributes({\n [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: response.content\n .map((item: ContentBlock) => item.text)\n .filter(text => !!text)\n .join(''),\n });\n\n const toolCalls: Array<ContentBlock> = [];\n\n for (const item of response.content) {\n if (item.type === 'tool_use' || item.type === 'server_tool_use') {\n toolCalls.push(item);\n }\n }\n if (toolCalls.length > 0) {\n span.setAttributes({ [GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE]: JSON.stringify(toolCalls) });\n }\n }\n }\n // Completions.create\n if ('completion' in response) {\n span.setAttributes({ [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: response.completion });\n }\n // Models.countTokens\n if ('input_tokens' in response) {\n span.setAttributes({ [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: JSON.stringify(response.input_tokens) });\n }\n}\n\n/**\n * Add basic metadata attributes from the response\n */\nfunction addMetadataAttributes(span: Span, response: AnthropicAiResponse): void {\n if ('id' in response && 'model' in response) {\n span.setAttributes({\n [GEN_AI_RESPONSE_ID_ATTRIBUTE]: response.id,\n [GEN_AI_RESPONSE_MODEL_ATTRIBUTE]: response.model,\n });\n\n if ('usage' in response && response.usage) {\n setTokenUsageAttributes(\n span,\n response.usage.input_tokens,\n response.usage.output_tokens,\n response.usage.cache_creation_input_tokens,\n response.usage.cache_read_input_tokens,\n );\n }\n }\n}\n\n/**\n * Add response attributes to spans\n */\nexport function addResponseAttributes(span: Span, response: AnthropicAiResponse, recordOutputs?: boolean): void {\n if (!response || typeof response !== 'object') return;\n\n // capture error, do not add attributes if error (they shouldn't exist)\n if ('type' in response && response.type === 'error') {\n handleResponseError(span, response);\n return;\n }\n\n // Private response attributes that are only recorded if recordOutputs is true.\n if (recordOutputs) {\n addContentAttributes(span, response);\n }\n\n // Add basic metadata attributes\n addMetadataAttributes(span, response);\n}\n\n/**\n * Handle common error catching and reporting for streaming requests\n */\nfunction handleStreamingError(error: unknown, span: Span, methodPath: string): never {\n captureException(error, {\n mechanism: { handled: false, type: 'auto.ai.anthropic', data: { function: methodPath } },\n });\n\n if (span.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n span.end();\n }\n throw error;\n}\n\n/**\n * Handle streaming cases with common logic\n */\nfunction handleStreamingRequest<T extends unknown[], R>(\n originalMethod: (...args: T) => R | Promise<R>,\n target: (...args: T) => R | Promise<R>,\n context: unknown,\n args: T,\n requestAttributes: Record<string, unknown>,\n operationName: string,\n methodPath: string,\n params: Record<string, unknown> | undefined,\n options: AnthropicAiOptions,\n isStreamRequested: boolean,\n isStreamingMethod: boolean,\n): R | Promise<R> {\n const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? 'unknown';\n const spanConfig = {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n };\n\n // messages.stream() always returns a sync MessageStream, even with stream: true param\n if (isStreamRequested && !isStreamingMethod) {\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpanManual(spanConfig, (span: Span) => {\n originalResult = originalMethod.apply(context, args) as Promise<R>;\n\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n\n return (async () => {\n try {\n const result = await originalResult;\n return instrumentAsyncIterableStream(\n result as AsyncIterable<AnthropicAiStreamingEvent>,\n span,\n options.recordOutputs ?? false,\n ) as unknown as R;\n } catch (error) {\n return handleStreamingError(error, span, methodPath);\n }\n })();\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.anthropic');\n } else {\n return startSpanManual(spanConfig, span => {\n try {\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n const messageStream = target.apply(context, args);\n return instrumentMessageStream(messageStream, span, options.recordOutputs ?? false);\n } catch (error) {\n return handleStreamingError(error, span, methodPath);\n }\n });\n }\n}\n\n/**\n * Instrument a method with Sentry spans\n * Following Sentry AI Agents Manual Instrumentation conventions\n * @see https://docs.sentry.io/platforms/javascript/guides/node/tracing/instrumentation/ai-agents-module/#manual-instrumentation\n */\nfunction instrumentMethod<T extends unknown[], R>(\n originalMethod: (...args: T) => R | Promise<R>,\n methodPath: string,\n instrumentedMethod: InstrumentedMethodEntry,\n context: unknown,\n options: AnthropicAiOptions,\n): (...args: T) => R | Promise<R> {\n return new Proxy(originalMethod, {\n apply(target, thisArg, args: T): R | Promise<R> {\n const operationName = instrumentedMethod.operation || 'unknown';\n const requestAttributes = extractRequestAttributes(args, methodPath, operationName);\n const model = requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] ?? 'unknown';\n\n const params = typeof args[0] === 'object' ? (args[0] as Record<string, unknown>) : undefined;\n const isStreamRequested = Boolean(params?.stream);\n const isStreamingMethod = instrumentedMethod.streaming === true;\n\n if (isStreamRequested || isStreamingMethod) {\n return handleStreamingRequest(\n originalMethod,\n target,\n context,\n args,\n requestAttributes,\n operationName,\n methodPath,\n params,\n options,\n isStreamRequested,\n isStreamingMethod,\n );\n }\n\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpan(\n {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n },\n span => {\n originalResult = target.apply(context, args) as Promise<R>;\n\n if (options.recordInputs && params) {\n addPrivateRequestAttributes(span, params, shouldEnableTruncation(options.enableTruncation));\n }\n\n return originalResult.then(\n result => {\n addResponseAttributes(span, result as AnthropicAiResponse, options.recordOutputs);\n return result;\n },\n error => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic',\n data: {\n function: methodPath,\n },\n },\n });\n throw error;\n },\n );\n },\n );\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.anthropic');\n },\n }) as (...args: T) => R | Promise<R>;\n}\n\n/**\n * Create a deep proxy for Anthropic AI client instrumentation\n */\nfunction createDeepProxy<T extends object>(target: T, currentPath = '', options: AnthropicAiOptions): T {\n return new Proxy(target, {\n get(obj: object, prop: string): unknown {\n const value = (obj as Record<string, unknown>)[prop];\n const methodPath = buildMethodPath(currentPath, String(prop));\n\n const instrumentedMethod = ANTHROPIC_METHOD_REGISTRY[methodPath as keyof typeof ANTHROPIC_METHOD_REGISTRY];\n if (typeof value === 'function' && instrumentedMethod) {\n return instrumentMethod(\n value as (...args: unknown[]) => unknown | Promise<unknown>,\n methodPath,\n instrumentedMethod,\n obj,\n options,\n );\n }\n\n if (typeof value === 'function') {\n // Bind non-instrumented functions to preserve the original `this` context,\n return value.bind(obj);\n }\n\n if (value && typeof value === 'object') {\n return createDeepProxy(value, methodPath, options);\n }\n\n return value;\n },\n }) as T;\n}\n\n/**\n * Instrument an Anthropic AI client with Sentry tracing\n * Can be used across Node.js, Cloudflare Workers, and Vercel Edge\n *\n * @template T - The type of the client that extends object\n * @param client - The Anthropic AI client to instrument\n * @param options - Optional configuration for recording inputs and outputs\n * @returns The instrumented client with the same type as the input\n */\nexport function instrumentAnthropicAiClient<T extends object>(anthropicAiClient: T, options?: AnthropicAiOptions): T {\n return createDeepProxy(anthropicAiClient, '', resolveAIRecordingOptions(options));\n}\n"],"names":[],"mappings":";;;;;;;;;;AAsCO,SAAS,wBAAA,CACd,IAAA,EACA,UAAA,EACA,aAAA,EACyB;AACzB,EAAA,MAAM,UAAA,GAAsC;AAAA,IAC1C,CAAC,uBAAuB,GAAG,WAAA;AAAA,IAC3B,CAAC,+BAA+B,GAAG,aAAA;AAAA,IACnC,CAAC,gCAAgC,GAAG;AAAA,GACtC;AAEA,EAAA,IAAI,IAAA,CAAK,MAAA,GAAS,CAAA,IAAK,OAAO,IAAA,CAAK,CAAC,CAAA,KAAM,QAAA,IAAY,IAAA,CAAK,CAAC,CAAA,KAAM,IAAA,EAAM;AACtE,IAAA,MAAM,MAAA,GAAS,KAAK,CAAC,CAAA;AACrB,IAAA,IAAI,OAAO,KAAA,IAAS,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO,KAAK,CAAA,EAAG;AAC/C,MAAA,UAAA,CAAW,wCAAwC,CAAA,GAAI,IAAA,CAAK,SAAA,CAAU,OAAO,KAAK,CAAA;AAAA,IACpF;AAEA,IAAA,UAAA,CAAW,8BAA8B,CAAA,GAAI,MAAA,CAAO,KAAA,IAAS,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AAAA,OACF;AAEA,MAAA,OAAO,sBAAA,CAAuB,cAAA,EAAgB,mBAAA,EAAqB,mBAAmB,CAAA;AAAA,IACxF;AAAA,GACD,CAAA;AACH;AAKA,SAAS,eAAA,CAAkC,MAAA,EAAW,WAAA,GAAc,EAAA,EAAI,OAAA,EAAgC;AACtG,EAAA,OAAO,IAAI,MAAM,MAAA,EAAQ;AAAA,IACvB,GAAA,CAAI,KAAa,IAAA,EAAuB;AACtC,MAAA,MAAM,KAAA,GAAS,IAAgC,IAAI,CAAA;AACnD,MAAA,MAAM,UAAA,GAAa,eAAA,CAAgB,WAAA,EAAa,MAAA,CAAO,IAAI,CAAC,CAAA;AAE5D,MAAA,MAAM,kBAAA,GAAqB,0BAA0B,UAAoD,CAAA;AACzG,MAAA,IAAI,OAAO,KAAA,KAAU,UAAA,IAAc,kBAAA,EAAoB;AACrD,QAAA,OAAO,gBAAA;AAAA,UACL,KAAA;AAAA,UACA,UAAA;AAAA,UACA,kBAAA;AAAA,UACA,GAAA;AAAA,UACA;AAAA,SACF;AAAA,MACF;AAEA,MAAA,IAAI,OAAO,UAAU,UAAA,EAAY;AAE/B,QAAA,OAAO,KAAA,CAAM,KAAK,GAAG,CAAA;AAAA,MACvB;AAEA,MAAA,IAAI,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,EAAU;AACtC,QAAA,OAAO,eAAA,CAAgB,KAAA,EAAO,UAAA,EAAY,OAAO,CAAA;AAAA,MACnD;AAEA,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,GACD,CAAA;AACH;AAWO,SAAS,2BAAA,CAA8C,mBAAsB,OAAA,EAAiC;AACnH,EAAA,OAAO,eAAA,CAAgB,iBAAA,EAAmB,EAAA,EAAI,yBAAA,CAA0B,OAAO,CAAC,CAAA;AAClF;;;;"} |
@@ -22,6 +22,9 @@ import { captureException } from '../../exports.js'; | ||
| function handleMessageMetadata(event, state) { | ||
| if (event.type === "message_delta" && event.usage) { | ||
| if ("output_tokens" in event.usage && typeof event.usage.output_tokens === "number") { | ||
| if (event.type === "message_delta") { | ||
| if (event.usage && typeof event.usage.output_tokens === "number") { | ||
| state.completionTokens = event.usage.output_tokens; | ||
| } | ||
| if (event.delta?.stop_reason) { | ||
| state.finishReasons.push(event.delta.stop_reason); | ||
| } | ||
| } | ||
@@ -32,3 +35,2 @@ if (event.message) { | ||
| if (message.model) state.responseModel = message.model; | ||
| if (message.stop_reason) state.finishReasons.push(message.stop_reason); | ||
| if (message.usage) { | ||
@@ -35,0 +37,0 @@ if (typeof message.usage.input_tokens === "number") state.promptTokens = message.usage.input_tokens; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"streaming.js","sources":["../../../../src/tracing/anthropic-ai/streaming.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport type { Span } from '../../types/span';\nimport { endStreamSpan } from '../ai/utils';\nimport type { AnthropicAiStreamingEvent } from './types';\nimport { mapAnthropicErrorToStatusMessage } from './utils';\n\n/**\n * State object used to accumulate information from a stream of Anthropic AI events.\n */\ninterface StreamingState {\n /** Collected response text fragments (for output recording). */\n responseTexts: string[];\n /** Reasons for finishing the response, as reported by the API. */\n finishReasons: string[];\n /** The response ID. */\n responseId: string;\n /** The model name. */\n responseModel: string;\n /** Number of prompt/input tokens used. */\n promptTokens: number | undefined;\n /** Number of completion/output tokens used. */\n completionTokens: number | undefined;\n /** Number of cache creation input tokens used. */\n cacheCreationInputTokens: number | undefined;\n /** Number of cache read input tokens used. */\n cacheReadInputTokens: number | undefined;\n /** Accumulated tool calls (finalized) */\n toolCalls: Array<Record<string, unknown>>;\n /** In-progress tool call blocks keyed by index */\n activeToolBlocks: Record<\n number,\n {\n id?: string;\n name?: string;\n inputJsonParts: string[];\n }\n >;\n}\n\n/**\n * Checks if an event is an error event\n * @param event - The event to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n * @param span - The span to update\n * @returns Whether an error occurred\n */\n\nfunction isErrorEvent(event: AnthropicAiStreamingEvent, span: Span): boolean {\n if ('type' in event && typeof event.type === 'string') {\n // If the event is an error, set the span status and capture the error\n // These error events are not rejected by the API by default, but are sent as metadata of the response\n if (event.type === 'error') {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: mapAnthropicErrorToStatusMessage(event.error?.type) });\n captureException(event.error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic.anthropic_error',\n },\n });\n return true;\n }\n }\n return false;\n}\n\n/**\n * Processes the message metadata of an event\n * @param event - The event to process\n * @param state - The state of the streaming process\n */\n\nfunction handleMessageMetadata(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n // The token counts shown in the usage field of the message_delta event are cumulative.\n // @see https://docs.anthropic.com/en/docs/build-with-claude/streaming#event-types\n if (event.type === 'message_delta' && event.usage) {\n if ('output_tokens' in event.usage && typeof event.usage.output_tokens === 'number') {\n state.completionTokens = event.usage.output_tokens;\n }\n }\n\n if (event.message) {\n const message = event.message;\n\n if (message.id) state.responseId = message.id;\n if (message.model) state.responseModel = message.model;\n if (message.stop_reason) state.finishReasons.push(message.stop_reason);\n\n if (message.usage) {\n if (typeof message.usage.input_tokens === 'number') state.promptTokens = message.usage.input_tokens;\n if (typeof message.usage.cache_creation_input_tokens === 'number')\n state.cacheCreationInputTokens = message.usage.cache_creation_input_tokens;\n if (typeof message.usage.cache_read_input_tokens === 'number')\n state.cacheReadInputTokens = message.usage.cache_read_input_tokens;\n }\n }\n}\n\n/**\n * Handle start of a content block (e.g., tool_use)\n */\nfunction handleContentBlockStart(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n if (event.type !== 'content_block_start' || typeof event.index !== 'number' || !event.content_block) return;\n if (event.content_block.type === 'tool_use' || event.content_block.type === 'server_tool_use') {\n state.activeToolBlocks[event.index] = {\n id: event.content_block.id,\n name: event.content_block.name,\n inputJsonParts: [],\n };\n }\n}\n\n/**\n * Handle deltas of a content block, including input_json_delta for tool_use\n */\nfunction handleContentBlockDelta(\n event: AnthropicAiStreamingEvent,\n state: StreamingState,\n recordOutputs: boolean,\n): void {\n if (event.type !== 'content_block_delta' || !event.delta) return;\n\n // Accumulate tool_use input JSON deltas only when we have an index and an active tool block\n if (\n typeof event.index === 'number' &&\n 'partial_json' in event.delta &&\n typeof event.delta.partial_json === 'string'\n ) {\n const active = state.activeToolBlocks[event.index];\n if (active) {\n active.inputJsonParts.push(event.delta.partial_json);\n }\n }\n\n // Accumulate streamed response text regardless of index\n if (recordOutputs && typeof event.delta.text === 'string') {\n state.responseTexts.push(event.delta.text);\n }\n}\n\n/**\n * Handle stop of a content block; finalize tool_use entries\n */\nfunction handleContentBlockStop(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n if (event.type !== 'content_block_stop' || typeof event.index !== 'number') return;\n\n const active = state.activeToolBlocks[event.index];\n if (!active) return;\n\n const raw = active.inputJsonParts.join('');\n let parsedInput: unknown;\n\n try {\n parsedInput = raw ? JSON.parse(raw) : {};\n } catch {\n parsedInput = { __unparsed: raw };\n }\n\n state.toolCalls.push({\n type: 'tool_use',\n id: active.id,\n name: active.name,\n input: parsedInput,\n });\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete state.activeToolBlocks[event.index];\n}\n\n/**\n * Processes an event\n * @param event - The event to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n * @param span - The span to update\n */\nfunction processEvent(\n event: AnthropicAiStreamingEvent,\n state: StreamingState,\n recordOutputs: boolean,\n span: Span,\n): void {\n if (!(event && typeof event === 'object')) {\n return;\n }\n\n const isError = isErrorEvent(event, span);\n if (isError) return;\n\n handleMessageMetadata(event, state);\n\n // Tool call events are sent via 3 separate events:\n // - content_block_start (start of the tool call)\n // - content_block_delta (delta aka input of the tool call)\n // - content_block_stop (end of the tool call)\n // We need to handle them all to capture the full tool call.\n handleContentBlockStart(event, state);\n handleContentBlockDelta(event, state, recordOutputs);\n handleContentBlockStop(event, state);\n}\n\n/**\n * Instruments an async iterable stream of Anthropic events, updates the span with\n * streaming attributes and (optionally) the aggregated output text, and yields\n * each event from the input stream unchanged.\n */\nexport async function* instrumentAsyncIterableStream(\n stream: AsyncIterable<AnthropicAiStreamingEvent>,\n span: Span,\n recordOutputs: boolean,\n): AsyncGenerator<AnthropicAiStreamingEvent, void, unknown> {\n const state: StreamingState = {\n responseTexts: [],\n finishReasons: [],\n responseId: '',\n responseModel: '',\n promptTokens: undefined,\n completionTokens: undefined,\n cacheCreationInputTokens: undefined,\n cacheReadInputTokens: undefined,\n toolCalls: [],\n activeToolBlocks: {},\n };\n\n try {\n for await (const event of stream) {\n processEvent(event, state, recordOutputs, span);\n yield event;\n }\n } finally {\n endStreamSpan(span, state, recordOutputs);\n }\n}\n\n/**\n * Instruments a MessageStream by registering event handlers and preserving the original stream API.\n */\nexport function instrumentMessageStream<R extends { on: (...args: unknown[]) => void }>(\n stream: R,\n span: Span,\n recordOutputs: boolean,\n): R {\n const state: StreamingState = {\n responseTexts: [],\n finishReasons: [],\n responseId: '',\n responseModel: '',\n promptTokens: undefined,\n completionTokens: undefined,\n cacheCreationInputTokens: undefined,\n cacheReadInputTokens: undefined,\n toolCalls: [],\n activeToolBlocks: {},\n };\n\n stream.on('streamEvent', (event: unknown) => {\n processEvent(event as AnthropicAiStreamingEvent, state, recordOutputs, span);\n });\n\n // The event fired when a message is done being streamed by the API. Corresponds to the message_stop SSE event.\n // @see https://github.com/anthropics/anthropic-sdk-typescript/blob/d3be31f5a4e6ebb4c0a2f65dbb8f381ae73a9166/helpers.md?plain=1#L42-L44\n stream.on('message', () => {\n endStreamSpan(span, state, recordOutputs);\n });\n\n stream.on('error', (error: unknown) => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic.stream_error',\n },\n });\n\n if (span.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n span.end();\n }\n });\n\n return stream;\n}\n"],"names":[],"mappings":";;;;;AAiDA,SAAS,YAAA,CAAa,OAAkC,IAAA,EAAqB;A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wBAAA,EAA0B,MAAA;AAAA,IAC1B,oBAAA,EAAsB,MAAA;AAAA,IACtB,WAAW,EAAC;AAAA,IACZ,kBAAkB;AAAC,GACrB;AAEA,EAAA,MAAA,CAAO,EAAA,CAAG,aAAA,EAAe,CAAC,KAAA,KAAmB;AAC3C,IAAA,YAAA,CAAa,KAAA,EAAoC,KAAA,EAAO,aAAA,EAAe,IAAI,CAAA;AAAA,EAC7E,CAAC,CAAA;AAID,EAAA,MAAA,CAAO,EAAA,CAAG,WAAW,MAAM;AACzB,IAAA,aAAA,CAAc,IAAA,EAAM,OAAO,aAAa,CAAA;AAAA,EAC1C,CAAC,CAAA;AAED,EAAA,MAAA,CAAO,EAAA,CAAG,OAAA,EAAS,CAAC,KAAA,KAAmB;AACrC,IAAA,gBAAA,CAAiB,KAAA,EAAO;AAAA,MACtB,SAAA,EAAW;AAAA,QACT,OAAA,EAAS,KAAA;AAAA,QACT,IAAA,EAAM;AAAA;AACR,KACD,CAAA;AAED,IAAA,IAAI,IAAA,CAAK,aAAY,EAAG;AACtB,MAAA,IAAA,CAAK,UAAU,EAAE,IAAA,EAAM,iBAAA,EAAmB,OAAA,EAAS,kBAAkB,CAAA;AACrE,MAAA,IAAA,CAAK,GAAA,EAAI;AAAA,IACX;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,MAAA;AACT;;;;"} | ||
| {"version":3,"file":"streaming.js","sources":["../../../../src/tracing/anthropic-ai/streaming.ts"],"sourcesContent":["import { captureException } from '../../exports';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport type { Span } from '../../types/span';\nimport { endStreamSpan } from '../ai/utils';\nimport type { AnthropicAiStreamingEvent } from './types';\nimport { mapAnthropicErrorToStatusMessage } from './utils';\n\n/**\n * State object used to accumulate information from a stream of Anthropic AI events.\n */\ninterface StreamingState {\n /** Collected response text fragments (for output recording). */\n responseTexts: string[];\n /** Reasons for finishing the response, as reported by the API. */\n finishReasons: string[];\n /** The response ID. */\n responseId: string;\n /** The model name. */\n responseModel: string;\n /** Number of prompt/input tokens used. */\n promptTokens: number | undefined;\n /** Number of completion/output tokens used. */\n completionTokens: number | undefined;\n /** Number of cache creation input tokens used. */\n cacheCreationInputTokens: number | undefined;\n /** Number of cache read input tokens used. */\n cacheReadInputTokens: number | undefined;\n /** Accumulated tool calls (finalized) */\n toolCalls: Array<Record<string, unknown>>;\n /** In-progress tool call blocks keyed by index */\n activeToolBlocks: Record<\n number,\n {\n id?: string;\n name?: string;\n inputJsonParts: string[];\n }\n >;\n}\n\n/**\n * Checks if an event is an error event\n * @param event - The event to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n * @param span - The span to update\n * @returns Whether an error occurred\n */\n\nfunction isErrorEvent(event: AnthropicAiStreamingEvent, span: Span): boolean {\n if ('type' in event && typeof event.type === 'string') {\n // If the event is an error, set the span status and capture the error\n // These error events are not rejected by the API by default, but are sent as metadata of the response\n if (event.type === 'error') {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: mapAnthropicErrorToStatusMessage(event.error?.type) });\n captureException(event.error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic.anthropic_error',\n },\n });\n return true;\n }\n }\n return false;\n}\n\n/**\n * Processes the message metadata of an event\n * @param event - The event to process\n * @param state - The state of the streaming process\n */\n\nfunction handleMessageMetadata(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n // Cumulative token counts and the final stop reason both arrive on the message_delta event.\n // @see https://docs.anthropic.com/en/docs/build-with-claude/streaming#event-types\n if (event.type === 'message_delta') {\n if (event.usage && typeof event.usage.output_tokens === 'number') {\n state.completionTokens = event.usage.output_tokens;\n }\n if (event.delta?.stop_reason) {\n state.finishReasons.push(event.delta.stop_reason);\n }\n }\n\n if (event.message) {\n const message = event.message;\n\n if (message.id) state.responseId = message.id;\n if (message.model) state.responseModel = message.model;\n\n if (message.usage) {\n if (typeof message.usage.input_tokens === 'number') state.promptTokens = message.usage.input_tokens;\n if (typeof message.usage.cache_creation_input_tokens === 'number')\n state.cacheCreationInputTokens = message.usage.cache_creation_input_tokens;\n if (typeof message.usage.cache_read_input_tokens === 'number')\n state.cacheReadInputTokens = message.usage.cache_read_input_tokens;\n }\n }\n}\n\n/**\n * Handle start of a content block (e.g., tool_use)\n */\nfunction handleContentBlockStart(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n if (event.type !== 'content_block_start' || typeof event.index !== 'number' || !event.content_block) return;\n if (event.content_block.type === 'tool_use' || event.content_block.type === 'server_tool_use') {\n state.activeToolBlocks[event.index] = {\n id: event.content_block.id,\n name: event.content_block.name,\n inputJsonParts: [],\n };\n }\n}\n\n/**\n * Handle deltas of a content block, including input_json_delta for tool_use\n */\nfunction handleContentBlockDelta(\n event: AnthropicAiStreamingEvent,\n state: StreamingState,\n recordOutputs: boolean,\n): void {\n if (event.type !== 'content_block_delta' || !event.delta) return;\n\n // Accumulate tool_use input JSON deltas only when we have an index and an active tool block\n if (\n typeof event.index === 'number' &&\n 'partial_json' in event.delta &&\n typeof event.delta.partial_json === 'string'\n ) {\n const active = state.activeToolBlocks[event.index];\n if (active) {\n active.inputJsonParts.push(event.delta.partial_json);\n }\n }\n\n // Accumulate streamed response text regardless of index\n if (recordOutputs && typeof event.delta.text === 'string') {\n state.responseTexts.push(event.delta.text);\n }\n}\n\n/**\n * Handle stop of a content block; finalize tool_use entries\n */\nfunction handleContentBlockStop(event: AnthropicAiStreamingEvent, state: StreamingState): void {\n if (event.type !== 'content_block_stop' || typeof event.index !== 'number') return;\n\n const active = state.activeToolBlocks[event.index];\n if (!active) return;\n\n const raw = active.inputJsonParts.join('');\n let parsedInput: unknown;\n\n try {\n parsedInput = raw ? JSON.parse(raw) : {};\n } catch {\n parsedInput = { __unparsed: raw };\n }\n\n state.toolCalls.push({\n type: 'tool_use',\n id: active.id,\n name: active.name,\n input: parsedInput,\n });\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete state.activeToolBlocks[event.index];\n}\n\n/**\n * Processes an event\n * @param event - The event to process\n * @param state - The state of the streaming process\n * @param recordOutputs - Whether to record outputs\n * @param span - The span to update\n */\nfunction processEvent(\n event: AnthropicAiStreamingEvent,\n state: StreamingState,\n recordOutputs: boolean,\n span: Span,\n): void {\n if (!(event && typeof event === 'object')) {\n return;\n }\n\n const isError = isErrorEvent(event, span);\n if (isError) return;\n\n handleMessageMetadata(event, state);\n\n // Tool call events are sent via 3 separate events:\n // - content_block_start (start of the tool call)\n // - content_block_delta (delta aka input of the tool call)\n // - content_block_stop (end of the tool call)\n // We need to handle them all to capture the full tool call.\n handleContentBlockStart(event, state);\n handleContentBlockDelta(event, state, recordOutputs);\n handleContentBlockStop(event, state);\n}\n\n/**\n * Instruments an async iterable stream of Anthropic events, updates the span with\n * streaming attributes and (optionally) the aggregated output text, and yields\n * each event from the input stream unchanged.\n */\nexport async function* instrumentAsyncIterableStream(\n stream: AsyncIterable<AnthropicAiStreamingEvent>,\n span: Span,\n recordOutputs: boolean,\n): AsyncGenerator<AnthropicAiStreamingEvent, void, unknown> {\n const state: StreamingState = {\n responseTexts: [],\n finishReasons: [],\n responseId: '',\n responseModel: '',\n promptTokens: undefined,\n completionTokens: undefined,\n cacheCreationInputTokens: undefined,\n cacheReadInputTokens: undefined,\n toolCalls: [],\n activeToolBlocks: {},\n };\n\n try {\n for await (const event of stream) {\n processEvent(event, state, recordOutputs, span);\n yield event;\n }\n } finally {\n endStreamSpan(span, state, recordOutputs);\n }\n}\n\n/**\n * Instruments a MessageStream by registering event handlers and preserving the original stream API.\n */\nexport function instrumentMessageStream<R extends { on: (...args: unknown[]) => void }>(\n stream: R,\n span: Span,\n recordOutputs: boolean,\n): R {\n const state: StreamingState = {\n responseTexts: [],\n finishReasons: [],\n responseId: '',\n responseModel: '',\n promptTokens: undefined,\n completionTokens: undefined,\n cacheCreationInputTokens: undefined,\n cacheReadInputTokens: undefined,\n toolCalls: [],\n activeToolBlocks: {},\n };\n\n stream.on('streamEvent', (event: unknown) => {\n processEvent(event as AnthropicAiStreamingEvent, state, recordOutputs, span);\n });\n\n // The event fired when a message is done being streamed by the API. Corresponds to the message_stop SSE event.\n // @see https://github.com/anthropics/anthropic-sdk-typescript/blob/d3be31f5a4e6ebb4c0a2f65dbb8f381ae73a9166/helpers.md?plain=1#L42-L44\n stream.on('message', () => {\n endStreamSpan(span, state, recordOutputs);\n });\n\n stream.on('error', (error: unknown) => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.anthropic.stream_error',\n },\n });\n\n if (span.isRecording()) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n span.end();\n }\n });\n\n return stream;\n}\n"],"names":[],"mappings":";;;;;AAiDA,SAAS,YAAA,CAAa,OAAkC,IAAA,EAAqB;AAC3E,EAAA,IAAI,MAAA,IAAU,KAAA,IAAS,OAAO,KAAA,CAAM,SAAS,QAAA,EAAU;AAGrD,IAAA,IAAI,KAAA,CAAM,SAAS,OAAA,EAAS;AAC1B,MAAA,IAAA,CAAK,SAAA,CAAU,EAAE,IAAA,EAAM,iBAAA,EAAmB,OAAA,EAAS,iCAAiC,KAAA,CAAM,KAAA,EAAO,IAAI,CAAA,EAAG,CAAA;AACxG,MAAA,gBAAA,CAAiB,MAAM,KAAA,EAAO;AAAA,QAC5B,SAAA,EAAW;AAAA,UACT,OAAA,EAAS,KAAA;AAAA,UACT,IAAA,EAAM;AAAA;AACR,OACD,CAAA;AACD,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT;AAQA,SAAS,qBAAA,CAAsB,OAAkC,KAAA,EAA6B;AAG5F,EAAA,IAAI,KAAA,CAAM,SAAS,eAAA,EAAiB;AAClC,IAAA,IAAI,MAAM,KAAA,IAAS,OAAO,KAAA,CAAM,KAAA,CAAM,kBAAkB,QAAA,EAAU;AAChE,MAAA,KAAA,CAAM,gBAAA,GAAmB,MAAM,KAAA,CAAM,aAAA;AAAA,IACvC;AACA,IAAA,IAAI,KAAA,CAAM,OAAO,WA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AI;AAAA,IACX;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,MAAA;AACT;;;;"} |
@@ -0,1 +1,2 @@ | ||
| import { SENTRY_SPAN_SOURCE } from '@sentry/conventions/attributes'; | ||
| import { DEFAULT_ENVIRONMENT } from '../constants.js'; | ||
@@ -66,3 +67,3 @@ import { getClient } from '../currentScopes.js'; | ||
| const dsc = getDynamicSamplingContextFromClient(span.spanContext().traceId, client); | ||
| const source = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] ?? rootSpanAttributes["sentry.span.source"]; | ||
| const source = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] ?? rootSpanAttributes[SENTRY_SPAN_SOURCE]; | ||
| const name = rootSpanJson.description; | ||
@@ -69,0 +70,0 @@ if (source !== "url" && name) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"dynamicSamplingContext.js","sources":["../../../src/tracing/dynamicSamplingContext.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { DEFAULT_ENVIRONMENT } from '../constants';\nimport { getClient } from '../currentScopes';\nimport type { Scope } from '../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { DynamicSamplingContext } from '../types/envelope';\nimport type { Span } from '../types/span';\nimport { baggageHeaderToDynamicSamplingContext, dynamicSamplingContextToSentryBaggageHeader } from '../utils/baggage';\nimport { extractOrgIdFromClient } from '../utils/dsn';\nimport { hasSpansEnabled } from '../utils/hasSpansEnabled';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { getRootSpan, spanIsSampled, spanToJSON } from '../utils/spanUtils';\nimport { spanIsNonRecordingSpan } from './sentryNonRecordingSpan';\nimport { getCapturedScopesOnSpan } from './utils';\n\n/**\n * If you change this value, also update the terser plugin config to\n * avoid minification of the object property!\n */\nconst FROZEN_DSC_FIELD = '_frozenDsc';\n\ntype SpanWithMaybeDsc = Span & {\n [FROZEN_DSC_FIELD]?: Partial<DynamicSamplingContext> | undefined;\n};\n\n/**\n * Freeze the given DSC on the given span.\n */\nexport function freezeDscOnSpan(span: Span, dsc: Partial<DynamicSamplingContext>): void {\n const spanWithMaybeDsc = span as SpanWithMaybeDsc;\n addNonEnumerableProperty(spanWithMaybeDsc, FROZEN_DSC_FIELD, dsc);\n}\n\n/**\n * Creates a dynamic sampling context from a client.\n *\n * Dispatches the `createDsc` lifecycle hook as a side effect.\n */\nexport function getDynamicSamplingContextFromClient(trace_id: string, client: Client): DynamicSamplingContext {\n const options = client.getOptions();\n\n const { publicKey: public_key } = client.getDsn() || {};\n\n // Instead of conditionally adding non-undefined values, we add them and then remove them if needed\n // otherwise, the order of baggage entries changes, which \"breaks\" a bunch of tests etc.\n const dsc: DynamicSamplingContext = {\n environment: options.environment || DEFAULT_ENVIRONMENT,\n release: options.release,\n public_key,\n trace_id,\n org_id: extractOrgIdFromClient(client),\n };\n\n client.emit('createDsc', dsc);\n\n return dsc;\n}\n\n/**\n * Get the dynamic sampling context for the currently active scopes.\n */\nexport function getDynamicSamplingContextFromScope(client: Client, scope: Scope): Partial<DynamicSamplingContext> {\n const propagationContext = scope.getPropagationContext();\n return propagationContext.dsc || getDynamicSamplingContextFromClient(propagationContext.traceId, client);\n}\n\n/**\n * Creates a dynamic sampling context from a span (and client and scope)\n *\n * @param span the span from which a few values like the root span name and sample rate are extracted.\n *\n * @returns a dynamic sampling context\n */\nexport function getDynamicSamplingContextFromSpan(span: Span): Readonly<Partial<DynamicSamplingContext>> {\n const client = getClient();\n if (!client) {\n return {};\n }\n\n const rootSpan = getRootSpan(span);\n const rootSpanJson = spanToJSON(rootSpan);\n const rootSpanAttributes = rootSpanJson.data;\n const traceState = rootSpan.spanContext().traceState;\n\n // The span sample rate that was locally applied to the root span should also always be applied to the DSC, even if the DSC is frozen.\n // This is so that the downstream traces/services can use parentSampleRate in their `tracesSampler` to make consistent sampling decisions across the entire trace.\n const rootSpanSampleRate =\n traceState?.get('sentry.sample_rate') ??\n rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE] ??\n rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE];\n\n function applyLocalSampleRateToDsc(dsc: Partial<DynamicSamplingContext>): Partial<DynamicSamplingContext> {\n if (typeof rootSpanSampleRate === 'number' || typeof rootSpanSampleRate === 'string') {\n dsc.sample_rate = `${rootSpanSampleRate}`;\n }\n return dsc;\n }\n\n // For core implementation, we freeze the DSC onto the span as a non-enumerable property\n const frozenDsc = (rootSpan as SpanWithMaybeDsc)[FROZEN_DSC_FIELD];\n if (frozenDsc) {\n return applyLocalSampleRateToDsc(frozenDsc);\n }\n\n // For a non-recording placeholder in Tracing without Performance (TwP) mode, the DSC is not\n // carried on the span; the scope is the source of truth. Resolve it from the span's captured\n // scope: continued traces keep the incoming DSC, new traces derive it from the client.\n //\n // We gate this on `!hasSpansEnabled()` so it mirrors the `sentry-trace` source in `getTraceData`:\n // with tracing enabled, a non-recording span (e.g. an `onlyIfParent` placeholder) keeps deriving\n // its DSC from the span/client so the baggage agrees with the `-0` decision that `spanToTraceHeader`\n // encodes for `sentry-trace`. Without this guard the two headers can disagree.\n //\n // We spread into a new object so applying the local sample rate can't mutate the scope's DSC.\n if (spanIsNonRecordingSpan(rootSpan) && !hasSpansEnabled(client.getOptions())) {\n const capturedScope = getCapturedScopesOnSpan(rootSpan).scope;\n if (capturedScope) {\n return applyLocalSampleRateToDsc({ ...getDynamicSamplingContextFromScope(client, capturedScope) });\n }\n }\n\n // For OpenTelemetry, we freeze the DSC on the trace state\n const traceStateDsc = traceState?.get('sentry.dsc');\n\n // If the span has a DSC, we want it to take precedence\n const dscOnTraceState = traceStateDsc && baggageHeaderToDynamicSamplingContext(traceStateDsc);\n\n if (dscOnTraceState) {\n return applyLocalSampleRateToDsc(dscOnTraceState);\n }\n\n // Else, we generate it from the span\n const dsc = getDynamicSamplingContextFromClient(span.spanContext().traceId, client);\n\n // We don't want to have a transaction name in the DSC if the source is \"url\" because URLs might contain PII\n // TODO(v11): Only read `SEMANTIC_ATTRIBUTE_SENTRY_SOURCE` again, once we renamed it to `sentry.span.source`\n const source = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] ?? rootSpanAttributes['sentry.span.source'];\n\n // after JSON conversion, txn.name becomes jsonSpan.description\n const name = rootSpanJson.description;\n if (source !== 'url' && name) {\n dsc.transaction = name;\n }\n\n // How can we even land here with hasSpansEnabled() returning false?\n // Otel creates a Non-recording span in Tracing Without Performance mode when handling incoming requests\n // So we end up with an active span that is not sampled (neither positively nor negatively)\n if (hasSpansEnabled()) {\n dsc.sampled = String(spanIsSampled(rootSpan));\n dsc.sample_rand =\n // In OTEL we store the sample rand on the trace state because we cannot access scopes for NonRecordingSpans\n // The Sentry OTEL SpanSampler takes care of writing the sample rand on the root span\n traceState?.get('sentry.sample_rand') ??\n // On all other platforms we can actually get the scopes from a root span (we use this as a fallback)\n getCapturedScopesOnSpan(rootSpan).scope?.getPropagationContext().sampleRand.toString();\n }\n\n applyLocalSampleRateToDsc(dsc);\n\n client.emit('createDsc', dsc, rootSpan);\n\n return dsc;\n}\n\n/**\n * Convert a Span to a baggage header.\n */\nexport function spanToBaggageHeader(span: Span): string | undefined {\n const dsc = getDynamicSamplingContextFromSpan(span);\n return dynamicSamplingContextToSentryBaggageHeader(dsc);\n}\n"],"names":["dsc"],"mappings":";;;;;;;;;;;AAuBA,MAAM,gBAAA,GAAmB,YAAA;AASlB,SAAS,eAAA,CAAgB,MAAY,GAAA,EAA4C;AACtF,EAAA,MAAM,gBAAA,GAAmB,IAAA;AACzB,EAAA,wBAAA,CAAyB,gBAAA,EAAkB,kBAAkB,GAAG,CAAA;AAClE;AAOO,SAAS,mCAAA,CAAoC,UAAkB,MAAA,EAA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A;AAAA,IAGF,UAAA,EAAY,IAAI,oBAAoB,CAAA;AAAA,IAEpC,wBAAwB,QAAQ,CAAA,CAAE,OAAO,qBAAA,EAAsB,CAAE,WAAW,QAAA,EAAS;AAAA,EACzF;AAEA,EAAA,yBAAA,CAA0B,GAAG,CAAA;AAE7B,EAAA,MAAA,CAAO,IAAA,CAAK,WAAA,EAAa,GAAA,EAAK,QAAQ,CAAA;AAEtC,EAAA,OAAO,GAAA;AACT;AAKO,SAAS,oBAAoB,IAAA,EAAgC;AAClE,EAAA,MAAM,GAAA,GAAM,kCAAkC,IAAI,CAAA;AAClD,EAAA,OAAO,4CAA4C,GAAG,CAAA;AACxD;;;;"} | ||
| {"version":3,"file":"dynamicSamplingContext.js","sources":["../../../src/tracing/dynamicSamplingContext.ts"],"sourcesContent":["import { SENTRY_SPAN_SOURCE } from '@sentry/conventions/attributes';\nimport type { Client } from '../client';\nimport { DEFAULT_ENVIRONMENT } from '../constants';\nimport { getClient } from '../currentScopes';\nimport type { Scope } from '../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { DynamicSamplingContext } from '../types/envelope';\nimport type { Span } from '../types/span';\nimport { baggageHeaderToDynamicSamplingContext, dynamicSamplingContextToSentryBaggageHeader } from '../utils/baggage';\nimport { extractOrgIdFromClient } from '../utils/dsn';\nimport { hasSpansEnabled } from '../utils/hasSpansEnabled';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { getRootSpan, spanIsSampled, spanToJSON } from '../utils/spanUtils';\nimport { spanIsNonRecordingSpan } from './sentryNonRecordingSpan';\nimport { getCapturedScopesOnSpan } from './utils';\n\n/**\n * If you change this value, also update the terser plugin config to\n * avoid minification of the object property!\n */\nconst FROZEN_DSC_FIELD = '_frozenDsc';\n\ntype SpanWithMaybeDsc = Span & {\n [FROZEN_DSC_FIELD]?: Partial<DynamicSamplingContext> | undefined;\n};\n\n/**\n * Freeze the given DSC on the given span.\n */\nexport function freezeDscOnSpan(span: Span, dsc: Partial<DynamicSamplingContext>): void {\n const spanWithMaybeDsc = span as SpanWithMaybeDsc;\n addNonEnumerableProperty(spanWithMaybeDsc, FROZEN_DSC_FIELD, dsc);\n}\n\n/**\n * Creates a dynamic sampling context from a client.\n *\n * Dispatches the `createDsc` lifecycle hook as a side effect.\n */\nexport function getDynamicSamplingContextFromClient(trace_id: string, client: Client): DynamicSamplingContext {\n const options = client.getOptions();\n\n const { publicKey: public_key } = client.getDsn() || {};\n\n // Instead of conditionally adding non-undefined values, we add them and then remove them if needed\n // otherwise, the order of baggage entries changes, which \"breaks\" a bunch of tests etc.\n const dsc: DynamicSamplingContext = {\n environment: options.environment || DEFAULT_ENVIRONMENT,\n release: options.release,\n public_key,\n trace_id,\n org_id: extractOrgIdFromClient(client),\n };\n\n client.emit('createDsc', dsc);\n\n return dsc;\n}\n\n/**\n * Get the dynamic sampling context for the currently active scopes.\n */\nexport function getDynamicSamplingContextFromScope(client: Client, scope: Scope): Partial<DynamicSamplingContext> {\n const propagationContext = scope.getPropagationContext();\n return propagationContext.dsc || getDynamicSamplingContextFromClient(propagationContext.traceId, client);\n}\n\n/**\n * Creates a dynamic sampling context from a span (and client and scope)\n *\n * @param span the span from which a few values like the root span name and sample rate are extracted.\n *\n * @returns a dynamic sampling context\n */\nexport function getDynamicSamplingContextFromSpan(span: Span): Readonly<Partial<DynamicSamplingContext>> {\n const client = getClient();\n if (!client) {\n return {};\n }\n\n const rootSpan = getRootSpan(span);\n const rootSpanJson = spanToJSON(rootSpan);\n const rootSpanAttributes = rootSpanJson.data;\n const traceState = rootSpan.spanContext().traceState;\n\n // The span sample rate that was locally applied to the root span should also always be applied to the DSC, even if the DSC is frozen.\n // This is so that the downstream traces/services can use parentSampleRate in their `tracesSampler` to make consistent sampling decisions across the entire trace.\n const rootSpanSampleRate =\n traceState?.get('sentry.sample_rate') ??\n rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE] ??\n rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE];\n\n function applyLocalSampleRateToDsc(dsc: Partial<DynamicSamplingContext>): Partial<DynamicSamplingContext> {\n if (typeof rootSpanSampleRate === 'number' || typeof rootSpanSampleRate === 'string') {\n dsc.sample_rate = `${rootSpanSampleRate}`;\n }\n return dsc;\n }\n\n // For core implementation, we freeze the DSC onto the span as a non-enumerable property\n const frozenDsc = (rootSpan as SpanWithMaybeDsc)[FROZEN_DSC_FIELD];\n if (frozenDsc) {\n return applyLocalSampleRateToDsc(frozenDsc);\n }\n\n // For a non-recording placeholder in Tracing without Performance (TwP) mode, the DSC is not\n // carried on the span; the scope is the source of truth. Resolve it from the span's captured\n // scope: continued traces keep the incoming DSC, new traces derive it from the client.\n //\n // We gate this on `!hasSpansEnabled()` so it mirrors the `sentry-trace` source in `getTraceData`:\n // with tracing enabled, a non-recording span (e.g. an `onlyIfParent` placeholder) keeps deriving\n // its DSC from the span/client so the baggage agrees with the `-0` decision that `spanToTraceHeader`\n // encodes for `sentry-trace`. Without this guard the two headers can disagree.\n //\n // We spread into a new object so applying the local sample rate can't mutate the scope's DSC.\n if (spanIsNonRecordingSpan(rootSpan) && !hasSpansEnabled(client.getOptions())) {\n const capturedScope = getCapturedScopesOnSpan(rootSpan).scope;\n if (capturedScope) {\n return applyLocalSampleRateToDsc({ ...getDynamicSamplingContextFromScope(client, capturedScope) });\n }\n }\n\n // For OpenTelemetry, we freeze the DSC on the trace state\n const traceStateDsc = traceState?.get('sentry.dsc');\n\n // If the span has a DSC, we want it to take precedence\n const dscOnTraceState = traceStateDsc && baggageHeaderToDynamicSamplingContext(traceStateDsc);\n\n if (dscOnTraceState) {\n return applyLocalSampleRateToDsc(dscOnTraceState);\n }\n\n // Else, we generate it from the span\n const dsc = getDynamicSamplingContextFromClient(span.spanContext().traceId, client);\n\n // We don't want to have a transaction name in the DSC if the source is \"url\" because URLs might contain PII\n // TODO(v11): Only read `SENTRY_SPAN_SOURCE` once we removed `SEMANTIC_ATTRIBUTE_SENTRY_SOURCE`\n const source = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] ?? rootSpanAttributes[SENTRY_SPAN_SOURCE];\n\n // after JSON conversion, txn.name becomes jsonSpan.description\n const name = rootSpanJson.description;\n if (source !== 'url' && name) {\n dsc.transaction = name;\n }\n\n // How can we even land here with hasSpansEnabled() returning false?\n // Otel creates a Non-recording span in Tracing Without Performance mode when handling incoming requests\n // So we end up with an active span that is not sampled (neither positively nor negatively)\n if (hasSpansEnabled()) {\n dsc.sampled = String(spanIsSampled(rootSpan));\n dsc.sample_rand =\n // In OTEL we store the sample rand on the trace state because we cannot access scopes for NonRecordingSpans\n // The Sentry OTEL SpanSampler takes care of writing the sample rand on the root span\n traceState?.get('sentry.sample_rand') ??\n // On all other platforms we can actually get the scopes from a root span (we use this as a fallback)\n getCapturedScopesOnSpan(rootSpan).scope?.getPropagationContext().sampleRand.toString();\n }\n\n applyLocalSampleRateToDsc(dsc);\n\n client.emit('createDsc', dsc, rootSpan);\n\n return dsc;\n}\n\n/**\n * Convert a Span to a baggage header.\n */\nexport function spanToBaggageHeader(span: Span): string | undefined {\n const dsc = getDynamicSamplingContextFromSpan(span);\n return dynamicSamplingContextToSentryBaggageHeader(dsc);\n}\n"],"names":["dsc"],"mappings":";;;;;;;;;;;;AAwBA,MAAM,gBAAA,GAAmB,YAAA;AASlB,SAAS,eAAA,CAAgB,MAAY,GAAA,EAA4C;AACtF,EAAA,MAAM,gBAAA,GAAmB,IAAA;AACzB,EAAA,wBAAA,CAAyB,gBAAA,EAAkB,kBAAkB,GAAG,CAAA;AAClE;AAOO,SAAS,mCAAA,CAAoC,UAAkB,MAAA,EAAwC;AAC5G,EAAA,MAAM,OAAA,GAAU,OAAO,UAAA,EAAW;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IAEpC,wBAAwB,QAAQ,CAAA,CAAE,OAAO,qBAAA,EAAsB,CAAE,WAAW,QAAA,EAAS;AAAA,EACzF;AAEA,EAAA,yBAAA,CAA0B,GAAG,CAAA;AAE7B,EAAA,MAAA,CAAO,IAAA,CAAK,WAAA,EAAa,GAAA,EAAK,QAAQ,CAAA;AAEtC,EAAA,OAAO,GAAA;AACT;AAKO,SAAS,oBAAoB,IAAA,EAAgC;AAClE,EAAA,MAAM,GAAA,GAAM,kCAAkC,IAAI,CAAA;AAClD,EAAA,OAAO,4CAA4C,GAAG,CAAA;AACxD;;;;"} |
@@ -7,7 +7,7 @@ import { DEBUG_BUILD } from '../../debug-build.js'; | ||
| import { startSpanManual, startSpan } from '../trace.js'; | ||
| import { GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE, GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, GEN_AI_INPUT_MESSAGES_ATTRIBUTE, GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, GEN_AI_OPERATION_NAME_ATTRIBUTE, GEN_AI_SYSTEM_ATTRIBUTE } from '../ai/gen-ai-attributes.js'; | ||
| import { resolveAIRecordingOptions, shouldEnableTruncation, wrapPromiseWithMethods, buildMethodPath, extractSystemInstructions, getTruncatedJsonString, getJsonString } from '../ai/utils.js'; | ||
| import { GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, GEN_AI_INPUT_MESSAGES_ATTRIBUTE, GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE, GEN_AI_OPERATION_NAME_ATTRIBUTE, GEN_AI_SYSTEM_ATTRIBUTE } from '../ai/gen-ai-attributes.js'; | ||
| import { extractSystemInstructions, getTruncatedJsonString, getJsonString, resolveAIRecordingOptions, shouldEnableTruncation, wrapPromiseWithMethods, buildMethodPath } from '../ai/utils.js'; | ||
| import { OPENAI_METHOD_REGISTRY } from './constants.js'; | ||
| import { instrumentStream } from './streaming.js'; | ||
| import { addResponseAttributes, extractRequestParameters } from './utils.js'; | ||
| import { extractRequestParameters, addResponseAttributes } from './utils.js'; | ||
@@ -181,3 +181,3 @@ function extractAvailableTools(params) { | ||
| export { instrumentOpenAiClient }; | ||
| export { addRequestAttributes, extractRequestAttributes, instrumentOpenAiClient }; | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/openai/index.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../../debug-build';\nimport { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpan, startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types/span';\nimport { debug } from '../../utils/debug-logger';\nimport {\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { InstrumentedMethodEntry } from '../ai/utils';\nimport {\n buildMethodPath,\n extractSystemInstructions,\n getJsonString,\n getTruncatedJsonString,\n resolveAIRecordingOptions,\n shouldEnableTruncation,\n wrapPromiseWithMethods,\n} from '../ai/utils';\nimport { OPENAI_METHOD_REGISTRY } from './constants';\nimport { instrumentStream } from './streaming';\nimport type { ChatCompletionChunk, OpenAiOptions, OpenAIStream, ResponseStreamingEvent } from './types';\nimport { addResponseAttributes, extractRequestParameters } from './utils';\n\n/**\n * Extract available tools from request parameters\n */\nfunction extractAvailableTools(params: Record<string, unknown>): string | undefined {\n const tools = Array.isArray(params.tools) ? params.tools : [];\n const hasWebSearchOptions = params.web_search_options && typeof params.web_search_options === 'object';\n const webSearchOptions = hasWebSearchOptions\n ? [{ type: 'web_search_options', ...(params.web_search_options as Record<string, unknown>) }]\n : [];\n\n const availableTools = [...tools, ...webSearchOptions];\n if (availableTools.length === 0) {\n return undefined;\n }\n\n try {\n return JSON.stringify(availableTools);\n } catch (error) {\n DEBUG_BUILD && debug.error('Failed to serialize OpenAI tools:', error);\n return undefined;\n }\n}\n\n/**\n * Extract request attributes from method arguments\n */\nfunction extractRequestAttributes(args: unknown[], operationName: string): Record<string, unknown> {\n const attributes: Record<string, unknown> = {\n [GEN_AI_SYSTEM_ATTRIBUTE]: 'openai',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: operationName,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.openai',\n };\n\n if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null) {\n const params = args[0] as Record<string, unknown>;\n\n const availableTools = extractAvailableTools(params);\n if (availableTools) {\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = availableTools;\n }\n\n Object.assign(attributes, extractRequestParameters(params));\n } else {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = 'unknown';\n }\n\n return attributes;\n}\n\n// Extract and record AI request inputs, if present. This is intentionally separate from response attributes.\nfunction addRequestAttributes(\n span: Span,\n params: Record<string, unknown>,\n operationName: string,\n enableTruncation: boolean,\n): void {\n // Store embeddings input on a separate attribute and do not truncate it\n if (operationName === 'embeddings' && 'input' in params) {\n const input = params.input;\n\n // No input provided\n if (input == null) {\n return;\n }\n\n // Empty input string\n if (typeof input === 'string' && input.length === 0) {\n return;\n }\n\n // Empty array input\n if (Array.isArray(input) && input.length === 0) {\n return;\n }\n\n // Store strings as-is, arrays/objects as JSON\n span.setAttribute(GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE, typeof input === 'string' ? input : JSON.stringify(input));\n return;\n }\n\n const src = 'input' in params ? params.input : 'messages' in params ? params.messages : undefined;\n\n if (!src) {\n return;\n }\n\n if (Array.isArray(src) && src.length === 0) {\n return;\n }\n\n const { systemInstructions, filteredMessages } = extractSystemInstructions(src);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n span.setAttribute(\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n enableTruncation ? getTruncatedJsonString(filteredMessages) : getJsonString(filteredMessages),\n );\n\n if (Array.isArray(filteredMessages)) {\n span.setAttribute(GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, filteredMessages.length);\n } else {\n span.setAttribute(GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, 1);\n }\n}\n\n/**\n * Instrument a method with Sentry spans\n * Following Sentry AI Agents Manual Instrumentation conventions\n * @see https://docs.sentry.io/platforms/javascript/guides/node/tracing/instrumentation/ai-agents-module/#manual-instrumentation\n */\nfunction instrumentMethod<T extends unknown[], R>(\n originalMethod: (...args: T) => Promise<R>,\n methodPath: string,\n instrumentedMethod: InstrumentedMethodEntry,\n context: unknown,\n options: OpenAiOptions,\n): (...args: T) => Promise<R> {\n return function instrumentedCall(...args: T): Promise<R> {\n const operationName = instrumentedMethod.operation || 'unknown';\n const requestAttributes = extractRequestAttributes(args, operationName);\n const model = (requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] as string) || 'unknown';\n\n const params = args[0] as Record<string, unknown> | undefined;\n const isStreamRequested = params && typeof params === 'object' && params.stream === true;\n\n const spanConfig = {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n };\n\n if (isStreamRequested) {\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpanManual(spanConfig, (span: Span) => {\n originalResult = originalMethod.apply(context, args);\n\n if (options.recordInputs && params) {\n addRequestAttributes(span, params, operationName, shouldEnableTruncation(options.enableTruncation));\n }\n\n // Return async processing\n return (async () => {\n try {\n const result = await originalResult;\n return instrumentStream(\n result as OpenAIStream<ChatCompletionChunk | ResponseStreamingEvent>,\n span,\n options.recordOutputs ?? false,\n ) as unknown as R;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.openai.stream',\n data: { function: methodPath },\n },\n });\n span.end();\n throw error;\n }\n })();\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.openai');\n }\n\n // Non-streaming\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpan(spanConfig, (span: Span) => {\n // Call synchronously to capture the promise\n originalResult = originalMethod.apply(context, args);\n\n if (options.recordInputs && params) {\n addRequestAttributes(span, params, operationName, shouldEnableTruncation(options.enableTruncation));\n }\n\n return originalResult.then(\n result => {\n addResponseAttributes(span, result, options.recordOutputs);\n return result;\n },\n error => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.openai',\n data: { function: methodPath },\n },\n });\n throw error;\n },\n );\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.openai');\n };\n}\n\n/**\n * Create a deep proxy for OpenAI client instrumentation\n */\nfunction createDeepProxy<T extends object>(target: T, currentPath = '', options: OpenAiOptions): T {\n return new Proxy(target, {\n get(obj: object, prop: string): unknown {\n const value = (obj as Record<string, unknown>)[prop];\n const methodPath = buildMethodPath(currentPath, String(prop));\n\n const instrumentedMethod = OPENAI_METHOD_REGISTRY[methodPath as keyof typeof OPENAI_METHOD_REGISTRY];\n if (typeof value === 'function' && instrumentedMethod) {\n return instrumentMethod(\n value as (...args: unknown[]) => Promise<unknown>,\n methodPath,\n instrumentedMethod,\n obj,\n options,\n );\n }\n\n if (typeof value === 'function') {\n // Bind non-instrumented functions to preserve the original `this` context,\n // which is required for accessing private class fields (e.g. #baseURL) in OpenAI SDK v5.\n return value.bind(obj);\n }\n\n if (value && typeof value === 'object') {\n return createDeepProxy(value, methodPath, options);\n }\n\n return value;\n },\n }) as T;\n}\n\n/**\n * Instrument an OpenAI client with Sentry tracing\n * Can be used across Node.js, Cloudflare Workers, and Vercel Edge\n */\nexport function instrumentOpenAiClient<T extends object>(client: T, options?: OpenAiOptions): T {\n return createDeepProxy(client, '', resolveAIRecordingOptions(options));\n}\n"],"names":["originalResult","instrumentedPromise"],"mappings":";;;;;;;;;;;;AAmCA,SAAS,sBAAsB,MAAA,EAAqD;AAClF,EAAA,MAAM,KAAA,GAAQ,MAAM,OAAA,CAAQ,MAAA,CAAO,KAAK,CAAA,GAAI,MAAA,CAAO,QAAQ,EAAC;AAC5D,EAAA,MAAM,mBAAA,GAAsB,MAAA,CAAO,kBAAA,IAAsB,OAAO,OAAO,kBAAA,KAAuB,QAAA;AAC9F,EAAA,MAAM,gBAAA,GAAmB,mBAAA,GACrB,CAAC,EAAE,IAAA,EAAM,oBAAA,EAAsB,GAAI,MAAA,CAAO,kBAAA,EAAgD,CAAA,GAC1F,EAAC;AAEL,EAAA,MAAM,cAAA,GAAiB,CAAC,GAAG,KAAA,EAAO,GAAG,gBAAgB,CAAA;AACrD,EAAA,IAAI,cAAA,CAAe,WAAW,CAAA,EAAG;AAC/B,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,IAAI;AACF,IAAA,OAAO,IAAA,CAAK,UAAU,cAAc,CAAA;AAAA,EACtC,SAAS,KAAA,EAAO;AACd,IAAA,WAAA,IAAe,KAAA,CAAM,KAAA,CAAM,mCAAA,EAAqC,KAAK,CAAA;AACrE,IA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EAAA,EAAI,OAAA,EAA2B;AACjG,EAAA,OAAO,IAAI,MAAM,MAAA,EAAQ;AAAA,IACvB,GAAA,CAAI,KAAa,IAAA,EAAuB;AACtC,MAAA,MAAM,KAAA,GAAS,IAAgC,IAAI,CAAA;AACnD,MAAA,MAAM,UAAA,GAAa,eAAA,CAAgB,WAAA,EAAa,MAAA,CAAO,IAAI,CAAC,CAAA;AAE5D,MAAA,MAAM,kBAAA,GAAqB,uBAAuB,UAAiD,CAAA;AACnG,MAAA,IAAI,OAAO,KAAA,KAAU,UAAA,IAAc,kBAAA,EAAoB;AACrD,QAAA,OAAO,gBAAA;AAAA,UACL,KAAA;AAAA,UACA,UAAA;AAAA,UACA,kBAAA;AAAA,UACA,GAAA;AAAA,UACA;AAAA,SACF;AAAA,MACF;AAEA,MAAA,IAAI,OAAO,UAAU,UAAA,EAAY;AAG/B,QAAA,OAAO,KAAA,CAAM,KAAK,GAAG,CAAA;AAAA,MACvB;AAEA,MAAA,IAAI,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,EAAU;AACtC,QAAA,OAAO,eAAA,CAAgB,KAAA,EAAO,UAAA,EAAY,OAAO,CAAA;AAAA,MACnD;AAEA,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,GACD,CAAA;AACH;AAMO,SAAS,sBAAA,CAAyC,QAAW,OAAA,EAA4B;AAC9F,EAAA,OAAO,eAAA,CAAgB,MAAA,EAAQ,EAAA,EAAI,yBAAA,CAA0B,OAAO,CAAC,CAAA;AACvE;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../src/tracing/openai/index.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../../debug-build';\nimport { captureException } from '../../exports';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR } from '../../tracing';\nimport { startSpan, startSpanManual } from '../../tracing/trace';\nimport type { Span, SpanAttributeValue } from '../../types/span';\nimport { debug } from '../../utils/debug-logger';\nimport {\n GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,\n GEN_AI_OPERATION_NAME_ATTRIBUTE,\n GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n GEN_AI_SYSTEM_ATTRIBUTE,\n GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE,\n} from '../ai/gen-ai-attributes';\nimport type { InstrumentedMethodEntry } from '../ai/utils';\nimport {\n buildMethodPath,\n extractSystemInstructions,\n getJsonString,\n getTruncatedJsonString,\n resolveAIRecordingOptions,\n shouldEnableTruncation,\n wrapPromiseWithMethods,\n} from '../ai/utils';\nimport { OPENAI_METHOD_REGISTRY } from './constants';\nimport { instrumentStream } from './streaming';\nimport type { ChatCompletionChunk, OpenAiOptions, OpenAIStream, ResponseStreamingEvent } from './types';\nimport { addResponseAttributes, extractRequestParameters } from './utils';\n\n/**\n * Extract available tools from request parameters\n */\nfunction extractAvailableTools(params: Record<string, unknown>): string | undefined {\n const tools = Array.isArray(params.tools) ? params.tools : [];\n const hasWebSearchOptions = params.web_search_options && typeof params.web_search_options === 'object';\n const webSearchOptions = hasWebSearchOptions\n ? [{ type: 'web_search_options', ...(params.web_search_options as Record<string, unknown>) }]\n : [];\n\n const availableTools = [...tools, ...webSearchOptions];\n if (availableTools.length === 0) {\n return undefined;\n }\n\n try {\n return JSON.stringify(availableTools);\n } catch (error) {\n DEBUG_BUILD && debug.error('Failed to serialize OpenAI tools:', error);\n return undefined;\n }\n}\n\n/**\n * Extract request attributes from method arguments\n */\nexport function extractRequestAttributes(args: unknown[], operationName: string): Record<string, unknown> {\n const attributes: Record<string, unknown> = {\n [GEN_AI_SYSTEM_ATTRIBUTE]: 'openai',\n [GEN_AI_OPERATION_NAME_ATTRIBUTE]: operationName,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.openai',\n };\n\n if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null) {\n const params = args[0] as Record<string, unknown>;\n\n const availableTools = extractAvailableTools(params);\n if (availableTools) {\n attributes[GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE] = availableTools;\n }\n\n Object.assign(attributes, extractRequestParameters(params));\n } else {\n attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] = 'unknown';\n }\n\n return attributes;\n}\n\n// Extract and record AI request inputs, if present. This is intentionally separate from response attributes.\nexport function addRequestAttributes(\n span: Span,\n params: Record<string, unknown>,\n operationName: string,\n enableTruncation: boolean,\n): void {\n // Store embeddings input on a separate attribute and do not truncate it\n if (operationName === 'embeddings' && 'input' in params) {\n const input = params.input;\n\n // No input provided\n if (input == null) {\n return;\n }\n\n // Empty input string\n if (typeof input === 'string' && input.length === 0) {\n return;\n }\n\n // Empty array input\n if (Array.isArray(input) && input.length === 0) {\n return;\n }\n\n // Store strings as-is, arrays/objects as JSON\n span.setAttribute(GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE, typeof input === 'string' ? input : JSON.stringify(input));\n return;\n }\n\n const src = 'input' in params ? params.input : 'messages' in params ? params.messages : undefined;\n\n if (!src) {\n return;\n }\n\n if (Array.isArray(src) && src.length === 0) {\n return;\n }\n\n const { systemInstructions, filteredMessages } = extractSystemInstructions(src);\n\n if (systemInstructions) {\n span.setAttribute(GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, systemInstructions);\n }\n\n span.setAttribute(\n GEN_AI_INPUT_MESSAGES_ATTRIBUTE,\n enableTruncation ? getTruncatedJsonString(filteredMessages) : getJsonString(filteredMessages),\n );\n\n if (Array.isArray(filteredMessages)) {\n span.setAttribute(GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, filteredMessages.length);\n } else {\n span.setAttribute(GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, 1);\n }\n}\n\n/**\n * Instrument a method with Sentry spans\n * Following Sentry AI Agents Manual Instrumentation conventions\n * @see https://docs.sentry.io/platforms/javascript/guides/node/tracing/instrumentation/ai-agents-module/#manual-instrumentation\n */\nfunction instrumentMethod<T extends unknown[], R>(\n originalMethod: (...args: T) => Promise<R>,\n methodPath: string,\n instrumentedMethod: InstrumentedMethodEntry,\n context: unknown,\n options: OpenAiOptions,\n): (...args: T) => Promise<R> {\n return function instrumentedCall(...args: T): Promise<R> {\n const operationName = instrumentedMethod.operation || 'unknown';\n const requestAttributes = extractRequestAttributes(args, operationName);\n const model = (requestAttributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] as string) || 'unknown';\n\n const params = args[0] as Record<string, unknown> | undefined;\n const isStreamRequested = params && typeof params === 'object' && params.stream === true;\n\n const spanConfig = {\n name: `${operationName} ${model}`,\n op: `gen_ai.${operationName}`,\n attributes: requestAttributes as Record<string, SpanAttributeValue>,\n };\n\n if (isStreamRequested) {\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpanManual(spanConfig, (span: Span) => {\n originalResult = originalMethod.apply(context, args);\n\n if (options.recordInputs && params) {\n addRequestAttributes(span, params, operationName, shouldEnableTruncation(options.enableTruncation));\n }\n\n // Return async processing\n return (async () => {\n try {\n const result = await originalResult;\n return instrumentStream(\n result as OpenAIStream<ChatCompletionChunk | ResponseStreamingEvent>,\n span,\n options.recordOutputs ?? false,\n ) as unknown as R;\n } catch (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.openai.stream',\n data: { function: methodPath },\n },\n });\n span.end();\n throw error;\n }\n })();\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.openai');\n }\n\n // Non-streaming\n let originalResult!: Promise<R>;\n\n const instrumentedPromise = startSpan(spanConfig, (span: Span) => {\n // Call synchronously to capture the promise\n originalResult = originalMethod.apply(context, args);\n\n if (options.recordInputs && params) {\n addRequestAttributes(span, params, operationName, shouldEnableTruncation(options.enableTruncation));\n }\n\n return originalResult.then(\n result => {\n addResponseAttributes(span, result, options.recordOutputs);\n return result;\n },\n error => {\n captureException(error, {\n mechanism: {\n handled: false,\n type: 'auto.ai.openai',\n data: { function: methodPath },\n },\n });\n throw error;\n },\n );\n });\n\n return wrapPromiseWithMethods(originalResult, instrumentedPromise, 'auto.ai.openai');\n };\n}\n\n/**\n * Create a deep proxy for OpenAI client instrumentation\n */\nfunction createDeepProxy<T extends object>(target: T, currentPath = '', options: OpenAiOptions): T {\n return new Proxy(target, {\n get(obj: object, prop: string): unknown {\n const value = (obj as Record<string, unknown>)[prop];\n const methodPath = buildMethodPath(currentPath, String(prop));\n\n const instrumentedMethod = OPENAI_METHOD_REGISTRY[methodPath as keyof typeof OPENAI_METHOD_REGISTRY];\n if (typeof value === 'function' && instrumentedMethod) {\n return instrumentMethod(\n value as (...args: unknown[]) => Promise<unknown>,\n methodPath,\n instrumentedMethod,\n obj,\n options,\n );\n }\n\n if (typeof value === 'function') {\n // Bind non-instrumented functions to preserve the original `this` context,\n // which is required for accessing private class fields (e.g. #baseURL) in OpenAI SDK v5.\n return value.bind(obj);\n }\n\n if (value && typeof value === 'object') {\n return createDeepProxy(value, methodPath, options);\n }\n\n return value;\n },\n }) as T;\n}\n\n/**\n * Instrument an OpenAI client with Sentry tracing\n * Can be used across Node.js, Cloudflare Workers, and Vercel Edge\n */\nexport function instrumentOpenAiClient<T extends object>(client: T, options?: OpenAiOptions): T {\n return createDeepProxy(client, '', resolveAIRecordingOptions(options));\n}\n"],"names":["originalResult","instrumentedPromise"],"mappings":";;;;;;;;;;;;AAmCA,SAAS,sBAAsB,MAAA,EAAqD;AAClF,EAAA,MAAM,KAAA,GAAQ,MAAM,OAAA,CAAQ,MAAA,CAAO,KAAK,CAAA,GAAI,MAAA,CAAO,QAAQ,EAAC;AAC5D,EAAA,MAAM,mBAAA,GAAsB,MAAA,CAAO,kBAA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CAAA;AAAA,MACnD;AAEA,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,GACD,CAAA;AACH;AAMO,SAAS,sBAAA,CAAyC,QAAW,OAAA,EAA4B;AAC9F,EAAA,OAAO,eAAA,CAAgB,MAAA,EAAQ,EAAA,EAAI,yBAAA,CAA0B,OAAO,CAAC,CAAA;AACvE;;;;"} |
@@ -12,4 +12,5 @@ import { getClient, getCurrentScope } from '../currentScopes.js'; | ||
| import { timedEventsToMeasurements } from './measurement.js'; | ||
| import { getSegmentSpanCaptureStrategy } from './segmentSpanCaptureStrategy.js'; | ||
| import { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled.js'; | ||
| import { spanShouldInferOtelSource, getCapturedScopesOnSpan } from './utils.js'; | ||
| import { spanShouldInferOtelSource, markSpanSourceAsExplicit, spanIsTracerProviderSpan, getCapturedScopesOnSpan } from './utils.js'; | ||
@@ -54,2 +55,5 @@ const MAX_SPAN_COUNT = 1e3; | ||
| addLink(link) { | ||
| if (this._frozen) { | ||
| return this; | ||
| } | ||
| if (this._links) { | ||
@@ -64,2 +68,5 @@ this._links.push(link); | ||
| addLinks(links) { | ||
| if (this._frozen) { | ||
| return this; | ||
| } | ||
| if (this._links) { | ||
@@ -92,2 +99,5 @@ this._links.push(...links); | ||
| setAttribute(key, value) { | ||
| if (this._frozen) { | ||
| return this; | ||
| } | ||
| if (value === void 0) { | ||
@@ -98,2 +108,5 @@ delete this._attributes[key]; | ||
| } | ||
| if (key === SEMANTIC_ATTRIBUTE_SENTRY_SOURCE && value !== void 0 && spanShouldInferOtelSource(this)) { | ||
| markSpanSourceAsExplicit(this); | ||
| } | ||
| return this; | ||
@@ -115,2 +128,5 @@ } | ||
| updateStartTime(timeInput) { | ||
| if (this._frozen) { | ||
| return; | ||
| } | ||
| this._startTime = spanTimeInputToSeconds(timeInput); | ||
@@ -122,2 +138,5 @@ } | ||
| setStatus(value) { | ||
| if (this._frozen) { | ||
| return this; | ||
| } | ||
| this._status = value; | ||
@@ -130,2 +149,5 @@ return this; | ||
| updateName(name) { | ||
| if (this._frozen) { | ||
| return this; | ||
| } | ||
| this._name = name; | ||
@@ -140,2 +162,3 @@ if (!spanShouldInferOtelSource(this)) { | ||
| if (this._endTime) { | ||
| this._frozen = spanIsTracerProviderSpan(this); | ||
| return; | ||
@@ -146,2 +169,3 @@ } | ||
| this._onSpanEnded(); | ||
| this._frozen = spanIsTracerProviderSpan(this); | ||
| } | ||
@@ -207,2 +231,5 @@ /** | ||
| addEvent(name, attributesOrStartTime, startTime) { | ||
| if (this._frozen) { | ||
| return this; | ||
| } | ||
| DEBUG_BUILD && debug.log("[Tracing] Adding an event to span:", name); | ||
@@ -239,6 +266,4 @@ const time = isSpanTimeInput(attributesOrStartTime) ? attributesOrStartTime : startTime || timestampInSeconds(); | ||
| } | ||
| const isSegmentSpan = this._isStandaloneSpan || this === getRootSpan(this); | ||
| if (!isSegmentSpan) { | ||
| return; | ||
| } | ||
| const rootSpan = getRootSpan(this); | ||
| const isSegmentSpan = this._isStandaloneSpan || this === rootSpan; | ||
| if (this._isStandaloneSpan) { | ||
@@ -254,10 +279,24 @@ if (this._sampled) { | ||
| return; | ||
| } else if (client && hasSpanStreamingEnabled(client)) { | ||
| } | ||
| if (!isSegmentSpan) { | ||
| const strategy2 = getSegmentSpanCaptureStrategy(); | ||
| if (strategy2) { | ||
| const scope2 = getCapturedScopesOnSpan(this).scope || getCurrentScope(); | ||
| strategy2.onChildSpanEnded(this, rootSpan, (options) => this._convertSpanToTransaction(options), scope2); | ||
| } | ||
| return; | ||
| } | ||
| if (client && hasSpanStreamingEnabled(client)) { | ||
| client.emit("afterSegmentSpanEnd", this); | ||
| return; | ||
| } | ||
| const transactionEvent = this._convertSpanToTransaction(); | ||
| if (transactionEvent) { | ||
| const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope(); | ||
| scope.captureEvent(transactionEvent); | ||
| const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope(); | ||
| const strategy = getSegmentSpanCaptureStrategy(); | ||
| if (strategy) { | ||
| strategy.onSegmentSpanEnded((options) => this._convertSpanToTransaction(options), scope); | ||
| } else { | ||
| const transactionEvent = this._convertSpanToTransaction(); | ||
| if (transactionEvent) { | ||
| scope.captureEvent(transactionEvent); | ||
| } | ||
| } | ||
@@ -268,3 +307,3 @@ } | ||
| */ | ||
| _convertSpanToTransaction() { | ||
| _convertSpanToTransaction(options = {}) { | ||
| if (!isFullFinishedSpan(spanToJSON(this))) { | ||
@@ -282,4 +321,15 @@ return void 0; | ||
| } | ||
| const finishedSpans = getSpanDescendants(this).filter((span) => span !== this && !isStandaloneSpan(span)); | ||
| const spans = finishedSpans.map((span) => spanToJSON(span)).filter(isFullFinishedSpan); | ||
| options.onSpanCaptured?.(this); | ||
| const spans = []; | ||
| for (const descendant of getSpanDescendants(this)) { | ||
| if (descendant === this || isStandaloneSpan(descendant) || options.isSpanAlreadyCaptured?.(descendant)) { | ||
| continue; | ||
| } | ||
| const spanJSON = spanToJSON(descendant); | ||
| if (!isFullFinishedSpan(spanJSON)) { | ||
| continue; | ||
| } | ||
| options.onSpanCaptured?.(descendant); | ||
| spans.push(spanJSON); | ||
| } | ||
| const source = this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]; | ||
@@ -286,0 +336,0 @@ delete this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"sentrySpan.js","sources":["../../../src/tracing/sentrySpan.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { getClient, getCurrentScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { createSpanEnvelope } from '../envelope';\nimport {\n SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,\n SEMANTIC_ATTRIBUTE_PROFILE_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { SpanEnvelope } from '../types/envelope';\nimport type { TransactionEvent } from '../types/event';\nimport type { SpanLink } from '../types/link';\nimport type {\n SentrySpanArguments,\n Span,\n SpanAttributes,\n SpanAttributeValue,\n SpanContextData,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types/span';\nimport type { SpanStatus } from '../types/spanStatus';\nimport type { TimedEvent } from '../types/timedEvent';\nimport { debug } from '../utils/debug-logger';\nimport { generateSpanId, generateTraceId } from '../utils/propagationContext';\nimport {\n addStatusMessageAttribute,\n convertSpanLinksForEnvelope,\n getRootSpan,\n getSimpleStatus,\n getSpanDescendants,\n getStatusMessage,\n getStreamedSpanLinks,\n spanTimeInputToSeconds,\n spanToJSON,\n spanToTransactionTraceContext,\n TRACE_FLAG_NONE,\n TRACE_FLAG_SAMPLED,\n} from '../utils/spanUtils';\nimport { timestampInSeconds } from '../utils/time';\nimport { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanEnd } from './logSpans';\nimport { timedEventsToMeasurements } from './measurement';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport { getCapturedScopesOnSpan, spanShouldInferOtelSource } from './utils';\n\nconst MAX_SPAN_COUNT = 1000;\n\n/**\n * Span contains all data about a span\n */\nexport class SentrySpan implements Span {\n protected _traceId: string;\n protected _spanId: string;\n protected _parentSpanId?: string | undefined;\n protected _sampled: boolean | undefined;\n protected _name?: string | undefined;\n protected _attributes: SpanAttributes;\n protected _links?: SpanLink[];\n /** Epoch timestamp in seconds when the span started. */\n protected _startTime: number;\n /** Epoch timestamp in seconds when the span ended. */\n protected _endTime?: number | undefined;\n /** Internal keeper of the status */\n protected _status?: SpanStatus;\n /** The timed events added to this span. */\n protected _events: TimedEvent[];\n\n /** if true, treat span as a standalone span (not part of a transaction) */\n private _isStandaloneSpan?: boolean;\n\n /**\n * You should never call the constructor manually, always use `Sentry.startSpan()`\n * or other span methods.\n * @internal\n * @hideconstructor\n * @hidden\n */\n public constructor(spanContext: SentrySpanArguments = {}) {\n this._traceId = spanContext.traceId || generateTraceId();\n this._spanId = spanContext.spanId || generateSpanId();\n this._startTime = spanContext.startTimestamp || timestampInSeconds();\n this._links = spanContext.links;\n\n this._attributes = {};\n this.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: spanContext.op,\n ...spanContext.attributes,\n });\n\n this._name = spanContext.name;\n\n if (spanContext.parentSpanId) {\n this._parentSpanId = spanContext.parentSpanId;\n }\n // We want to include booleans as well here\n if ('sampled' in spanContext) {\n this._sampled = spanContext.sampled;\n }\n if (spanContext.endTimestamp) {\n this._endTime = spanContext.endTimestamp;\n }\n\n this._events = [];\n\n this._isStandaloneSpan = spanContext.isStandalone;\n\n // If the span is already ended, ensure we finalize the span immediately\n if (this._endTime) {\n this._onSpanEnded();\n }\n }\n\n /** @inheritDoc */\n public addLink(link: SpanLink): this {\n if (this._links) {\n this._links.push(link);\n } else {\n this._links = [link];\n }\n return this;\n }\n\n /** @inheritDoc */\n public addLinks(links: SpanLink[]): this {\n if (this._links) {\n this._links.push(...links);\n } else {\n this._links = links;\n }\n return this;\n }\n\n /**\n * This should generally not be used,\n * but it is needed for being compliant with the OTEL Span interface.\n *\n * @hidden\n * @internal\n */\n public recordException(_exception: unknown, _time?: number | undefined): void {\n // noop\n }\n\n /** @inheritdoc */\n public spanContext(): SpanContextData {\n const { _spanId: spanId, _traceId: traceId, _sampled: sampled } = this;\n return {\n spanId,\n traceId,\n traceFlags: sampled ? TRACE_FLAG_SAMPLED : TRACE_FLAG_NONE,\n };\n }\n\n /** @inheritdoc */\n public setAttribute(key: string, value: SpanAttributeValue | undefined): this {\n if (value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n } else {\n this._attributes[key] = value;\n }\n\n return this;\n }\n\n /** @inheritdoc */\n public setAttributes(attributes: SpanAttributes): this {\n Object.keys(attributes).forEach(key => this.setAttribute(key, attributes[key]));\n return this;\n }\n\n /**\n * This should generally not be used,\n * but we need it for browser tracing where we want to adjust the start time afterwards.\n * USE THIS WITH CAUTION!\n *\n * @hidden\n * @internal\n */\n public updateStartTime(timeInput: SpanTimeInput): void {\n this._startTime = spanTimeInputToSeconds(timeInput);\n }\n\n /**\n * @inheritDoc\n */\n public setStatus(value: SpanStatus): this {\n this._status = value;\n return this;\n }\n\n /**\n * @inheritDoc\n */\n public updateName(name: string): this {\n this._name = name;\n // Renaming a span marks its name as explicitly chosen, so we stamp `custom`.\n // The exception is spans created by SentryTraceProvider: those are branded for\n // OTel-style source inference at span end (mirroring OTel SDK spans, which have\n // no Sentry source concept), so instrumentations renaming them must not pin\n // `custom` — applyOtelSpanData infers the correct source (e.g. 'route', 'task').\n if (!spanShouldInferOtelSource(this)) {\n this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'custom');\n }\n return this;\n }\n\n /** @inheritdoc */\n public end(endTimestamp?: SpanTimeInput): void {\n // If already ended, skip\n if (this._endTime) {\n return;\n }\n\n this._endTime = spanTimeInputToSeconds(endTimestamp);\n logSpanEnd(this);\n\n this._onSpanEnded();\n }\n\n /**\n * Get JSON representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToJSON(span)` instead.\n */\n public getSpanJSON(): SpanJSON {\n return {\n data: this._attributes,\n description: this._name,\n op: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n parent_span_id: this._parentSpanId,\n span_id: this._spanId,\n start_timestamp: this._startTime,\n status: getStatusMessage(this._status),\n timestamp: this._endTime,\n trace_id: this._traceId,\n origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n profile_id: this._attributes[SEMANTIC_ATTRIBUTE_PROFILE_ID] as string | undefined,\n exclusive_time: this._attributes[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME] as number | undefined,\n measurements: timedEventsToMeasurements(this._events),\n is_segment: (this._isStandaloneSpan && getRootSpan(this) === this) || undefined,\n segment_id: this._isStandaloneSpan ? getRootSpan(this).spanContext().spanId : undefined,\n links: convertSpanLinksForEnvelope(this._links),\n };\n }\n\n /**\n * Get {@link StreamedSpanJSON} representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToStreamedSpanJSON(span)` instead.\n */\n public getStreamedSpanJSON(): StreamedSpanJSON {\n return {\n name: this._name ?? '',\n span_id: this._spanId,\n trace_id: this._traceId,\n parent_span_id: this._parentSpanId,\n start_timestamp: this._startTime,\n // just in case _endTime is not set, we use the start time (i.e. duration 0)\n end_timestamp: this._endTime ?? this._startTime,\n is_segment: this._isStandaloneSpan || this === getRootSpan(this),\n status: getSimpleStatus(this._status),\n attributes: addStatusMessageAttribute(this._attributes, this._status),\n links: getStreamedSpanLinks(this._links),\n };\n }\n\n /** @inheritdoc */\n public isRecording(): boolean {\n return !this._endTime && !!this._sampled;\n }\n\n /**\n * @inheritdoc\n */\n public addEvent(\n name: string,\n attributesOrStartTime?: SpanAttributes | SpanTimeInput,\n startTime?: SpanTimeInput,\n ): this {\n DEBUG_BUILD && debug.log('[Tracing] Adding an event to span:', name);\n\n const time = isSpanTimeInput(attributesOrStartTime) ? attributesOrStartTime : startTime || timestampInSeconds();\n const attributes = isSpanTimeInput(attributesOrStartTime) ? {} : attributesOrStartTime || {};\n\n const event: TimedEvent = {\n name,\n time: spanTimeInputToSeconds(time),\n attributes,\n };\n\n this._events.push(event);\n\n return this;\n }\n\n /**\n * This method should generally not be used,\n * but for now we need a way to publicly check if the `_isStandaloneSpan` flag is set.\n * USE THIS WITH CAUTION!\n * @internal\n * @hidden\n * @experimental\n */\n public isStandaloneSpan(): boolean {\n return !!this._isStandaloneSpan;\n }\n\n /** Emit `spanEnd` when the span is ended. */\n private _onSpanEnded(): void {\n const client = getClient();\n if (client) {\n client.emit('spanEnd', this);\n // Guarding sending standalone v1 spans as v2 streamed spans for now.\n // Otherwise they'd be sent once as v1 spans and again as streamed spans.\n // We'll migrate CLS and LCP spans to streamed spans in a later PR and\n // INP spans in the next major of the SDK. At that point, we can fully remove\n // standalone v1 spans <3\n if (!this._isStandaloneSpan) {\n client.emit('afterSpanEnd', this);\n }\n }\n\n // A segment span is basically the root span of a local span tree.\n // So for now, this is either what we previously refer to as the root span,\n // or a standalone span.\n const isSegmentSpan = this._isStandaloneSpan || this === getRootSpan(this);\n\n if (!isSegmentSpan) {\n return;\n }\n\n // if this is a standalone span, we send it immediately\n if (this._isStandaloneSpan) {\n if (this._sampled) {\n sendSpanEnvelope(createSpanEnvelope([this], client));\n } else {\n DEBUG_BUILD &&\n debug.log('[Tracing] Discarding standalone span because its trace was not chosen to be sampled.');\n if (client) {\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n return;\n } else if (client && hasSpanStreamingEnabled(client)) {\n // TODO (spans): Remove standalone span custom logic in favor of sending simple v2 web vital spans\n client.emit('afterSegmentSpanEnd', this);\n return;\n }\n\n const transactionEvent = this._convertSpanToTransaction();\n if (transactionEvent) {\n const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope();\n scope.captureEvent(transactionEvent);\n }\n }\n\n /**\n * Finish the transaction & prepare the event to send to Sentry.\n */\n private _convertSpanToTransaction(): TransactionEvent | undefined {\n // We can only convert finished spans\n if (!isFullFinishedSpan(spanToJSON(this))) {\n return undefined;\n }\n\n if (!this._name) {\n DEBUG_BUILD && debug.warn('Transaction has no name, falling back to `<unlabeled transaction>`.');\n this._name = '<unlabeled transaction>';\n }\n\n const { scope: capturedSpanScope, isolationScope: capturedSpanIsolationScope } = getCapturedScopesOnSpan(this);\n\n const normalizedRequest = capturedSpanScope?.getScopeData().sdkProcessingMetadata?.normalizedRequest;\n\n if (this._sampled !== true) {\n return undefined;\n }\n\n // The transaction span itself as well as any potential standalone spans should be filtered out\n const finishedSpans = getSpanDescendants(this).filter(span => span !== this && !isStandaloneSpan(span));\n\n const spans = finishedSpans.map(span => spanToJSON(span)).filter(isFullFinishedSpan);\n\n const source = this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n\n // remove internal root span attributes we don't need to send.\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n let hasGenAiSpans = false;\n spans.forEach(span => {\n delete span.data[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n if (span.op?.startsWith('gen_ai.')) {\n hasGenAiSpans = true;\n }\n });\n // eslint-enabled-next-line @typescript-eslint/no-dynamic-delete\n\n const transaction: TransactionEvent = {\n contexts: {\n trace: spanToTransactionTraceContext(this),\n },\n spans:\n // spans.sort() mutates the array, but `spans` is already a copy so we can safely do this here\n // we do not use spans anymore after this point\n spans.length > MAX_SPAN_COUNT\n ? spans.sort((a, b) => a.start_timestamp - b.start_timestamp).slice(0, MAX_SPAN_COUNT)\n : spans,\n start_timestamp: this._startTime,\n timestamp: this._endTime,\n transaction: this._name,\n type: 'transaction',\n sdkProcessingMetadata: {\n capturedSpanScope,\n capturedSpanIsolationScope,\n dynamicSamplingContext: getDynamicSamplingContextFromSpan(this),\n hasGenAiSpans,\n },\n request: normalizedRequest,\n ...(source && {\n transaction_info: {\n source,\n },\n }),\n };\n\n const measurements = timedEventsToMeasurements(this._events);\n const hasMeasurements = measurements && Object.keys(measurements).length;\n\n if (hasMeasurements) {\n DEBUG_BUILD &&\n debug.log(\n '[Measurements] Adding measurements to transaction event',\n JSON.stringify(measurements, undefined, 2),\n );\n transaction.measurements = measurements;\n }\n\n return transaction;\n }\n}\n\nfunction isSpanTimeInput(value: undefined | SpanAttributes | SpanTimeInput): value is SpanTimeInput {\n return (value && typeof value === 'number') || value instanceof Date || Array.isArray(value);\n}\n\n// We want to filter out any incomplete SpanJSON objects\nfunction isFullFinishedSpan(input: Partial<SpanJSON>): input is SpanJSON {\n return !!input.start_timestamp && !!input.timestamp && !!input.span_id && !!input.trace_id;\n}\n\n/** `SentrySpan`s can be sent as a standalone span rather than belonging to a transaction */\nfunction isStandaloneSpan(span: Span): boolean {\n return span instanceof SentrySpan && span.isStandaloneSpan();\n}\n\n/**\n * Sends a `SpanEnvelope`.\n *\n * Note: If the envelope's spans are dropped, e.g. via `beforeSendSpan`,\n * the envelope will not be sent either.\n */\nfunction sendSpanEnvelope(envelope: SpanEnvelope): void {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const spanItems = envelope[1];\n if (!spanItems || spanItems.length === 0) {\n client.recordDroppedEvent('before_send', 'span');\n return;\n }\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAmDA,MAAM,cAAA,GAAiB,GAAA;AAKhB,MAAM,UAAA,CAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2B/B,WAAA,CAAY,WAAA,GAAmC,EAAC,EAAG;AACxD,IAAA,IAAA,CAAK,QAAA,GAAW,WAAA,CAAY,OAAA,IAAW,eAAA,EAAgB;AACvD,IAAA,IAAA,CAAK,OAAA,GAAU,WAAA,CAAY,MAAA,IAAU,cAAA,EAAe;AACpD,IAAA,IAAA,CAAK,UAAA,GAAa,WAAA,CAAY,cAAA,IAAkB,kBAAA,EAAmB;AACnE,IAAA,IAAA,CAAK,SAAS,WAAA,CAAY,KAAA;AAE1B,IAAA,IAAA,CAAK,cAAc,EAAC;AACpB,IAAA,IAAA,CAAK,aAAA,CAAc;AAAA,MACjB,CAAC,gCAAgC,GAAG,QAAA;AAAA,MACpC,CAAC,4BAA4B,GAAG,WAAA,CAAY,EAAA;AAAA,MAC5C,G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,OAC3C;AACF,MAAA,WAAA,CAAY,YAAA,GAAe,YAAA;AAAA,IAC7B;AAEA,IAAA,OAAO,WAAA;AAAA,EACT;AACF;AAEA,SAAS,gBAAgB,KAAA,EAA2E;AAClG,EAAA,OAAQ,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAa,iBAAiB,IAAA,IAAQ,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC7F;AAGA,SAAS,mBAAmB,KAAA,EAA6C;AACvE,EAAA,OAAO,CAAC,CAAC,KAAA,CAAM,eAAA,IAAmB,CAAC,CAAC,KAAA,CAAM,SAAA,IAAa,CAAC,CAAC,KAAA,CAAM,OAAA,IAAW,CAAC,CAAC,KAAA,CAAM,QAAA;AACpF;AAGA,SAAS,iBAAiB,IAAA,EAAqB;AAC7C,EAAA,OAAO,IAAA,YAAgB,UAAA,IAAc,IAAA,CAAK,gBAAA,EAAiB;AAC7D;AAQA,SAAS,iBAAiB,QAAA,EAA8B;AACtD,EAAA,MAAM,SAAS,SAAA,EAAU;AACzB,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,SAAA,GAAY,SAAS,CAAC,CAAA;AAC5B,EAAA,IAAI,CAAC,SAAA,IAAa,SAAA,CAAU,MAAA,KAAW,CAAA,EAAG;AACxC,IAAA,MAAA,CAAO,kBAAA,CAAmB,eAAe,MAAM,CAAA;AAC/C,IAAA;AAAA,EACF;AAIA,EAAA,MAAA,CAAO,aAAa,QAAQ,CAAA;AAC9B;;;;"} | ||
| {"version":3,"file":"sentrySpan.js","sources":["../../../src/tracing/sentrySpan.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { getClient, getCurrentScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { createSpanEnvelope } from '../envelope';\nimport {\n SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,\n SEMANTIC_ATTRIBUTE_PROFILE_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { SpanEnvelope } from '../types/envelope';\nimport type { TransactionEvent } from '../types/event';\nimport type { SpanLink } from '../types/link';\nimport type {\n SentrySpanArguments,\n Span,\n SpanAttributes,\n SpanAttributeValue,\n SpanContextData,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types/span';\nimport type { SpanStatus } from '../types/spanStatus';\nimport type { TimedEvent } from '../types/timedEvent';\nimport { debug } from '../utils/debug-logger';\nimport { generateSpanId, generateTraceId } from '../utils/propagationContext';\nimport {\n addStatusMessageAttribute,\n convertSpanLinksForEnvelope,\n getRootSpan,\n getSimpleStatus,\n getSpanDescendants,\n getStatusMessage,\n getStreamedSpanLinks,\n spanTimeInputToSeconds,\n spanToJSON,\n spanToTransactionTraceContext,\n TRACE_FLAG_NONE,\n TRACE_FLAG_SAMPLED,\n} from '../utils/spanUtils';\nimport { timestampInSeconds } from '../utils/time';\nimport { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanEnd } from './logSpans';\nimport { timedEventsToMeasurements } from './measurement';\nimport { getSegmentSpanCaptureStrategy, type SegmentSpanCaptureConvertOptions } from './segmentSpanCaptureStrategy';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport {\n getCapturedScopesOnSpan,\n markSpanSourceAsExplicit,\n spanIsTracerProviderSpan,\n spanShouldInferOtelSource,\n} from './utils';\n\nconst MAX_SPAN_COUNT = 1000;\n\n/**\n * Span contains all data about a span\n */\nexport class SentrySpan implements Span {\n protected _traceId: string;\n protected _spanId: string;\n protected _parentSpanId?: string | undefined;\n protected _sampled: boolean | undefined;\n protected _name?: string | undefined;\n protected _attributes: SpanAttributes;\n protected _links?: SpanLink[];\n /** Epoch timestamp in seconds when the span started. */\n protected _startTime: number;\n /** Epoch timestamp in seconds when the span ended. */\n protected _endTime?: number | undefined;\n /** Internal keeper of the status */\n protected _status?: SpanStatus;\n /** The timed events added to this span. */\n protected _events: TimedEvent[];\n\n /** if true, treat span as a standalone span (not part of a transaction) */\n private _isStandaloneSpan?: boolean;\n\n /** if true, the span is sealed and ignores further mutations (set after end for tracer-provider spans) */\n private _frozen?: boolean;\n\n /**\n * You should never call the constructor manually, always use `Sentry.startSpan()`\n * or other span methods.\n * @internal\n * @hideconstructor\n * @hidden\n */\n public constructor(spanContext: SentrySpanArguments = {}) {\n this._traceId = spanContext.traceId || generateTraceId();\n this._spanId = spanContext.spanId || generateSpanId();\n this._startTime = spanContext.startTimestamp || timestampInSeconds();\n this._links = spanContext.links;\n\n this._attributes = {};\n this.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: spanContext.op,\n ...spanContext.attributes,\n });\n\n this._name = spanContext.name;\n\n if (spanContext.parentSpanId) {\n this._parentSpanId = spanContext.parentSpanId;\n }\n // We want to include booleans as well here\n if ('sampled' in spanContext) {\n this._sampled = spanContext.sampled;\n }\n if (spanContext.endTimestamp) {\n this._endTime = spanContext.endTimestamp;\n }\n\n this._events = [];\n\n this._isStandaloneSpan = spanContext.isStandalone;\n\n // If the span is already ended, ensure we finalize the span immediately\n if (this._endTime) {\n this._onSpanEnded();\n }\n }\n\n /** @inheritDoc */\n public addLink(link: SpanLink): this {\n if (this._frozen) {\n return this;\n }\n if (this._links) {\n this._links.push(link);\n } else {\n this._links = [link];\n }\n return this;\n }\n\n /** @inheritDoc */\n public addLinks(links: SpanLink[]): this {\n if (this._frozen) {\n return this;\n }\n if (this._links) {\n this._links.push(...links);\n } else {\n this._links = links;\n }\n return this;\n }\n\n /**\n * This should generally not be used,\n * but it is needed for being compliant with the OTEL Span interface.\n *\n * @hidden\n * @internal\n */\n public recordException(_exception: unknown, _time?: SpanTimeInput | undefined): void {\n // noop\n }\n\n /** @inheritdoc */\n public spanContext(): SpanContextData {\n const { _spanId: spanId, _traceId: traceId, _sampled: sampled } = this;\n return {\n spanId,\n traceId,\n traceFlags: sampled ? TRACE_FLAG_SAMPLED : TRACE_FLAG_NONE,\n };\n }\n\n /** @inheritdoc */\n public setAttribute(key: string, value: SpanAttributeValue | undefined): this {\n if (this._frozen) {\n return this;\n }\n\n if (value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n } else {\n this._attributes[key] = value;\n }\n\n // Setting the source on a span branded for OTel-style inference means user code is choosing it\n // explicitly, so flag it to keep `applyOtelSpanData` from overriding it with an inferred source.\n if (key === SEMANTIC_ATTRIBUTE_SENTRY_SOURCE && value !== undefined && spanShouldInferOtelSource(this)) {\n markSpanSourceAsExplicit(this);\n }\n\n return this;\n }\n\n /** @inheritdoc */\n public setAttributes(attributes: SpanAttributes): this {\n Object.keys(attributes).forEach(key => this.setAttribute(key, attributes[key]));\n return this;\n }\n\n /**\n * This should generally not be used,\n * but we need it for browser tracing where we want to adjust the start time afterwards.\n * USE THIS WITH CAUTION!\n *\n * @hidden\n * @internal\n */\n public updateStartTime(timeInput: SpanTimeInput): void {\n if (this._frozen) {\n return;\n }\n this._startTime = spanTimeInputToSeconds(timeInput);\n }\n\n /**\n * @inheritDoc\n */\n public setStatus(value: SpanStatus): this {\n if (this._frozen) {\n return this;\n }\n this._status = value;\n return this;\n }\n\n /**\n * @inheritDoc\n */\n public updateName(name: string): this {\n if (this._frozen) {\n return this;\n }\n this._name = name;\n // Renaming a span marks its name as explicitly chosen, so we stamp `custom`.\n // The exception is spans created by SentryTraceProvider: those are branded for\n // OTel-style source inference at span end (mirroring OTel SDK spans, which have\n // no Sentry source concept), so instrumentations renaming them must not pin\n // `custom` — applyOtelSpanData infers the correct source (e.g. 'route', 'task').\n if (!spanShouldInferOtelSource(this)) {\n this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'custom');\n }\n return this;\n }\n\n /** @inheritdoc */\n public end(endTimestamp?: SpanTimeInput): void {\n // If already ended, skip the end-of-span processing, but still seal a tracer-provider span. The\n // seal at the bottom of this method is skipped on this early return, and `_endTime` may have been\n // set before this first `end()` call (e.g. via the constructor's `endTimestamp`), which would\n // otherwise leave the span mutable after `end()`. End-of-span processing already ran in that case.\n if (this._endTime) {\n this._frozen = spanIsTracerProviderSpan(this);\n return;\n }\n\n this._endTime = spanTimeInputToSeconds(endTimestamp);\n logSpanEnd(this);\n\n this._onSpanEnded();\n\n // A span created by the SentryTracerProvider is handed to OTel instrumentations as an OTel span,\n // so once end-of-span processing is done (including the `spanEnd` hook where `applyOtelSpanData`\n // finalizes status/source) it is sealed against further writes — mirroring the OpenTelemetry SDK,\n // where setters no-op after a span has ended. Without this, an instrumentation that sets\n // status/attributes after `end()` (e.g. Next.js on a render error) would overwrite the finalized\n // values, and the deferred capture would then serialize those late writes. Spans created directly\n // through the core API (e.g. the browser SDK, which backfills resource-timing attributes after a\n // span ends) are not tracer-provider spans and stay mutable.\n this._frozen = spanIsTracerProviderSpan(this);\n }\n\n /**\n * Get JSON representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToJSON(span)` instead.\n */\n public getSpanJSON(): SpanJSON {\n return {\n data: this._attributes,\n description: this._name,\n op: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n parent_span_id: this._parentSpanId,\n span_id: this._spanId,\n start_timestamp: this._startTime,\n status: getStatusMessage(this._status),\n timestamp: this._endTime,\n trace_id: this._traceId,\n origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n profile_id: this._attributes[SEMANTIC_ATTRIBUTE_PROFILE_ID] as string | undefined,\n exclusive_time: this._attributes[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME] as number | undefined,\n measurements: timedEventsToMeasurements(this._events),\n is_segment: (this._isStandaloneSpan && getRootSpan(this) === this) || undefined,\n segment_id: this._isStandaloneSpan ? getRootSpan(this).spanContext().spanId : undefined,\n links: convertSpanLinksForEnvelope(this._links),\n };\n }\n\n /**\n * Get {@link StreamedSpanJSON} representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToStreamedSpanJSON(span)` instead.\n */\n public getStreamedSpanJSON(): StreamedSpanJSON {\n return {\n name: this._name ?? '',\n span_id: this._spanId,\n trace_id: this._traceId,\n parent_span_id: this._parentSpanId,\n start_timestamp: this._startTime,\n // just in case _endTime is not set, we use the start time (i.e. duration 0)\n end_timestamp: this._endTime ?? this._startTime,\n is_segment: this._isStandaloneSpan || this === getRootSpan(this),\n status: getSimpleStatus(this._status),\n attributes: addStatusMessageAttribute(this._attributes, this._status),\n links: getStreamedSpanLinks(this._links),\n };\n }\n\n /** @inheritdoc */\n public isRecording(): boolean {\n return !this._endTime && !!this._sampled;\n }\n\n /**\n * @inheritdoc\n */\n public addEvent(\n name: string,\n attributesOrStartTime?: SpanAttributes | SpanTimeInput,\n startTime?: SpanTimeInput,\n ): this {\n if (this._frozen) {\n return this;\n }\n DEBUG_BUILD && debug.log('[Tracing] Adding an event to span:', name);\n\n const time = isSpanTimeInput(attributesOrStartTime) ? attributesOrStartTime : startTime || timestampInSeconds();\n const attributes = isSpanTimeInput(attributesOrStartTime) ? {} : attributesOrStartTime || {};\n\n const event: TimedEvent = {\n name,\n time: spanTimeInputToSeconds(time),\n attributes,\n };\n\n this._events.push(event);\n\n return this;\n }\n\n /**\n * This method should generally not be used,\n * but for now we need a way to publicly check if the `_isStandaloneSpan` flag is set.\n * USE THIS WITH CAUTION!\n * @internal\n * @hidden\n * @experimental\n */\n public isStandaloneSpan(): boolean {\n return !!this._isStandaloneSpan;\n }\n\n /** Emit `spanEnd` when the span is ended. */\n private _onSpanEnded(): void {\n const client = getClient();\n if (client) {\n client.emit('spanEnd', this);\n // Guarding sending standalone v1 spans as v2 streamed spans for now.\n // Otherwise they'd be sent once as v1 spans and again as streamed spans.\n // We'll migrate CLS and LCP spans to streamed spans in a later PR and\n // INP spans in the next major of the SDK. At that point, we can fully remove\n // standalone v1 spans <3\n if (!this._isStandaloneSpan) {\n client.emit('afterSpanEnd', this);\n }\n }\n\n // A segment span is basically the root span of a local span tree.\n // So for now, this is either what we previously refer to as the root span,\n // or a standalone span.\n const rootSpan = getRootSpan(this);\n const isSegmentSpan = this._isStandaloneSpan || this === rootSpan;\n\n // if this is a standalone span, we send it immediately\n if (this._isStandaloneSpan) {\n if (this._sampled) {\n sendSpanEnvelope(createSpanEnvelope([this], client));\n } else {\n DEBUG_BUILD &&\n debug.log('[Tracing] Discarding standalone span because its trace was not chosen to be sampled.');\n if (client) {\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n return;\n }\n\n // Non-segment children aren't captured on their own. A registered strategy may re-emit a late child\n // as its own orphan transaction; without one, it's dropped.\n if (!isSegmentSpan) {\n const strategy = getSegmentSpanCaptureStrategy();\n if (strategy) {\n const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope();\n strategy.onChildSpanEnded(this, rootSpan, options => this._convertSpanToTransaction(options), scope);\n }\n return;\n }\n\n if (client && hasSpanStreamingEnabled(client)) {\n // TODO (spans): Remove standalone span custom logic in favor of sending simple v2 web vital spans\n client.emit('afterSegmentSpanEnd', this);\n return;\n }\n\n // A registered strategy defers the snapshot so children closing just after the segment still land\n // (and late ones can orphan); without one, assemble synchronously from the live tree.\n const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope();\n const strategy = getSegmentSpanCaptureStrategy();\n if (strategy) {\n strategy.onSegmentSpanEnded(options => this._convertSpanToTransaction(options), scope);\n } else {\n const transactionEvent = this._convertSpanToTransaction();\n if (transactionEvent) {\n scope.captureEvent(transactionEvent);\n }\n }\n }\n\n /**\n * Finish the transaction & prepare the event to send to Sentry.\n */\n private _convertSpanToTransaction(options: SegmentSpanCaptureConvertOptions = {}): TransactionEvent | undefined {\n // We can only convert finished spans\n if (!isFullFinishedSpan(spanToJSON(this))) {\n return undefined;\n }\n\n if (!this._name) {\n DEBUG_BUILD && debug.warn('Transaction has no name, falling back to `<unlabeled transaction>`.');\n this._name = '<unlabeled transaction>';\n }\n\n const { scope: capturedSpanScope, isolationScope: capturedSpanIsolationScope } = getCapturedScopesOnSpan(this);\n\n const normalizedRequest = capturedSpanScope?.getScopeData().sdkProcessingMetadata?.normalizedRequest;\n\n if (this._sampled !== true) {\n return undefined;\n }\n\n // Skip the span itself, standalone spans, and (when a strategy tracks it) spans already sent. The\n // synchronous default passes no hooks, so this bookkeeping stays out of SDKs that don't defer.\n options.onSpanCaptured?.(this);\n const spans: SpanJSON[] = [];\n for (const descendant of getSpanDescendants(this)) {\n if (descendant === this || isStandaloneSpan(descendant) || options.isSpanAlreadyCaptured?.(descendant)) {\n continue;\n }\n const spanJSON = spanToJSON(descendant);\n if (!isFullFinishedSpan(spanJSON)) {\n continue;\n }\n options.onSpanCaptured?.(descendant);\n spans.push(spanJSON);\n }\n\n const source = this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n\n // remove internal root span attributes we don't need to send.\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n let hasGenAiSpans = false;\n spans.forEach(span => {\n delete span.data[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n if (span.op?.startsWith('gen_ai.')) {\n hasGenAiSpans = true;\n }\n });\n // eslint-enabled-next-line @typescript-eslint/no-dynamic-delete\n\n const transaction: TransactionEvent = {\n contexts: {\n trace: spanToTransactionTraceContext(this),\n },\n spans:\n // spans.sort() mutates the array, but `spans` is already a copy so we can safely do this here\n // we do not use spans anymore after this point\n spans.length > MAX_SPAN_COUNT\n ? spans.sort((a, b) => a.start_timestamp - b.start_timestamp).slice(0, MAX_SPAN_COUNT)\n : spans,\n start_timestamp: this._startTime,\n timestamp: this._endTime,\n transaction: this._name,\n type: 'transaction',\n sdkProcessingMetadata: {\n capturedSpanScope,\n capturedSpanIsolationScope,\n dynamicSamplingContext: getDynamicSamplingContextFromSpan(this),\n hasGenAiSpans,\n },\n request: normalizedRequest,\n ...(source && {\n transaction_info: {\n source,\n },\n }),\n };\n\n const measurements = timedEventsToMeasurements(this._events);\n const hasMeasurements = measurements && Object.keys(measurements).length;\n\n if (hasMeasurements) {\n DEBUG_BUILD &&\n debug.log(\n '[Measurements] Adding measurements to transaction event',\n JSON.stringify(measurements, undefined, 2),\n );\n transaction.measurements = measurements;\n }\n\n return transaction;\n }\n}\n\nfunction isSpanTimeInput(value: undefined | SpanAttributes | SpanTimeInput): value is SpanTimeInput {\n return (value && typeof value === 'number') || value instanceof Date || Array.isArray(value);\n}\n\n// We want to filter out any incomplete SpanJSON objects\nfunction isFullFinishedSpan(input: Partial<SpanJSON>): input is SpanJSON {\n return !!input.start_timestamp && !!input.timestamp && !!input.span_id && !!input.trace_id;\n}\n\n/** `SentrySpan`s can be sent as a standalone span rather than belonging to a transaction */\nfunction isStandaloneSpan(span: Span): boolean {\n return span instanceof SentrySpan && span.isStandaloneSpan();\n}\n\n/**\n * Sends a `SpanEnvelope`.\n *\n * Note: If the envelope's spans are dropped, e.g. via `beforeSendSpan`,\n * the envelope will not be sent either.\n */\nfunction sendSpanEnvelope(envelope: SpanEnvelope): void {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const spanItems = envelope[1];\n if (!spanItems || spanItems.length === 0) {\n client.recordDroppedEvent('before_send', 'span');\n return;\n }\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n"],"names":["strategy","scope"],"mappings":";;;;;;;;;;;;;;;AAyDA,MAAM,cAAA,GAAiB,GAAA;AAKhB,MAAM,UAAA,CAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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AAM,QAAA;AACpF;AAGA,SAAS,iBAAiB,IAAA,EAAqB;AAC7C,EAAA,OAAO,IAAA,YAAgB,UAAA,IAAc,IAAA,CAAK,gBAAA,EAAiB;AAC7D;AAQA,SAAS,iBAAiB,QAAA,EAA8B;AACtD,EAAA,MAAM,SAAS,SAAA,EAAU;AACzB,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,SAAA,GAAY,SAAS,CAAC,CAAA;AAC5B,EAAA,IAAI,CAAC,SAAA,IAAa,SAAA,CAAU,MAAA,KAAW,CAAA,EAAG;AACxC,IAAA,MAAA,CAAO,kBAAA,CAAmB,eAAe,MAAM,CAAA;AAC/C,IAAA;AAAA,EACF;AAIA,EAAA,MAAA,CAAO,aAAa,QAAQ,CAAA;AAC9B;;;;"} |
@@ -8,2 +8,3 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_USER_USERNAME, SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS, SEMANTIC_ATTRIBUTE_USER_EMAIL, SEMANTIC_ATTRIBUTE_USER_ID, SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME, SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID, SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME, SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT, SEMANTIC_ATTRIBUTE_SENTRY_RELEASE, SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS } from '../../semanticAttributes.js'; | ||
| import { DEFAULT_ENVIRONMENT } from '../../constants.js'; | ||
| import { SENTRY_TRACE_LIFECYCLE, SENTRY_SPAN_SOURCE } from '@sentry/conventions/attributes'; | ||
@@ -30,5 +31,3 @@ function captureSpan(span, client) { | ||
| safeSetSpanJSONAttributes(processedSpan, { | ||
| // Purposefully not using a constant defined here like in other attributes: | ||
| // This will be the name for SEMANTIC_ATTRIBUTE_SENTRY_SOURCE in v11 | ||
| "sentry.span.source": spanNameSource | ||
| [SENTRY_SPAN_SOURCE]: spanNameSource | ||
| }); | ||
@@ -64,2 +63,3 @@ } | ||
| safeSetSpanJSONAttributes(spanJSON, { | ||
| [SENTRY_TRACE_LIFECYCLE]: "stream", | ||
| [SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: release, | ||
@@ -66,0 +66,0 @@ [SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: environment || DEFAULT_ENVIRONMENT, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"captureSpan.js","sources":["../../../../src/tracing/spans/captureSpan.ts"],"sourcesContent":["import type { RawAttributes } from '../../attributes';\nimport type { Client } from '../../client';\nimport type { ScopeData } from '../../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT,\n SEMANTIC_ATTRIBUTE_SENTRY_RELEASE,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_USER_EMAIL,\n SEMANTIC_ATTRIBUTE_USER_ID,\n SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS,\n SEMANTIC_ATTRIBUTE_USER_USERNAME,\n} from '../../semanticAttributes';\nimport type { SerializedStreamedSpan, Span, StreamedSpanJSON } from '../../types/span';\nimport { getCombinedScopeData } from '../../utils/scopeData';\nimport {\n INTERNAL_getSegmentSpan,\n showSpanDropWarning,\n spanToStreamedSpanJSON,\n streamedSpanJsonToSerializedSpan,\n} from '../../utils/spanUtils';\nimport { getCapturedScopesOnSpan } from '../utils';\nimport { isStreamedBeforeSendSpanCallback } from './beforeSendSpan';\nimport { scopeContextsToSpanAttributes } from './scopeContextAttributes';\nimport { DEFAULT_ENVIRONMENT } from '../../constants';\n\nexport type SerializedStreamedSpanWithSegmentSpan = SerializedStreamedSpan & {\n _segmentSpan: Span;\n};\n\n/**\n * Captures a span and returns a JSON representation to be enqueued for sending.\n *\n * IMPORTANT: This function converts the span to JSON immediately to avoid writing\n * to an already-ended OTel span instance (which is blocked by the OTel Span class).\n *\n * @returns the final serialized span with a reference to its segment span. This reference\n * is needed later on to compute the DSC for the span envelope.\n */\nexport function captureSpan(span: Span, client: Client): SerializedStreamedSpanWithSegmentSpan {\n // Convert to JSON FIRST - we cannot write to an already-ended span\n const spanJSON = spanToStreamedSpanJSON(span);\n\n const segmentSpan = INTERNAL_getSegmentSpan(span);\n const serializedSegmentSpan = spanToStreamedSpanJSON(segmentSpan);\n\n const { isolationScope: spanIsolationScope, scope: spanScope } = getCapturedScopesOnSpan(span);\n\n const finalScopeData = getCombinedScopeData(spanIsolationScope, spanScope);\n\n applyCommonSpanAttributes(spanJSON, serializedSegmentSpan, client, finalScopeData);\n\n // Access `kind` via duck-typing — OTel span objects have this property but it's not on Sentry's Span type.\n // It is forwarded to `preprocessSpan` subscribers (e.g. the OpenTelemetry SDK backfills op/source/name from it).\n const spanKind = (span as { kind?: number }).kind;\n\n // Preprocess the span JSON before any other hooks run, so that `processSpan`/`processSegmentSpan`\n // subscribers (incl. integrations) and `beforeSendSpan` see fully inferred span data.\n client.emit('preprocessSpan', spanJSON, { spanKind });\n\n if (spanJSON.is_segment) {\n applyScopeToSegmentSpan(spanJSON, finalScopeData);\n applySdkMetadataToSegmentSpan(spanJSON, client);\n // Allow hook subscribers to mutate the segment span JSON\n // This also invokes the `processSegmentSpan` hook of all integrations\n client.emit('processSegmentSpan', spanJSON);\n }\n\n // This allows hook subscribers to mutate the span JSON\n // This also invokes the `processSpan` hook of all integrations\n client.emit('processSpan', spanJSON);\n\n const { beforeSendSpan } = client.getOptions();\n const processedSpan =\n beforeSendSpan && isStreamedBeforeSendSpanCallback(beforeSendSpan)\n ? applyBeforeSendSpanCallback(spanJSON, beforeSendSpan)\n : spanJSON;\n\n // Backfill sentry.span.source from sentry.source. Only `sentry.span.source` is respected by Sentry.\n // TODO(v11): Remove this backfill once we renamed SEMANTIC_ATTRIBUTE_SENTRY_SOURCE to sentry.span.source\n const spanNameSource = processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n if (spanNameSource) {\n safeSetSpanJSONAttributes(processedSpan, {\n // Purposefully not using a constant defined here like in other attributes:\n // This will be the name for SEMANTIC_ATTRIBUTE_SENTRY_SOURCE in v11\n 'sentry.span.source': spanNameSource,\n });\n }\n\n return {\n ...streamedSpanJsonToSerializedSpan(processedSpan),\n _segmentSpan: segmentSpan,\n };\n}\n\nfunction applyScopeToSegmentSpan(segmentSpanJSON: StreamedSpanJSON, scopeData: ScopeData): void {\n const contextAttributes = scopeContextsToSpanAttributes(scopeData.contexts);\n safeSetSpanJSONAttributes(segmentSpanJSON, contextAttributes);\n}\n\n/**\n * Safely set attributes on a span JSON.\n * If an attribute already exists, it will not be overwritten.\n */\nexport function safeSetSpanJSONAttributes(\n spanJSON: StreamedSpanJSON,\n newAttributes: RawAttributes<Record<string, unknown>>,\n): void {\n const originalAttributes = spanJSON.attributes ?? (spanJSON.attributes = {});\n\n Object.entries(newAttributes).forEach(([key, value]) => {\n if (value != null && !(key in originalAttributes)) {\n originalAttributes[key] = value;\n }\n });\n}\n\nfunction applySdkMetadataToSegmentSpan(segmentSpanJSON: StreamedSpanJSON, client: Client): void {\n const integrationNames = client.getIntegrationNames();\n if (!integrationNames.length) return;\n\n safeSetSpanJSONAttributes(segmentSpanJSON, {\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS]: integrationNames,\n });\n}\n\nfunction applyCommonSpanAttributes(\n spanJSON: StreamedSpanJSON,\n serializedSegmentSpan: StreamedSpanJSON,\n client: Client,\n scopeData: ScopeData,\n): void {\n const sdk = client.getSdkMetadata();\n const { release, environment } = client.getOptions();\n\n // avoid overwriting any previously set attributes (from users or potentially our SDK instrumentation)\n safeSetSpanJSONAttributes(spanJSON, {\n [SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: release,\n [SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: environment || DEFAULT_ENVIRONMENT,\n [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME]: serializedSegmentSpan.name,\n [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID]: serializedSegmentSpan.span_id,\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: sdk?.sdk?.name,\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: sdk?.sdk?.version,\n [SEMANTIC_ATTRIBUTE_USER_ID]: scopeData.user?.id,\n [SEMANTIC_ATTRIBUTE_USER_EMAIL]: scopeData.user?.email,\n [SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS]: scopeData.user?.ip_address,\n [SEMANTIC_ATTRIBUTE_USER_USERNAME]: scopeData.user?.username,\n ...scopeData.attributes,\n });\n}\n\n/**\n * Apply a user-provided beforeSendSpan callback to a span JSON.\n */\nexport function applyBeforeSendSpanCallback(\n span: StreamedSpanJSON,\n beforeSendSpan: (span: StreamedSpanJSON) => StreamedSpanJSON,\n): StreamedSpanJSON {\n const modifedSpan = beforeSendSpan(span);\n if (!modifedSpan) {\n showSpanDropWarning();\n return span;\n }\n return modifedSpan;\n}\n"],"names":[],"mappings":";;;;;;;;AA2CO,SAAS,WAAA,CAAY,MAAY,MAAA,EAAuD;AAE7F,EAAA,MAAM,QAAA,GAAW,uBAAuB,IAAI,CAAA;AAE5C,EAAA,MAAM,WAAA,GAAc,wBAAwB,IAAI,CAAA;AAChD,EAAA,MAAM,qBAAA,GAAwB,uBAAuB,WAAW,CAAA;AAEhE,EAAA,MAAM,EAAE,cAAA,EAAgB,kBAAA,EAAoB,OAAO,S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BAA0B,GAAG,SAAA,CAAU,IAAA,EAAM,EAAA;AAAA,IAC9C,CAAC,6BAA6B,GAAG,SAAA,CAAU,IAAA,EAAM,KAAA;AAAA,IACjD,CAAC,kCAAkC,GAAG,SAAA,CAAU,IAAA,EAAM,UAAA;AAAA,IACtD,CAAC,gCAAgC,GAAG,SAAA,CAAU,IAAA,EAAM,QAAA;AAAA,IACpD,GAAG,SAAA,CAAU;AAAA,GACd,CAAA;AACH;AAKO,SAAS,2BAAA,CACd,MACA,cAAA,EACkB;AAClB,EAAA,MAAM,WAAA,GAAc,eAAe,IAAI,CAAA;AACvC,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAA,mBAAA,EAAoB;AACpB,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,WAAA;AACT;;;;"} | ||
| {"version":3,"file":"captureSpan.js","sources":["../../../../src/tracing/spans/captureSpan.ts"],"sourcesContent":["import type { RawAttributes } from '../../attributes';\nimport type { Client } from '../../client';\nimport type { ScopeData } from '../../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT,\n SEMANTIC_ATTRIBUTE_SENTRY_RELEASE,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_USER_EMAIL,\n SEMANTIC_ATTRIBUTE_USER_ID,\n SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS,\n SEMANTIC_ATTRIBUTE_USER_USERNAME,\n} from '../../semanticAttributes';\nimport type { SerializedStreamedSpan, Span, StreamedSpanJSON } from '../../types/span';\nimport { getCombinedScopeData } from '../../utils/scopeData';\nimport {\n INTERNAL_getSegmentSpan,\n showSpanDropWarning,\n spanToStreamedSpanJSON,\n streamedSpanJsonToSerializedSpan,\n} from '../../utils/spanUtils';\nimport { getCapturedScopesOnSpan } from '../utils';\nimport { isStreamedBeforeSendSpanCallback } from './beforeSendSpan';\nimport { scopeContextsToSpanAttributes } from './scopeContextAttributes';\nimport { DEFAULT_ENVIRONMENT } from '../../constants';\nimport { SENTRY_SPAN_SOURCE, SENTRY_TRACE_LIFECYCLE } from '@sentry/conventions/attributes';\n\nexport type SerializedStreamedSpanWithSegmentSpan = SerializedStreamedSpan & {\n _segmentSpan: Span;\n};\n\n/**\n * Captures a span and returns a JSON representation to be enqueued for sending.\n *\n * IMPORTANT: This function converts the span to JSON immediately to avoid writing\n * to an already-ended OTel span instance (which is blocked by the OTel Span class).\n *\n * @returns the final serialized span with a reference to its segment span. This reference\n * is needed later on to compute the DSC for the span envelope.\n */\nexport function captureSpan(span: Span, client: Client): SerializedStreamedSpanWithSegmentSpan {\n // Convert to JSON FIRST - we cannot write to an already-ended span\n const spanJSON = spanToStreamedSpanJSON(span);\n\n const segmentSpan = INTERNAL_getSegmentSpan(span);\n const serializedSegmentSpan = spanToStreamedSpanJSON(segmentSpan);\n\n const { isolationScope: spanIsolationScope, scope: spanScope } = getCapturedScopesOnSpan(span);\n\n const finalScopeData = getCombinedScopeData(spanIsolationScope, spanScope);\n\n applyCommonSpanAttributes(spanJSON, serializedSegmentSpan, client, finalScopeData);\n\n // Access `kind` via duck-typing — OTel span objects have this property but it's not on Sentry's Span type.\n // It is forwarded to `preprocessSpan` subscribers (e.g. the OpenTelemetry SDK backfills op/source/name from it).\n const spanKind = (span as { kind?: number }).kind;\n\n // Preprocess the span JSON before any other hooks run, so that `processSpan`/`processSegmentSpan`\n // subscribers (incl. integrations) and `beforeSendSpan` see fully inferred span data.\n client.emit('preprocessSpan', spanJSON, { spanKind });\n\n if (spanJSON.is_segment) {\n applyScopeToSegmentSpan(spanJSON, finalScopeData);\n applySdkMetadataToSegmentSpan(spanJSON, client);\n // Allow hook subscribers to mutate the segment span JSON\n // This also invokes the `processSegmentSpan` hook of all integrations\n client.emit('processSegmentSpan', spanJSON);\n }\n\n // This allows hook subscribers to mutate the span JSON\n // This also invokes the `processSpan` hook of all integrations\n client.emit('processSpan', spanJSON);\n\n const { beforeSendSpan } = client.getOptions();\n const processedSpan =\n beforeSendSpan && isStreamedBeforeSendSpanCallback(beforeSendSpan)\n ? applyBeforeSendSpanCallback(spanJSON, beforeSendSpan)\n : spanJSON;\n\n // Backfill sentry.span.source from sentry.source. Only `sentry.span.source` is respected by Sentry.\n // TODO(v11): Remove this backfill once we renamed SEMANTIC_ATTRIBUTE_SENTRY_SOURCE to sentry.span.source\n const spanNameSource = processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n if (spanNameSource) {\n safeSetSpanJSONAttributes(processedSpan, {\n [SENTRY_SPAN_SOURCE]: spanNameSource,\n });\n }\n\n return {\n ...streamedSpanJsonToSerializedSpan(processedSpan),\n _segmentSpan: segmentSpan,\n };\n}\n\nfunction applyScopeToSegmentSpan(segmentSpanJSON: StreamedSpanJSON, scopeData: ScopeData): void {\n const contextAttributes = scopeContextsToSpanAttributes(scopeData.contexts);\n safeSetSpanJSONAttributes(segmentSpanJSON, contextAttributes);\n}\n\n/**\n * Safely set attributes on a span JSON.\n * If an attribute already exists, it will not be overwritten.\n */\nexport function safeSetSpanJSONAttributes(\n spanJSON: StreamedSpanJSON,\n newAttributes: RawAttributes<Record<string, unknown>>,\n): void {\n const originalAttributes = spanJSON.attributes ?? (spanJSON.attributes = {});\n\n Object.entries(newAttributes).forEach(([key, value]) => {\n if (value != null && !(key in originalAttributes)) {\n originalAttributes[key] = value;\n }\n });\n}\n\nfunction applySdkMetadataToSegmentSpan(segmentSpanJSON: StreamedSpanJSON, client: Client): void {\n const integrationNames = client.getIntegrationNames();\n if (!integrationNames.length) return;\n\n safeSetSpanJSONAttributes(segmentSpanJSON, {\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS]: integrationNames,\n });\n}\n\nfunction applyCommonSpanAttributes(\n spanJSON: StreamedSpanJSON,\n serializedSegmentSpan: StreamedSpanJSON,\n client: Client,\n scopeData: ScopeData,\n): void {\n const sdk = client.getSdkMetadata();\n const { release, environment } = client.getOptions();\n\n // avoid overwriting any previously set attributes (from users or potentially our SDK instrumentation)\n safeSetSpanJSONAttributes(spanJSON, {\n [SENTRY_TRACE_LIFECYCLE]: 'stream',\n [SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: release,\n [SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: environment || DEFAULT_ENVIRONMENT,\n [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME]: serializedSegmentSpan.name,\n [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID]: serializedSegmentSpan.span_id,\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: sdk?.sdk?.name,\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: sdk?.sdk?.version,\n [SEMANTIC_ATTRIBUTE_USER_ID]: scopeData.user?.id,\n [SEMANTIC_ATTRIBUTE_USER_EMAIL]: scopeData.user?.email,\n [SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS]: scopeData.user?.ip_address,\n [SEMANTIC_ATTRIBUTE_USER_USERNAME]: scopeData.user?.username,\n ...scopeData.attributes,\n });\n}\n\n/**\n * Apply a user-provided beforeSendSpan callback to a span JSON.\n */\nexport function applyBeforeSendSpanCallback(\n span: StreamedSpanJSON,\n beforeSendSpan: (span: StreamedSpanJSON) => StreamedSpanJSON,\n): StreamedSpanJSON {\n const modifedSpan = beforeSendSpan(span);\n if (!modifedSpan) {\n showSpanDropWarning();\n return span;\n }\n return modifedSpan;\n}\n"],"names":[],"mappings":";;;;;;;;;AA4CO,SAAS,WAAA,CAAY,MAAY,MAAA,EAAuD;AAE7F,EAAA,MAAM,QAAA,GAAW,uBAAuB,IAAI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IAAA;AAAA,IAChE,CAAC,oCAAoC,GAAG,qBAAA,CAAsB,OAAA;AAAA,IAC9D,CAAC,kCAAkC,GAAG,GAAA,EAAK,GAAA,EAAK,IAAA;AAAA,IAChD,CAAC,qCAAqC,GAAG,GAAA,EAAK,GAAA,EAAK,OAAA;AAAA,IACnD,CAAC,0BAA0B,GAAG,SAAA,CAAU,IAAA,EAAM,EAAA;AAAA,IAC9C,CAAC,6BAA6B,GAAG,SAAA,CAAU,IAAA,EAAM,KAAA;AAAA,IACjD,CAAC,kCAAkC,GAAG,SAAA,CAAU,IAAA,EAAM,UAAA;AAAA,IACtD,CAAC,gCAAgC,GAAG,SAAA,CAAU,IAAA,EAAM,QAAA;AAAA,IACpD,GAAG,SAAA,CAAU;AAAA,GACd,CAAA;AACH;AAKO,SAAS,2BAAA,CACd,MACA,cAAA,EACkB;AAClB,EAAA,MAAM,WAAA,GAAc,eAAe,IAAI,CAAA;AACvC,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAA,mBAAA,EAAoB;AACpB,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,WAAA;AACT;;;;"} |
@@ -21,3 +21,3 @@ import { getAsyncContextStrategy } from '../asyncContext/index.js'; | ||
| import { sampleSpan } from './sampling.js'; | ||
| import { SentryNonRecordingSpan, spanIsNonRecordingSpan } from './sentryNonRecordingSpan.js'; | ||
| import { spanIsNonRecordingSpan, SentryNonRecordingSpan } from './sentryNonRecordingSpan.js'; | ||
| import { SentrySpan } from './sentrySpan.js'; | ||
@@ -49,3 +49,3 @@ import { SPAN_STATUS_ERROR } from './spanstatus.js'; | ||
| }); | ||
| if (!_isIgnoredSpan(activeSpan) || !parentSpan) { | ||
| if (!spanIsIgnored(activeSpan) || !parentSpan) { | ||
| _setSpanForScope(scope, activeSpan); | ||
@@ -88,3 +88,3 @@ } | ||
| }); | ||
| if (!_isIgnoredSpan(activeSpan) || !parentSpan) { | ||
| if (!spanIsIgnored(activeSpan) || !parentSpan) { | ||
| _setSpanForScope(scope, activeSpan); | ||
@@ -113,2 +113,8 @@ } | ||
| } | ||
| return _startInactiveSpanImpl(options); | ||
| } | ||
| function _INTERNAL_startInactiveSpan(options) { | ||
| return _startInactiveSpanImpl(options); | ||
| } | ||
| function _startInactiveSpanImpl(options) { | ||
| const spanArguments = parseSentrySpanArguments(options); | ||
@@ -403,7 +409,7 @@ const { forceTransaction, parentSpan: customParentSpan } = options; | ||
| } | ||
| function _isIgnoredSpan(span) { | ||
| function spanIsIgnored(span) { | ||
| return spanIsNonRecordingSpan(span) && span.dropReason === "ignored"; | ||
| } | ||
| export { SUPPRESS_TRACING_KEY, continueTrace, isTracingSuppressed, startInactiveSpan, startNewTrace, startSpan, startSpanManual, suppressTracing, withActiveSpan }; | ||
| export { SUPPRESS_TRACING_KEY, _INTERNAL_startInactiveSpan, continueTrace, isTracingSuppressed, spanIsIgnored, startInactiveSpan, startNewTrace, startSpan, startSpanManual, suppressTracing, withActiveSpan }; | ||
| //# sourceMappingURL=trace.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"trace.js","sources":["../../../src/tracing/trace.ts"],"sourcesContent":["/* eslint-disable max-lines */\n\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { AsyncContextStrategy } from '../asyncContext/types';\nimport { getMainCarrier } from '../carrier';\nimport { getClient, getCurrentScope, getIsolationScope, withScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Scope } from '../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { ClientOptions } from '../types/options';\nimport type { SentrySpanArguments, Span, SpanTimeInput } from '../types/span';\nimport type { StartSpanOptions } from '../types/startSpanOptions';\nimport { baggageHeaderToDynamicSamplingContext } from '../utils/baggage';\nimport { debug } from '../utils/debug-logger';\nimport { handleCallbackErrors } from '../utils/handleCallbackErrors';\nimport { hasSpansEnabled } from '../utils/hasSpansEnabled';\nimport { shouldIgnoreSpan } from '../utils/should-ignore-span';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport { parseSampleRate } from '../utils/parseSampleRate';\nimport { generateTraceId } from '../utils/propagationContext';\nimport { safeMathRandom } from '../utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from '../utils/spanOnScope';\nimport { addChildSpanToSpan, getRootSpan, spanIsSampled, spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils';\nimport { propagationContextFromHeaders, shouldContinueTrace } from '../utils/tracing';\nimport { freezeDscOnSpan, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanStart } from './logSpans';\nimport { sampleSpan } from './sampling';\nimport { SentryNonRecordingSpan, spanIsNonRecordingSpan } from './sentryNonRecordingSpan';\nimport { SentrySpan } from './sentrySpan';\nimport { SPAN_STATUS_ERROR } from './spanstatus';\nimport { setCapturedScopesOnSpan } from './utils';\nimport type { Client } from '../client';\n\nexport const SUPPRESS_TRACING_KEY = '__SENTRY_SUPPRESS_TRACING__';\n\n/**\n * Wraps a function with a transaction/span and finishes the span after the function is done.\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * If you want to create a span that is not set as active, use {@link startInactiveSpan}.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T): T {\n const acs = getAcs();\n if (acs.startSpan) {\n return acs.startSpan(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n // We still need to fork a potentially passed scope, as we set the active span on it\n // and we need to ensure that it is cleaned up properly once the span ends.\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n const client = getClient();\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n const activeSpan = missingRequiredParent\n ? startMissingRequiredParentSpan(scope, client)\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n // Ignored root spans still need to be set on scope so that `getActiveSpan()` returns them\n // and descendants are also non-recording. Ignored child spans don't need this because\n // the parent span is already on scope.\n if (!_isIgnoredSpan(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n () => callback(activeSpan),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n () => {\n activeSpan.end();\n },\n );\n });\n });\n}\n\n/**\n * Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span\n * after the function is done automatically. Use `span.end()` to end the span.\n *\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpanManual<T>(options: StartSpanOptions, callback: (span: Span, finish: () => void) => T): T {\n const acs = getAcs();\n if (acs.startSpanManual) {\n return acs.startSpanManual(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n const activeSpan = missingRequiredParent\n ? startMissingRequiredParentSpan(scope, getClient())\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n // We don't set ignored child spans onto the scope because there likely is an active,\n // unignored span on the scope already.\n if (!_isIgnoredSpan(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n // We pass the `finish` function to the callback, so the user can finish the span manually\n // this is mainly here for historic purposes because previously, we instructed users to call\n // `finish` instead of `span.end()` to also clean up the scope. Nowadays, calling `span.end()`\n // or `finish` has the same effect and we simply leave it here to avoid breaking user code.\n () => callback(activeSpan, () => activeSpan.end()),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n );\n });\n });\n}\n\n/**\n * Creates a span. This span is not set as active, so will not get automatic instrumentation spans\n * as children or be able to be accessed via `Sentry.getActiveSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * This function will always return a span,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startInactiveSpan(options: StartSpanOptions): Span {\n const acs = getAcs();\n if (acs.startInactiveSpan) {\n return acs.startInactiveSpan(options);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan } = options;\n\n // If `options.scope` is defined, we use this as as a wrapper,\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = options.scope\n ? (callback: () => Span) => withScope(options.scope, callback)\n : customParentSpan !== undefined\n ? (callback: () => Span) => withActiveSpan(customParentSpan, callback)\n : (callback: () => Span) => callback();\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n const client = getClient();\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n\n if (missingRequiredParent) {\n return startMissingRequiredParentSpan(scope, client);\n }\n\n return createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n });\n}\n\n/**\n * Continue a trace from `sentry-trace` and `baggage` values.\n * These values can be obtained from incoming request headers, or in the browser from `<meta name=\"sentry-trace\">`\n * and `<meta name=\"baggage\">` HTML tags.\n *\n * Spans started with `startSpan`, `startSpanManual` and `startInactiveSpan`, within the callback will automatically\n * be attached to the incoming trace.\n */\nexport const continueTrace = <V>(\n options: {\n sentryTrace: Parameters<typeof propagationContextFromHeaders>[0];\n baggage: Parameters<typeof propagationContextFromHeaders>[1];\n },\n callback: () => V,\n): V => {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.continueTrace) {\n return acs.continueTrace(options, callback);\n }\n\n const { sentryTrace, baggage } = options;\n\n const client = getClient();\n const incomingDsc = baggageHeaderToDynamicSamplingContext(baggage);\n if (client && !shouldContinueTrace(client, incomingDsc?.org_id)) {\n return startNewTrace(callback);\n }\n\n return withScope(scope => {\n const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);\n scope.setPropagationContext(propagationContext);\n _setSpanForScope(scope, undefined);\n return callback();\n });\n};\n\n/**\n * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be\n * passed `null` to start an entirely new span tree.\n *\n * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,\n * spans started within the callback will not be attached to a parent span.\n * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.\n * @returns the value returned from the provided callback function.\n */\nexport function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T {\n const acs = getAcs();\n if (acs.withActiveSpan) {\n return acs.withActiveSpan(span, callback);\n }\n\n return withScope(scope => {\n _setSpanForScope(scope, span || undefined);\n return callback(scope);\n });\n}\n\n/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */\nexport function suppressTracing<T>(callback: () => T): T {\n const acs = getAcs();\n\n if (acs.suppressTracing) {\n return acs.suppressTracing(callback);\n }\n\n return withScope(scope => {\n // Note: We do not wait for the callback to finish before we reset the metadata\n // the reason for this is that otherwise, in the browser this can lead to very weird behavior\n // as there is only a single top scope, if the callback takes longer to finish,\n // other, unrelated spans may also be suppressed, which we do not want\n // so instead, we only suppress tracing synchronoysly in the browser\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });\n const res = callback();\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: undefined });\n return res;\n });\n}\n\n/** Check if tracing is suppressed. */\nexport function isTracingSuppressed(scope = getCurrentScope()): boolean {\n const acs = getAcs();\n\n if (acs.isTracingSuppressed) {\n return acs.isTracingSuppressed(scope);\n }\n\n return scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY] === true;\n}\n\n/**\n * Starts a new trace for the duration of the provided callback. Spans started within the\n * callback will be part of the new trace instead of a potentially previously started trace.\n *\n * Important: Only use this function if you want to override the default trace lifetime and\n * propagation mechanism of the SDK for the duration and scope of the provided callback.\n * The newly created trace will also be the root of a new distributed trace, for example if\n * you make http requests within the callback.\n * This function might be useful if the operation you want to instrument should not be part\n * of a potentially ongoing trace.\n *\n * Default behavior:\n * - Server-side: A new trace is started for each incoming request.\n * - Browser: A new trace is started for each page our route. Navigating to a new route\n * or page will automatically create a new trace.\n */\nexport function startNewTrace<T>(callback: () => T): T {\n const acs = getAcs();\n if (acs.startNewTrace) {\n return acs.startNewTrace(callback);\n }\n\n return withScope(scope => {\n scope.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n DEBUG_BUILD && debug.log(`Starting a new trace with id ${scope.getPropagationContext().traceId}`);\n return withActiveSpan(null, callback);\n });\n}\n\n/**\n * The placeholder returned from `startSpan*` when `onlyIfParent` is set but there is no parent span.\n * It carries the current trace id and captured scopes so the trace data it propagates (and any nested\n * span that resolves it as its root via `getRootSpan`) reads its DSC from the scope, preserving a\n * continued trace's DSC instead of fabricating a fresh client one. Also records the dropped-span outcome.\n */\nfunction startMissingRequiredParentSpan(scope: Scope, client: Client | undefined): SentryNonRecordingSpan {\n client?.recordDroppedEvent('no_parent_span', 'span');\n const span = new SentryNonRecordingSpan({ traceId: scope.getPropagationContext().traceId });\n setCapturedScopesOnSpan(span, scope, getIsolationScope());\n return span;\n}\n\nfunction createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n}: {\n parentSpan: SentrySpan | undefined;\n spanArguments: SentrySpanArguments;\n forceTransaction?: boolean;\n scope: Scope;\n}): Span {\n const isolationScope = getIsolationScope();\n\n if (!hasSpansEnabled()) {\n const scopePropagationContext = { ...isolationScope.getPropagationContext(), ...scope.getPropagationContext() };\n const traceId = parentSpan ? parentSpan.spanContext().traceId : scopePropagationContext.traceId;\n\n // The placeholder is a thin marker; it carries no sampling decision or DSC. Both are read from\n // the scope: the sampling decision in `getTraceData`, the DSC in `getDynamicSamplingContextFromSpan`.\n const span = new SentryNonRecordingSpan({ traceId });\n\n // Nested placeholders link to their parent so `getRootSpan` resolves to the root placeholder,\n // whose captured scope is the source of truth. Root/forced placeholders are their own root.\n if (parentSpan && !forceTransaction) {\n addChildSpanToSpan(parentSpan, span);\n }\n\n // Capture scopes so consumers (e.g. SentryTraceProvider) can read them and so the DSC can be\n // resolved from the scope by `getDynamicSamplingContextFromSpan`. Consistent with `startIdleSpan`.\n setCapturedScopesOnSpan(span, scope, isolationScope);\n\n return span;\n }\n\n const client = getClient();\n if (_shouldIgnoreStreamedSpan(client, spanArguments)) {\n if (!isTracingSuppressed(scope)) {\n // if tracing is actively suppressed (Sentry.suppressTracing(...)),\n // we don't want to record a client outcome for the ignored span\n client?.recordDroppedEvent('ignored', 'span');\n }\n\n const ignoredSpan = new SentryNonRecordingSpan({\n dropReason: 'ignored',\n traceId: parentSpan?.spanContext().traceId ?? scope.getPropagationContext().traceId,\n });\n setCapturedScopesOnSpan(ignoredSpan, scope, isolationScope);\n\n return ignoredSpan;\n }\n\n let span: Span;\n if (parentSpan && !forceTransaction) {\n span = _startChildSpan(parentSpan, scope, spanArguments, isolationScope);\n addChildSpanToSpan(parentSpan, span);\n } else if (parentSpan) {\n // If we forced a transaction but have a parent span, make sure to continue from the parent span, not the scope\n const dsc = getDynamicSamplingContextFromSpan(parentSpan);\n const { traceId, spanId: parentSpanId } = parentSpan.spanContext();\n const parentSampled = spanIsSampled(parentSpan);\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n isolationScope,\n parentSampled,\n );\n\n freezeDscOnSpan(span, dsc);\n } else {\n const {\n traceId,\n dsc,\n parentSpanId,\n sampled: parentSampled,\n } = {\n ...isolationScope.getPropagationContext(),\n ...scope.getPropagationContext(),\n };\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n isolationScope,\n parentSampled,\n );\n\n if (dsc) {\n freezeDscOnSpan(span, dsc);\n }\n }\n\n logSpanStart(span);\n\n return span;\n}\n\n/**\n * This converts StartSpanOptions to SentrySpanArguments.\n * For the most part (for now) we accept the same options,\n * but some of them need to be transformed.\n */\nfunction parseSentrySpanArguments(options: StartSpanOptions): SentrySpanArguments {\n const exp = options.experimental || {};\n const initialCtx: SentrySpanArguments = {\n isStandalone: exp.standalone,\n ...options,\n };\n\n if (options.startTime) {\n const ctx: SentrySpanArguments & { startTime?: SpanTimeInput } = { ...initialCtx };\n ctx.startTimestamp = spanTimeInputToSeconds(options.startTime);\n delete ctx.startTime;\n return ctx;\n }\n\n return initialCtx;\n}\n\nfunction getAcs(): AsyncContextStrategy {\n const carrier = getMainCarrier();\n return getAsyncContextStrategy(carrier);\n}\n\nfunction _startRootSpan(\n spanArguments: SentrySpanArguments,\n scope: Scope,\n isolationScope: Scope,\n parentSampled?: boolean,\n): SentrySpan {\n const client = getClient();\n const options: Partial<ClientOptions> = client?.getOptions() || {};\n\n const { name = '' } = spanArguments;\n\n const mutableSpanSamplingData = { spanAttributes: { ...spanArguments.attributes }, spanName: name, parentSampled };\n\n // we don't care about the decision for the moment; this is just a placeholder\n client?.emit('beforeSampling', mutableSpanSamplingData, { decision: false });\n\n // If hook consumers override the parentSampled flag, we will use that value instead of the actual one\n const finalParentSampled = mutableSpanSamplingData.parentSampled ?? parentSampled;\n const finalAttributes = mutableSpanSamplingData.spanAttributes;\n\n const currentPropagationContext = scope.getPropagationContext();\n const _isTracingSuppressed = isTracingSuppressed(scope);\n\n const [sampled, sampleRate, localSampleRateWasApplied] = _isTracingSuppressed\n ? [false]\n : sampleSpan(\n options,\n {\n name,\n parentSampled: finalParentSampled,\n attributes: finalAttributes,\n normalizedRequest: isolationScope.getScopeData().sdkProcessingMetadata.normalizedRequest,\n parentSampleRate: parseSampleRate(currentPropagationContext.dsc?.sample_rate),\n },\n currentPropagationContext.sampleRand,\n );\n\n const rootSpan = new SentrySpan({\n ...spanArguments,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]:\n sampleRate !== undefined && localSampleRateWasApplied ? sampleRate : undefined,\n ...finalAttributes,\n },\n sampled,\n });\n\n if (!sampled && client && !_isTracingSuppressed) {\n DEBUG_BUILD && debug.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');\n client.recordDroppedEvent('sample_rate', hasSpanStreamingEnabled(client) ? 'span' : 'transaction');\n }\n\n setCapturedScopesOnSpan(rootSpan, scope, isolationScope);\n\n if (client) {\n client.emit('spanStart', rootSpan);\n }\n\n return rootSpan;\n}\n\n/**\n * Creates a new `Span` while setting the current `Span.id` as `parentSpanId`.\n * This inherits the sampling decision from the parent span.\n */\nfunction _startChildSpan(\n parentSpan: Span,\n scope: Scope,\n spanArguments: SentrySpanArguments,\n isolationScope: Scope,\n): Span {\n const { spanId, traceId } = parentSpan.spanContext();\n const _isTracingSuppressed = isTracingSuppressed(scope);\n const sampled = _isTracingSuppressed ? false : spanIsSampled(parentSpan);\n\n const childSpan = sampled\n ? new SentrySpan({\n ...spanArguments,\n parentSpanId: spanId,\n traceId,\n sampled,\n })\n : new SentryNonRecordingSpan({ traceId });\n\n addChildSpanToSpan(parentSpan, childSpan);\n\n setCapturedScopesOnSpan(childSpan, scope, isolationScope);\n\n const client = getClient();\n\n if (!client) {\n return childSpan;\n }\n\n if (hasSpanStreamingEnabled(client) && spanIsNonRecordingSpan(childSpan)) {\n if (spanIsNonRecordingSpan(parentSpan) && parentSpan.dropReason) {\n // We land here if the parent span was a segment span that was ignored (`ignoreSpans`).\n // In this case, the child was also ignored (see `sampled` above) but we need to\n // record a client outcome for the child.\n childSpan.dropReason = parentSpan.dropReason;\n client.recordDroppedEvent(parentSpan.dropReason, 'span');\n } else if (!_isTracingSuppressed) {\n // Otherwise, the child is not sampled due to sampling of the parent span,\n // hence we record a sample_rate client outcome for the child.\n childSpan.dropReason = 'sample_rate';\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n\n client.emit('spanStart', childSpan);\n // If it has an endTimestamp, it's already ended\n if (spanArguments.endTimestamp) {\n client.emit('spanEnd', childSpan);\n client.emit('afterSpanEnd', childSpan);\n }\n\n return childSpan;\n}\n\nfunction getParentSpan(scope: Scope, customParentSpan: Span | null | undefined): SentrySpan | undefined {\n // always use the passed in span directly\n if (customParentSpan) {\n return customParentSpan as SentrySpan;\n }\n\n // This is different from `undefined` as it means the user explicitly wants no parent span\n if (customParentSpan === null) {\n return undefined;\n }\n\n const span = _getSpanForScope(scope) as SentrySpan | undefined;\n\n if (!span) {\n return undefined;\n }\n\n const client = getClient();\n const options: Partial<ClientOptions> = client ? client.getOptions() : {};\n if (options.parentSpanIsAlwaysRootSpan) {\n return getRootSpan(span) as SentrySpan;\n }\n\n return span;\n}\n\nfunction getActiveSpanWrapper<T>(parentSpan: Span | undefined | null): (callback: () => T) => T {\n return parentSpan !== undefined\n ? (callback: () => T) => {\n return withActiveSpan(parentSpan, callback);\n }\n : (callback: () => T) => callback();\n}\n\n/* Checks if `ignoreSpans` applies (extracted for bundle size)*/\nfunction _shouldIgnoreStreamedSpan(client: Client | undefined, spanArguments: SentrySpanArguments): boolean {\n const ignoreSpans = client?.getOptions().ignoreSpans;\n\n if (!client || !hasSpanStreamingEnabled(client) || !ignoreSpans?.length) {\n return false;\n }\n\n return shouldIgnoreSpan(\n {\n description: spanArguments.name || '',\n op: spanArguments.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP] || spanArguments.op,\n attributes: spanArguments.attributes,\n },\n ignoreSpans,\n );\n}\n\nfunction _isIgnoredSpan(span: Span): span is SentryNonRecordingSpan {\n return spanIsNonRecordingSpan(span) && span.dropReason === 'ignored';\n}\n"],"names":["span"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,MAAM,oBAAA,GAAuB;AAY7B,SAAS,SAAA,CAAa,SAA2B,QAAA,EAAgC;AACtF,EAAA,MAAM,MAAM,MAAA,EAAO;AACnB,EAAA,IAAI,IAAI,SAAA,EAAW;AACjB,IAAA,OAAO,GAAA,CAAI,SAAA,CAAU,OAAA,EAAS,QAAQ,CAAA;AAAA,EACxC;AAEA,EAAA,MAAM,aAAA,GAAgB,yBAAyB,OAAO,CAAA;AACtD,EAAA,MAAM,EAAE,gBAAA,EAAkB,UAAA,EAAY,gBAAA,EAAkB,KAAA,EAAO,aAAY,GAAI,OAAA;AAI/E,EAAA,MAAM,iBAAA,GAAoB,aAAa,KAAA,EAAM;AAE7C,EAAA,OAAO,SAAA,CAAU,mBAAmB,MAAM;AAExC,IAAA,MAAM,OAAA,GAAU,qBAAwB,gBAAgB,CAAA;AAExD,IAAA,OAAO,QAAQ,MAAM;AACnB,MAAA,MAAM,QAAQ,eAAA,EAAgB;AAC9B,MAAA,MAAM,UAAA,GAAa,aAAA,CAAc,KAAA,EAAO,gBAAgB,CAAA;AACxD,MAAA,MAAM,SAAS,SAAA,EAAU;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n\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { AsyncContextStrategy } from '../asyncContext/types';\nimport { getMainCarrier } from '../carrier';\nimport { getClient, getCurrentScope, getIsolationScope, withScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Scope } from '../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { ClientOptions } from '../types/options';\nimport type { SentrySpanArguments, Span, SpanTimeInput } from '../types/span';\nimport type { StartSpanOptions } from '../types/startSpanOptions';\nimport { baggageHeaderToDynamicSamplingContext } from '../utils/baggage';\nimport { debug } from '../utils/debug-logger';\nimport { handleCallbackErrors } from '../utils/handleCallbackErrors';\nimport { hasSpansEnabled } from '../utils/hasSpansEnabled';\nimport { shouldIgnoreSpan } from '../utils/should-ignore-span';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport { parseSampleRate } from '../utils/parseSampleRate';\nimport { generateTraceId } from '../utils/propagationContext';\nimport { safeMathRandom } from '../utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from '../utils/spanOnScope';\nimport { addChildSpanToSpan, getRootSpan, spanIsSampled, spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils';\nimport { propagationContextFromHeaders, shouldContinueTrace } from '../utils/tracing';\nimport { freezeDscOnSpan, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanStart } from './logSpans';\nimport { sampleSpan } from './sampling';\nimport { SentryNonRecordingSpan, spanIsNonRecordingSpan } from './sentryNonRecordingSpan';\nimport { SentrySpan } from './sentrySpan';\nimport { SPAN_STATUS_ERROR } from './spanstatus';\nimport { setCapturedScopesOnSpan } from './utils';\nimport type { Client } from '../client';\n\nexport const SUPPRESS_TRACING_KEY = '__SENTRY_SUPPRESS_TRACING__';\n\n/**\n * Wraps a function with a transaction/span and finishes the span after the function is done.\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * If you want to create a span that is not set as active, use {@link startInactiveSpan}.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T): T {\n const acs = getAcs();\n if (acs.startSpan) {\n return acs.startSpan(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n // We still need to fork a potentially passed scope, as we set the active span on it\n // and we need to ensure that it is cleaned up properly once the span ends.\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n const client = getClient();\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n const activeSpan = missingRequiredParent\n ? startMissingRequiredParentSpan(scope, client)\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n // Ignored root spans still need to be set on scope so that `getActiveSpan()` returns them\n // and descendants are also non-recording. Ignored child spans don't need this because\n // the parent span is already on scope.\n if (!spanIsIgnored(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n () => callback(activeSpan),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n () => {\n activeSpan.end();\n },\n );\n });\n });\n}\n\n/**\n * Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span\n * after the function is done automatically. Use `span.end()` to end the span.\n *\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpanManual<T>(options: StartSpanOptions, callback: (span: Span, finish: () => void) => T): T {\n const acs = getAcs();\n if (acs.startSpanManual) {\n return acs.startSpanManual(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n const activeSpan = missingRequiredParent\n ? startMissingRequiredParentSpan(scope, getClient())\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n // We don't set ignored child spans onto the scope because there likely is an active,\n // unignored span on the scope already.\n if (!spanIsIgnored(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n // We pass the `finish` function to the callback, so the user can finish the span manually\n // this is mainly here for historic purposes because previously, we instructed users to call\n // `finish` instead of `span.end()` to also clean up the scope. Nowadays, calling `span.end()`\n // or `finish` has the same effect and we simply leave it here to avoid breaking user code.\n () => callback(activeSpan, () => activeSpan.end()),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n );\n });\n });\n}\n\n/**\n * Creates a span. This span is not set as active, so will not get automatic instrumentation spans\n * as children or be able to be accessed via `Sentry.getActiveSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * This function will always return a span,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startInactiveSpan(options: StartSpanOptions): Span {\n const acs = getAcs();\n if (acs.startInactiveSpan) {\n return acs.startInactiveSpan(options);\n }\n\n return _startInactiveSpanImpl(options);\n}\n\n/**\n * Internal version of startInactiveSpan that bypasses the ACS check.\n * Used by SentryTracerProvider to create spans without triggering recursion\n * through ACS overrides.\n * @hidden\n */\nexport function _INTERNAL_startInactiveSpan(options: StartSpanOptions): Span {\n return _startInactiveSpanImpl(options);\n}\n\nfunction _startInactiveSpanImpl(options: StartSpanOptions): Span {\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan } = options;\n\n // If `options.scope` is defined, we use this as as a wrapper,\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = options.scope\n ? (callback: () => Span) => withScope(options.scope, callback)\n : customParentSpan !== undefined\n ? (callback: () => Span) => withActiveSpan(customParentSpan, callback)\n : (callback: () => Span) => callback();\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n const client = getClient();\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n\n if (missingRequiredParent) {\n return startMissingRequiredParentSpan(scope, client);\n }\n\n return createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n });\n}\n\n/**\n * Continue a trace from `sentry-trace` and `baggage` values.\n * These values can be obtained from incoming request headers, or in the browser from `<meta name=\"sentry-trace\">`\n * and `<meta name=\"baggage\">` HTML tags.\n *\n * Spans started with `startSpan`, `startSpanManual` and `startInactiveSpan`, within the callback will automatically\n * be attached to the incoming trace.\n */\nexport const continueTrace = <V>(\n options: {\n sentryTrace: Parameters<typeof propagationContextFromHeaders>[0];\n baggage: Parameters<typeof propagationContextFromHeaders>[1];\n },\n callback: () => V,\n): V => {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.continueTrace) {\n return acs.continueTrace(options, callback);\n }\n\n const { sentryTrace, baggage } = options;\n\n const client = getClient();\n const incomingDsc = baggageHeaderToDynamicSamplingContext(baggage);\n if (client && !shouldContinueTrace(client, incomingDsc?.org_id)) {\n return startNewTrace(callback);\n }\n\n return withScope(scope => {\n const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);\n scope.setPropagationContext(propagationContext);\n _setSpanForScope(scope, undefined);\n return callback();\n });\n};\n\n/**\n * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be\n * passed `null` to start an entirely new span tree.\n *\n * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,\n * spans started within the callback will not be attached to a parent span.\n * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.\n * @returns the value returned from the provided callback function.\n */\nexport function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T {\n const acs = getAcs();\n if (acs.withActiveSpan) {\n return acs.withActiveSpan(span, callback);\n }\n\n return withScope(scope => {\n _setSpanForScope(scope, span || undefined);\n return callback(scope);\n });\n}\n\n/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */\nexport function suppressTracing<T>(callback: () => T): T {\n const acs = getAcs();\n\n if (acs.suppressTracing) {\n return acs.suppressTracing(callback);\n }\n\n return withScope(scope => {\n // Note: We do not wait for the callback to finish before we reset the metadata\n // the reason for this is that otherwise, in the browser this can lead to very weird behavior\n // as there is only a single top scope, if the callback takes longer to finish,\n // other, unrelated spans may also be suppressed, which we do not want\n // so instead, we only suppress tracing synchronoysly in the browser\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });\n const res = callback();\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: undefined });\n return res;\n });\n}\n\n/** Check if tracing is suppressed. */\nexport function isTracingSuppressed(scope = getCurrentScope()): boolean {\n const acs = getAcs();\n\n if (acs.isTracingSuppressed) {\n return acs.isTracingSuppressed(scope);\n }\n\n return scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY] === true;\n}\n\n/**\n * Starts a new trace for the duration of the provided callback. Spans started within the\n * callback will be part of the new trace instead of a potentially previously started trace.\n *\n * Important: Only use this function if you want to override the default trace lifetime and\n * propagation mechanism of the SDK for the duration and scope of the provided callback.\n * The newly created trace will also be the root of a new distributed trace, for example if\n * you make http requests within the callback.\n * This function might be useful if the operation you want to instrument should not be part\n * of a potentially ongoing trace.\n *\n * Default behavior:\n * - Server-side: A new trace is started for each incoming request.\n * - Browser: A new trace is started for each page our route. Navigating to a new route\n * or page will automatically create a new trace.\n */\nexport function startNewTrace<T>(callback: () => T): T {\n const acs = getAcs();\n if (acs.startNewTrace) {\n return acs.startNewTrace(callback);\n }\n\n return withScope(scope => {\n scope.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n DEBUG_BUILD && debug.log(`Starting a new trace with id ${scope.getPropagationContext().traceId}`);\n return withActiveSpan(null, callback);\n });\n}\n\n/**\n * The placeholder returned from `startSpan*` when `onlyIfParent` is set but there is no parent span.\n * It carries the current trace id and captured scopes so the trace data it propagates (and any nested\n * span that resolves it as its root via `getRootSpan`) reads its DSC from the scope, preserving a\n * continued trace's DSC instead of fabricating a fresh client one. Also records the dropped-span outcome.\n */\nfunction startMissingRequiredParentSpan(scope: Scope, client: Client | undefined): SentryNonRecordingSpan {\n client?.recordDroppedEvent('no_parent_span', 'span');\n const span = new SentryNonRecordingSpan({ traceId: scope.getPropagationContext().traceId });\n setCapturedScopesOnSpan(span, scope, getIsolationScope());\n return span;\n}\n\nfunction createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n}: {\n parentSpan: SentrySpan | undefined;\n spanArguments: SentrySpanArguments;\n forceTransaction?: boolean;\n scope: Scope;\n}): Span {\n const isolationScope = getIsolationScope();\n\n if (!hasSpansEnabled()) {\n const scopePropagationContext = { ...isolationScope.getPropagationContext(), ...scope.getPropagationContext() };\n const traceId = parentSpan ? parentSpan.spanContext().traceId : scopePropagationContext.traceId;\n\n // The placeholder is a thin marker; it carries no sampling decision or DSC. Both are read from\n // the scope: the sampling decision in `getTraceData`, the DSC in `getDynamicSamplingContextFromSpan`.\n const span = new SentryNonRecordingSpan({ traceId });\n\n // Nested placeholders link to their parent so `getRootSpan` resolves to the root placeholder,\n // whose captured scope is the source of truth. Root/forced placeholders are their own root.\n if (parentSpan && !forceTransaction) {\n addChildSpanToSpan(parentSpan, span);\n }\n\n // Capture scopes so consumers (e.g. SentryTraceProvider) can read them and so the DSC can be\n // resolved from the scope by `getDynamicSamplingContextFromSpan`. Consistent with `startIdleSpan`.\n setCapturedScopesOnSpan(span, scope, isolationScope);\n\n return span;\n }\n\n const client = getClient();\n if (_shouldIgnoreStreamedSpan(client, spanArguments)) {\n if (!isTracingSuppressed(scope)) {\n // if tracing is actively suppressed (Sentry.suppressTracing(...)),\n // we don't want to record a client outcome for the ignored span\n client?.recordDroppedEvent('ignored', 'span');\n }\n\n const ignoredSpan = new SentryNonRecordingSpan({\n dropReason: 'ignored',\n traceId: parentSpan?.spanContext().traceId ?? scope.getPropagationContext().traceId,\n });\n setCapturedScopesOnSpan(ignoredSpan, scope, isolationScope);\n\n return ignoredSpan;\n }\n\n let span: Span;\n if (parentSpan && !forceTransaction) {\n span = _startChildSpan(parentSpan, scope, spanArguments, isolationScope);\n addChildSpanToSpan(parentSpan, span);\n } else if (parentSpan) {\n // If we forced a transaction but have a parent span, make sure to continue from the parent span, not the scope\n const dsc = getDynamicSamplingContextFromSpan(parentSpan);\n const { traceId, spanId: parentSpanId } = parentSpan.spanContext();\n const parentSampled = spanIsSampled(parentSpan);\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n isolationScope,\n parentSampled,\n );\n\n freezeDscOnSpan(span, dsc);\n } else {\n const {\n traceId,\n dsc,\n parentSpanId,\n sampled: parentSampled,\n } = {\n ...isolationScope.getPropagationContext(),\n ...scope.getPropagationContext(),\n };\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n isolationScope,\n parentSampled,\n );\n\n if (dsc) {\n freezeDscOnSpan(span, dsc);\n }\n }\n\n logSpanStart(span);\n\n return span;\n}\n\n/**\n * This converts StartSpanOptions to SentrySpanArguments.\n * For the most part (for now) we accept the same options,\n * but some of them need to be transformed.\n */\nfunction parseSentrySpanArguments(options: StartSpanOptions): SentrySpanArguments {\n const exp = options.experimental || {};\n const initialCtx: SentrySpanArguments = {\n isStandalone: exp.standalone,\n ...options,\n };\n\n if (options.startTime) {\n const ctx: SentrySpanArguments & { startTime?: SpanTimeInput } = { ...initialCtx };\n ctx.startTimestamp = spanTimeInputToSeconds(options.startTime);\n delete ctx.startTime;\n return ctx;\n }\n\n return initialCtx;\n}\n\nfunction getAcs(): AsyncContextStrategy {\n const carrier = getMainCarrier();\n return getAsyncContextStrategy(carrier);\n}\n\nfunction _startRootSpan(\n spanArguments: SentrySpanArguments,\n scope: Scope,\n isolationScope: Scope,\n parentSampled?: boolean,\n): SentrySpan {\n const client = getClient();\n const options: Partial<ClientOptions> = client?.getOptions() || {};\n\n const { name = '' } = spanArguments;\n\n const mutableSpanSamplingData = { spanAttributes: { ...spanArguments.attributes }, spanName: name, parentSampled };\n\n // we don't care about the decision for the moment; this is just a placeholder\n client?.emit('beforeSampling', mutableSpanSamplingData, { decision: false });\n\n // If hook consumers override the parentSampled flag, we will use that value instead of the actual one\n const finalParentSampled = mutableSpanSamplingData.parentSampled ?? parentSampled;\n const finalAttributes = mutableSpanSamplingData.spanAttributes;\n\n const currentPropagationContext = scope.getPropagationContext();\n const _isTracingSuppressed = isTracingSuppressed(scope);\n\n const [sampled, sampleRate, localSampleRateWasApplied] = _isTracingSuppressed\n ? [false]\n : sampleSpan(\n options,\n {\n name,\n parentSampled: finalParentSampled,\n attributes: finalAttributes,\n normalizedRequest: isolationScope.getScopeData().sdkProcessingMetadata.normalizedRequest,\n parentSampleRate: parseSampleRate(currentPropagationContext.dsc?.sample_rate),\n },\n currentPropagationContext.sampleRand,\n );\n\n const rootSpan = new SentrySpan({\n ...spanArguments,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]:\n sampleRate !== undefined && localSampleRateWasApplied ? sampleRate : undefined,\n ...finalAttributes,\n },\n sampled,\n });\n\n if (!sampled && client && !_isTracingSuppressed) {\n DEBUG_BUILD && debug.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');\n client.recordDroppedEvent('sample_rate', hasSpanStreamingEnabled(client) ? 'span' : 'transaction');\n }\n\n setCapturedScopesOnSpan(rootSpan, scope, isolationScope);\n\n if (client) {\n client.emit('spanStart', rootSpan);\n }\n\n return rootSpan;\n}\n\n/**\n * Creates a new `Span` while setting the current `Span.id` as `parentSpanId`.\n * This inherits the sampling decision from the parent span.\n */\nfunction _startChildSpan(\n parentSpan: Span,\n scope: Scope,\n spanArguments: SentrySpanArguments,\n isolationScope: Scope,\n): Span {\n const { spanId, traceId } = parentSpan.spanContext();\n const _isTracingSuppressed = isTracingSuppressed(scope);\n const sampled = _isTracingSuppressed ? false : spanIsSampled(parentSpan);\n\n const childSpan = sampled\n ? new SentrySpan({\n ...spanArguments,\n parentSpanId: spanId,\n traceId,\n sampled,\n })\n : new SentryNonRecordingSpan({ traceId });\n\n addChildSpanToSpan(parentSpan, childSpan);\n\n setCapturedScopesOnSpan(childSpan, scope, isolationScope);\n\n const client = getClient();\n\n if (!client) {\n return childSpan;\n }\n\n if (hasSpanStreamingEnabled(client) && spanIsNonRecordingSpan(childSpan)) {\n if (spanIsNonRecordingSpan(parentSpan) && parentSpan.dropReason) {\n // We land here if the parent span was a segment span that was ignored (`ignoreSpans`).\n // In this case, the child was also ignored (see `sampled` above) but we need to\n // record a client outcome for the child.\n childSpan.dropReason = parentSpan.dropReason;\n client.recordDroppedEvent(parentSpan.dropReason, 'span');\n } else if (!_isTracingSuppressed) {\n // Otherwise, the child is not sampled due to sampling of the parent span,\n // hence we record a sample_rate client outcome for the child.\n childSpan.dropReason = 'sample_rate';\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n\n client.emit('spanStart', childSpan);\n // If it has an endTimestamp, it's already ended\n if (spanArguments.endTimestamp) {\n client.emit('spanEnd', childSpan);\n client.emit('afterSpanEnd', childSpan);\n }\n\n return childSpan;\n}\n\nfunction getParentSpan(scope: Scope, customParentSpan: Span | null | undefined): SentrySpan | undefined {\n // always use the passed in span directly\n if (customParentSpan) {\n return customParentSpan as SentrySpan;\n }\n\n // This is different from `undefined` as it means the user explicitly wants no parent span\n if (customParentSpan === null) {\n return undefined;\n }\n\n const span = _getSpanForScope(scope) as SentrySpan | undefined;\n\n if (!span) {\n return undefined;\n }\n\n const client = getClient();\n const options: Partial<ClientOptions> = client ? client.getOptions() : {};\n if (options.parentSpanIsAlwaysRootSpan) {\n return getRootSpan(span) as SentrySpan;\n }\n\n return span;\n}\n\nfunction getActiveSpanWrapper<T>(parentSpan: Span | undefined | null): (callback: () => T) => T {\n return parentSpan !== undefined\n ? (callback: () => T) => {\n return withActiveSpan(parentSpan, callback);\n }\n : (callback: () => T) => callback();\n}\n\n/* Checks if `ignoreSpans` applies (extracted for bundle size)*/\nfunction _shouldIgnoreStreamedSpan(client: Client | undefined, spanArguments: SentrySpanArguments): boolean {\n const ignoreSpans = client?.getOptions().ignoreSpans;\n\n if (!client || !hasSpanStreamingEnabled(client) || !ignoreSpans?.length) {\n return false;\n }\n\n return shouldIgnoreSpan(\n {\n description: spanArguments.name || '',\n op: spanArguments.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP] || spanArguments.op,\n attributes: spanArguments.attributes,\n },\n ignoreSpans,\n );\n}\n\n/**\n * Whether a span is an ignored (`ignoreSpans`) placeholder. Such a span must not be set as the active\n * span when it has a parent, so its children attach to that parent and get re-parented rather than\n * dropped with it. Shared with the OTel-based provider so both span pipelines apply the same rule.\n */\nexport function spanIsIgnored(span: Span): span is SentryNonRecordingSpan {\n return spanIsNonRecordingSpan(span) && span.dropReason === 'ignored';\n}\n"],"names":["span"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,MAAM,oBAAA,GAAuB;AAY7B,SAAS,SAAA,CAAa,SAA2B,QAAA,EAAgC;AACtF,EAAA,MAAM,MAAM,MAAA,EAAO;AACnB,EAAA,IAAI,IAAI,SAAA,EAAW;AACjB,IAAA,OAAO,GAAA,CAAI,SAAA,CAAU,OAAA,EAAS,QAAQ,CAAA;AAAA,EACxC;AAEA,EAAA,MAAM,aAAA,GAAgB,yBAAyB,OAAO,CAAA;AACtD,EAAA,MAAM,EAAE,gBAAA,EAAkB,UAAA,EAAY,gBAAA,EAAkB,KAAA,EAAO,aAAY,GAAI,OAAA;AAI/E,EAAA,MAAM,iBAAA,GAAoB,aAAa,KAAA,EAAM;AAE7C,EAAA,OAAO,SAAA,CAAU,mBAAmB,MAAM;AAExC,IAAA,MAAM,OAAA,GAAU,qBAAwB,gBAAgB,CAAA;AAExD,IAAA,OAAO,QAAQ,MAAM;AACnB,MAAA,MAAM,QAAQ,eAAA,EAAgB;AAC9B,MAAA,MAAM,UAAA,GAAa,aAAA,CAAc,KAAA,EAAO,gBAAgB,CAAA;AACxD,MAAA,MAAM,SAAS,SAAA,EAAU;AAEzB,MAAA,MAAM,qBAAA,GAAwB,OAAA,CAAQ,YAAA,IAAgB,CAAC,UAAA;AACvD,MAAA,MAAM,aAAa,qBAAA,GACf,8BAAA,CAA+B,KAAA,EAAO,MAAM,IAC5C,qBAAA,CAAsB;AAAA,QACpB,UAAA;AAAA,QACA,aAAA;AAAA,QACA,gBAAA;AAAA,QACA;AAAA,OACD,CAAA;AAKL,MAAA,IAAI,CAAC,aAAA,CAAc,UAAU,CAAA,IAAK,CAAC,UAAA,EAAY;AAC7C,QAAA,gBAAA,CAAiB,OAAO,UAAU,CAAA;AAAA,MACpC;A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AAe,EAAC;AACxE,EAAA,IAAI,QAAQ,0BAAA,EAA4B;AACtC,IAAA,OAAO,YAAY,IAAI,CAAA;AAAA,EACzB;AAEA,EAAA,OAAO,IAAA;AACT;AAEA,SAAS,qBAAwB,UAAA,EAA+D;AAC9F,EAAA,OAAO,UAAA,KAAe,MAAA,GAClB,CAAC,QAAA,KAAsB;AACrB,IAAA,OAAO,cAAA,CAAe,YAAY,QAAQ,CAAA;AAAA,EAC5C,CAAA,GACA,CAAC,QAAA,KAAsB,QAAA,EAAS;AACtC;AAGA,SAAS,yBAAA,CAA0B,QAA4B,aAAA,EAA6C;AAC1G,EAAA,MAAM,WAAA,GAAc,MAAA,EAAQ,UAAA,EAAW,CAAE,WAAA;AAEzC,EAAA,IAAI,CAAC,UAAU,CAAC,uBAAA,CAAwB,MAAM,CAAA,IAAK,CAAC,aAAa,MAAA,EAAQ;AACvE,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAO,gBAAA;AAAA,IACL;AAAA,MACE,WAAA,EAAa,cAAc,IAAA,IAAQ,EAAA;AAAA,MACnC,EAAA,EAAI,aAAA,CAAc,UAAA,GAAa,4BAA4B,KAAK,aAAA,CAAc,EAAA;AAAA,MAC9E,YAAY,aAAA,CAAc;AAAA,KAC5B;AAAA,IACA;AAAA,GACF;AACF;AAOO,SAAS,cAAc,IAAA,EAA4C;AACxE,EAAA,OAAO,sBAAA,CAAuB,IAAI,CAAA,IAAK,IAAA,CAAK,UAAA,KAAe,SAAA;AAC7D;;;;"} |
@@ -7,2 +7,4 @@ import { addNonEnumerableProperty } from '../utils/object.js'; | ||
| const OTEL_SOURCE_INFERENCE_SPAN_FIELD = /* @__PURE__ */ Symbol.for("sentry.otelSourceInference"); | ||
| const OTEL_SOURCE_EXPLICITLY_SET_SPAN_FIELD = /* @__PURE__ */ Symbol.for("sentry.otelSourceExplicitlySet"); | ||
| const TRACER_PROVIDER_SPAN_FIELD = /* @__PURE__ */ Symbol.for("sentry.tracerProviderSpan"); | ||
| function setCapturedScopesOnSpan(span, scope, isolationScope) { | ||
@@ -27,4 +29,16 @@ if (span) { | ||
| } | ||
| function markSpanSourceAsExplicit(span) { | ||
| addNonEnumerableProperty(span, OTEL_SOURCE_EXPLICITLY_SET_SPAN_FIELD, true); | ||
| } | ||
| function spanSourceWasExplicitlySet(span) { | ||
| return span[OTEL_SOURCE_EXPLICITLY_SET_SPAN_FIELD] === true; | ||
| } | ||
| function markSpanAsTracerProviderSpan(span) { | ||
| addNonEnumerableProperty(span, TRACER_PROVIDER_SPAN_FIELD, true); | ||
| } | ||
| function spanIsTracerProviderSpan(span) { | ||
| return span[TRACER_PROVIDER_SPAN_FIELD] === true; | ||
| } | ||
| export { getCapturedScopesOnSpan, markSpanForOtelSourceInference, setCapturedScopesOnSpan, spanShouldInferOtelSource }; | ||
| export { getCapturedScopesOnSpan, markSpanAsTracerProviderSpan, markSpanForOtelSourceInference, markSpanSourceAsExplicit, setCapturedScopesOnSpan, spanIsTracerProviderSpan, spanShouldInferOtelSource, spanSourceWasExplicitlySet }; | ||
| //# sourceMappingURL=utils.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"utils.js","sources":["../../../src/tracing/utils.ts"],"sourcesContent":["import type { Scope } from '../scope';\nimport type { Span } from '../types/span';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { derefWeakRef, makeWeakRef, type MaybeWeakRef } from '../utils/weakRef';\n\nconst SCOPE_ON_START_SPAN_FIELD = '_sentryScope';\nconst ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';\n\n// Brand marking a span whose `sentry.source` should be inferred OTel-style at span end (by\n// `applyOtelSpanData`) rather than pinned. `SentryTraceProvider` sets it on the spans it creates\n// so they behave like OTel SDK spans, which carry no Sentry source concept. We use `Symbol.for`\n// so the key is shared across duplicated copies of `@sentry/core`.\nconst OTEL_SOURCE_INFERENCE_SPAN_FIELD = Symbol.for('sentry.otelSourceInference');\n\ntype SpanWithScopes = Span & {\n [SCOPE_ON_START_SPAN_FIELD]?: Scope;\n [ISOLATION_SCOPE_ON_START_SPAN_FIELD]?: MaybeWeakRef<Scope>;\n};\n\ntype SpanWithOtelSourceInference = Span & {\n [OTEL_SOURCE_INFERENCE_SPAN_FIELD]?: boolean;\n};\n\n/** Store the scope & isolation scope for a span, which can the be used when it is finished. */\nexport function setCapturedScopesOnSpan(span: Span | undefined, scope: Scope, isolationScope: Scope): void {\n if (span) {\n addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, makeWeakRef(isolationScope));\n // We don't wrap the scope with a WeakRef here because webkit aggressively garbage collects\n // and scopes are not held in memory for long periods of time.\n addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);\n }\n}\n\n/**\n * Grabs the scope and isolation scope off a span that were active when the span was started.\n * If WeakRef was used and scopes have been garbage collected, returns undefined for those scopes.\n */\nexport function getCapturedScopesOnSpan(span: Span): { scope?: Scope; isolationScope?: Scope } {\n const spanWithScopes = span as SpanWithScopes;\n\n return {\n scope: spanWithScopes[SCOPE_ON_START_SPAN_FIELD],\n isolationScope: derefWeakRef(spanWithScopes[ISOLATION_SCOPE_ON_START_SPAN_FIELD]),\n };\n}\n\n/**\n * Mark a span as eligible for OTel-style `sentry.source` inference at span end.\n * Set by `SentryTraceProvider` on the spans it creates; read by `SentrySpan.updateName()` and\n * `applyOtelSpanData()`.\n */\nexport function markSpanForOtelSourceInference(span: Span): void {\n addNonEnumerableProperty(span, OTEL_SOURCE_INFERENCE_SPAN_FIELD, true);\n}\n\n/** Whether a span is marked for OTel-style `sentry.source` inference (see {@link markSpanForOtelSourceInference}). */\nexport function spanShouldInferOtelSource(span: Span): boolean {\n return (span as SpanWithOtelSourceInference)[OTEL_SOURCE_INFERENCE_SPAN_FIELD] === true;\n}\n"],"names":[],"mappings":";;;AAKA,MAAM,yBAAA,GAA4B,cAAA;AAClC,MAAM,mCAAA,GAAsC,uBAAA;AAM5C,MAAM,gCAAA,mBAAmC,MAAA,CAAO,GAAA,CAAI,4BAA4B,CAAA;AAYzE,SAAS,uBAAA,CAAwB,IAAA,EAAwB,KAAA,EAAc,cAAA,EAA6B;AACzG,EAAA,IAAI,IAAA,EAAM;AACR,IAAA,wBAAA,CAAyB,IAAA,EAAM,mCAAA,EAAqC,WAAA,CAAY,cAAc,CAAC,CAAA;AAG/F,IAAA,wBAAA,CAAyB,IAAA,EAAM,2BAA2B,KAAK,CAAA;AAAA,EACjE;AACF;AAMO,SAAS,wBAAwB,IAAA,EAAuD;AAC7F,EAAA,MAAM,cAAA,GAAiB,IAAA;AAEvB,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,eAAe,yBAAyB,CAAA;AAAA,IAC/C,cAAA,EAAgB,YAAA,CAAa,cAAA,CAAe,mCAAmC,CAAC;AAAA,GAClF;AACF;AAOO,SAAS,+BAA+B,IAAA,EAAkB;AAC/D,EAAA,wBAAA,CAAyB,IAAA,EAAM,kCAAkC,IAAI,CAAA;AACvE;AAGO,SAAS,0BAA0B,IAAA,EAAqB;AAC7D,EAAA,OAAQ,IAAA,CAAqC,gCAAgC,CAAA,KAAM,IAAA;AACrF;;;;"} | ||
| {"version":3,"file":"utils.js","sources":["../../../src/tracing/utils.ts"],"sourcesContent":["import type { Scope } from '../scope';\nimport type { Span } from '../types/span';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { derefWeakRef, makeWeakRef, type MaybeWeakRef } from '../utils/weakRef';\n\nconst SCOPE_ON_START_SPAN_FIELD = '_sentryScope';\nconst ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';\n\n// Brand marking a span whose `sentry.source` should be inferred OTel-style at span end (by\n// `applyOtelSpanData`) rather than pinned. `SentryTraceProvider` sets it on the spans it creates\n// so they behave like OTel SDK spans, which carry no Sentry source concept. We use `Symbol.for`\n// so the key is shared across duplicated copies of `@sentry/core`.\nconst OTEL_SOURCE_INFERENCE_SPAN_FIELD = Symbol.for('sentry.otelSourceInference');\n\n// Brand marking a span (otherwise subject to OTel-style source inference, see above) whose\n// `sentry.source` was explicitly set by user code after creation, so `applyOtelSpanData` stops\n// inferring and respects the chosen source and name. This is what tells a user-set `custom` source\n// apart from the default `custom` that `_startRootSpan` stamps on every root span.\nconst OTEL_SOURCE_EXPLICITLY_SET_SPAN_FIELD = Symbol.for('sentry.otelSourceExplicitlySet');\n\n// Brand marking a span created by the `SentryTracerProvider` (i.e. via the OTel tracer) rather than\n// directly through the core span API. Such a span is handed to OTel instrumentations as an OTel span,\n// so it must become immutable after `end()` like a real OTel SDK span (see `SentrySpan.end()`). Spans\n// created directly through core (e.g. the browser SDK) are not branded and stay mutable.\nconst TRACER_PROVIDER_SPAN_FIELD = Symbol.for('sentry.tracerProviderSpan');\n\ntype SpanWithScopes = Span & {\n [SCOPE_ON_START_SPAN_FIELD]?: Scope;\n [ISOLATION_SCOPE_ON_START_SPAN_FIELD]?: MaybeWeakRef<Scope>;\n};\n\ntype SpanWithOtelSourceInference = Span & {\n [OTEL_SOURCE_INFERENCE_SPAN_FIELD]?: boolean;\n [OTEL_SOURCE_EXPLICITLY_SET_SPAN_FIELD]?: boolean;\n};\n\ntype SpanWithTracerProviderBrand = Span & {\n [TRACER_PROVIDER_SPAN_FIELD]?: boolean;\n};\n\n/** Store the scope & isolation scope for a span, which can the be used when it is finished. */\nexport function setCapturedScopesOnSpan(span: Span | undefined, scope: Scope, isolationScope: Scope): void {\n if (span) {\n addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, makeWeakRef(isolationScope));\n // We don't wrap the scope with a WeakRef here because webkit aggressively garbage collects\n // and scopes are not held in memory for long periods of time.\n addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);\n }\n}\n\n/**\n * Grabs the scope and isolation scope off a span that were active when the span was started.\n * If WeakRef was used and scopes have been garbage collected, returns undefined for those scopes.\n */\nexport function getCapturedScopesOnSpan(span: Span): { scope?: Scope; isolationScope?: Scope } {\n const spanWithScopes = span as SpanWithScopes;\n\n return {\n scope: spanWithScopes[SCOPE_ON_START_SPAN_FIELD],\n isolationScope: derefWeakRef(spanWithScopes[ISOLATION_SCOPE_ON_START_SPAN_FIELD]),\n };\n}\n\n/**\n * Mark a span as eligible for OTel-style `sentry.source` inference at span end.\n * Set by `SentryTraceProvider` on the spans it creates; read by `SentrySpan.updateName()` and\n * `applyOtelSpanData()`.\n */\nexport function markSpanForOtelSourceInference(span: Span): void {\n addNonEnumerableProperty(span, OTEL_SOURCE_INFERENCE_SPAN_FIELD, true);\n}\n\n/** Whether a span is marked for OTel-style `sentry.source` inference (see {@link markSpanForOtelSourceInference}). */\nexport function spanShouldInferOtelSource(span: Span): boolean {\n return (span as SpanWithOtelSourceInference)[OTEL_SOURCE_INFERENCE_SPAN_FIELD] === true;\n}\n\n/**\n * Mark that user code explicitly set `sentry.source` on a span subject to OTel-style inference, so\n * `applyOtelSpanData` keeps that source (and name) instead of overriding it. Set by `SentrySpan`\n * when `setAttribute` writes the source on an already-branded span (the default `custom` source is\n * stamped at construction, before the brand, so it doesn't trip this).\n */\nexport function markSpanSourceAsExplicit(span: Span): void {\n addNonEnumerableProperty(span, OTEL_SOURCE_EXPLICITLY_SET_SPAN_FIELD, true);\n}\n\n/** Whether user code explicitly set `sentry.source` on a span (see {@link markSpanSourceAsExplicit}). */\nexport function spanSourceWasExplicitlySet(span: Span): boolean {\n return (span as SpanWithOtelSourceInference)[OTEL_SOURCE_EXPLICITLY_SET_SPAN_FIELD] === true;\n}\n\n/**\n * Mark a span as created by the `SentryTracerProvider` (via the OTel tracer). Set by `SentryTracer`\n * on every span it creates; read by `SentrySpan.end()` to seal the span against further writes once\n * it has ended, mirroring OTel SDK spans (which are immutable after `end()`).\n */\nexport function markSpanAsTracerProviderSpan(span: Span): void {\n addNonEnumerableProperty(span, TRACER_PROVIDER_SPAN_FIELD, true);\n}\n\n/** Whether a span was created by the `SentryTracerProvider` (see {@link markSpanAsTracerProviderSpan}). */\nexport function spanIsTracerProviderSpan(span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AAOO,SAAS,6BAA6B,IAAA,EAAkB;AAC7D,EAAA,wBAAA,CAAyB,IAAA,EAAM,4BAA4B,IAAI,CAAA;AACjE;AAGO,SAAS,yBAAyB,IAAA,EAAqB;AAC5D,EAAA,OAAQ,IAAA,CAAqC,0BAA0B,CAAA,KAAM,IAAA;AAC/E;;;;"} |
| import { getTraceData } from './traceData.js'; | ||
| function getTraceMetaTags(traceData) { | ||
| return Object.entries(traceData || getTraceData()).map(([key, value]) => `<meta name="${key}" content="${value}"/>`).join("\n"); | ||
| return Object.entries(traceData || getTraceData()).map(([key, value]) => `<meta name="${key}" content="${value}"/>`).join(""); | ||
| } | ||
@@ -6,0 +6,0 @@ |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"meta.js","sources":["../../../src/utils/meta.ts"],"sourcesContent":["import type { SerializedTraceData } from '../types/tracing';\nimport { getTraceData } from './traceData';\n\n/**\n * Returns a string of meta tags that represent the current trace data.\n *\n * You can use this to propagate a trace from your server-side rendered Html to the browser.\n * This function returns up to two meta tags, `sentry-trace` and `baggage`, depending on the\n * current trace data state.\n *\n * @example\n * Usage example:\n *\n * ```js\n * function renderHtml() {\n * return `\n * <head>\n * ${getTraceMetaTags()}\n * </head>\n * `;\n * }\n * ```\n *\n */\nexport function getTraceMetaTags(traceData?: SerializedTraceData): string {\n return Object.entries(traceData || getTraceData())\n .map(([key, value]) => `<meta name=\"${key}\" content=\"${value}\"/>`)\n .join('\\n');\n}\n"],"names":[],"mappings":";;AAwBO,SAAS,iBAAiB,SAAA,EAAyC;AACxE,EAAA,OAAO,OAAO,OAAA,CAAQ,SAAA,IAAa,cAAc,CAAA,CAC9C,IAAI,CAAC,CAAC,KAAK,KAAK,CAAA,KAAM,eAAe,GAAG,CAAA,WAAA,EAAc,KAAK,CAAA,GAAA,CAAK,CAAA,CAChE,KAAK,IAAI,CAAA;AACd;;;;"} | ||
| {"version":3,"file":"meta.js","sources":["../../../src/utils/meta.ts"],"sourcesContent":["import type { SerializedTraceData } from '../types/tracing';\nimport { getTraceData } from './traceData';\n\n/**\n * Returns a string of meta tags that represent the current trace data.\n *\n * You can use this to propagate a trace from your server-side rendered Html to the browser.\n * This function returns up to two meta tags, `sentry-trace` and `baggage`, depending on the\n * current trace data state.\n *\n * @example\n * Usage example:\n *\n * ```js\n * function renderHtml() {\n * return `\n * <head>\n * ${getTraceMetaTags()}\n * </head>\n * `;\n * }\n * ```\n *\n */\nexport function getTraceMetaTags(traceData?: SerializedTraceData): string {\n return (\n Object.entries(traceData || getTraceData())\n .map(([key, value]) => `<meta name=\"${key}\" content=\"${value}\"/>`)\n // Joined without whitespace on purpose: a separator between the tags becomes a text node when\n // injected into `<head>`, which breaks React 19 whole-document hydration (#21915).\n .join('')\n );\n}\n"],"names":[],"mappings":";;AAwBO,SAAS,iBAAiB,SAAA,EAAyC;AACxE,EAAA,OACE,OAAO,OAAA,CAAQ,SAAA,IAAa,cAAc,CAAA,CACvC,IAAI,CAAC,CAAC,KAAK,KAAK,CAAA,KAAM,eAAe,GAAG,CAAA,WAAA,EAAc,KAAK,CAAA,GAAA,CAAK,CAAA,CAGhE,KAAK,EAAE,CAAA;AAEd;;;;"} |
@@ -258,3 +258,3 @@ import { getAsyncContextStrategy } from '../asyncContext/index.js'; | ||
| export { INTERNAL_getSegmentSpan, TRACE_FLAG_NONE, TRACE_FLAG_SAMPLED, addChildSpanToSpan, addStatusMessageAttribute, convertSpanLinksForEnvelope, getActiveSpan, getRootSpan, getSimpleStatus, getSpanDescendants, getStatusMessage, getStreamedSpanLinks, removeChildSpanFromSpan, showSpanDropWarning, spanIsSampled, spanTimeInputToSeconds, spanToJSON, spanToStreamedSpanJSON, spanToTraceContext, spanToTraceHeader, spanToTraceparentHeader, spanToTransactionTraceContext, streamedSpanJsonToSerializedSpan, updateSpanName }; | ||
| export { INTERNAL_getSegmentSpan, TRACE_FLAG_NONE, TRACE_FLAG_SAMPLED, addChildSpanToSpan, addStatusMessageAttribute, convertSpanLinksForEnvelope, getActiveSpan, getRootSpan, getSimpleStatus, getSpanDescendants, getStatusMessage, getStreamedSpanLinks, removeChildSpanFromSpan, showSpanDropWarning, spanIsSampled, spanIsSentrySpan, spanTimeInputToSeconds, spanToJSON, spanToStreamedSpanJSON, spanToTraceContext, spanToTraceHeader, spanToTraceparentHeader, spanToTransactionTraceContext, streamedSpanJsonToSerializedSpan, updateSpanName }; | ||
| //# sourceMappingURL=spanUtils.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"spanUtils.js","sources":["../../../src/utils/spanUtils.ts"],"sourcesContent":["// oxlint-disable max-lines\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { RawAttributes } from '../attributes';\nimport { serializeAttributes } from '../attributes';\nimport { getMainCarrier } from '../carrier';\nimport { getCurrentScope } from '../currentScopes';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE,\n} from '../semanticAttributes';\nimport type { SentrySpan } from '../tracing/sentrySpan';\nimport { SPAN_STATUS_OK, SPAN_STATUS_UNSET } from '../tracing/spanstatus';\nimport { getCapturedScopesOnSpan } from '../tracing/utils';\nimport type { TraceContext } from '../types/context';\nimport type { SpanLink, SpanLinkJSON } from '../types/link';\nimport type {\n SerializedStreamedSpan,\n Span,\n SpanAttributes,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types/span';\nimport type { SpanStatus } from '../types/spanStatus';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { generateSpanId } from '../utils/propagationContext';\nimport { timestampInSeconds } from '../utils/time';\nimport { generateSentryTraceHeader, generateTraceparentHeader } from '../utils/tracing';\nimport { consoleSandbox } from './debug-logger';\nimport { _getSpanForScope } from './spanOnScope';\n\n// These are aligned with OpenTelemetry trace flags\nexport const TRACE_FLAG_NONE = 0x0;\nexport const TRACE_FLAG_SAMPLED = 0x1;\n\nlet hasShownSpanDropWarning = false;\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in an event.\n * By default, this will only include trace_id, span_id & parent_span_id.\n * If `includeAllData` is true, it will also include data, op, status & origin.\n */\nexport function spanToTransactionTraceContext(span: Span): TraceContext {\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n const { data, op, parent_span_id, status, origin, links } = spanToJSON(span);\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n data,\n op,\n status,\n origin,\n links,\n };\n}\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in a non-transaction event.\n */\nexport function spanToTraceContext(span: Span): TraceContext {\n const { spanId, traceId: trace_id, isRemote } = span.spanContext();\n\n // If the span is remote, we use a random/virtual span as span_id to the trace context,\n // and the remote span as parent_span_id\n const parent_span_id = isRemote ? spanId : spanToJSON(span).parent_span_id;\n const scope = getCapturedScopesOnSpan(span).scope;\n\n const span_id = isRemote ? scope?.getPropagationContext().propagationSpanId || generateSpanId() : spanId;\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n };\n}\n\n/**\n * Convert a Span to a Sentry trace header.\n */\nexport function spanToTraceHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateSentryTraceHeader(traceId, spanId, sampled);\n}\n\n/**\n * Convert a Span to a W3C traceparent header.\n */\nexport function spanToTraceparentHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateTraceparentHeader(traceId, spanId, sampled);\n}\n\n/**\n * Converts the span links array to a flattened version to be sent within an envelope.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function convertSpanLinksForEnvelope(links?: SpanLink[]): SpanLinkJSON[] | undefined {\n if (links && links.length > 0) {\n return links.map(({ context: { spanId, traceId, traceFlags, ...restContext }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n ...restContext,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Converts the span links array to a flattened version with serialized attributes for V2 spans.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function getStreamedSpanLinks(\n links?: SpanLink[],\n): SpanLinkJSON<RawAttributes<Record<string, unknown>>>[] | undefined {\n if (links?.length) {\n return links.map(({ context: { spanId, traceId, traceFlags }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Convert a span time input into a timestamp in seconds.\n */\nexport function spanTimeInputToSeconds(input: SpanTimeInput | undefined): number {\n if (typeof input === 'number') {\n return ensureTimestampInSeconds(input);\n }\n\n if (Array.isArray(input)) {\n // See {@link HrTime} for the array-based time format\n return input[0] + input[1] / 1e9;\n }\n\n if (input instanceof Date) {\n return ensureTimestampInSeconds(input.getTime());\n }\n\n return timestampInSeconds();\n}\n\n/**\n * Converts a timestamp to second, if it was in milliseconds, or keeps it as second.\n */\nfunction ensureTimestampInSeconds(timestamp: number): number {\n const isMs = timestamp > 9999999999;\n return isMs ? timestamp / 1000 : timestamp;\n}\n\n/**\n * Convert a span to a JSON representation.\n */\n// Note: Because of this, we currently have a circular type dependency (which we opted out of in package.json).\n// This is not avoidable as we need `spanToJSON` in `spanUtils.ts`, which in turn is needed by `span.ts` for backwards compatibility.\n// And `spanToJSON` needs the Span class from `span.ts` to check here.\nexport function spanToJSON(span: Span): SpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n span_id,\n trace_id,\n data: attributes,\n description: name,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n // This is [0,0] by default in OTEL, in which case we want to interpret this as no end time\n timestamp: spanTimeInputToSeconds(endTime) || undefined,\n status: getStatusMessage(status),\n op: attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n origin: attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n links: convertSpanLinksForEnvelope(links),\n };\n }\n\n // Finally, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n data: {},\n };\n}\n\n/**\n * Convert a span to the intermediate {@link StreamedSpanJSON} representation.\n */\nexport function spanToStreamedSpanJSON(span: Span): StreamedSpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getStreamedSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n name,\n span_id,\n trace_id,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n end_timestamp: spanTimeInputToSeconds(endTime),\n is_segment: span === INTERNAL_getSegmentSpan(span),\n status: getSimpleStatus(status),\n attributes: addStatusMessageAttribute(attributes, status),\n links: getStreamedSpanLinks(links),\n };\n }\n\n // Finally, as a fallback, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n name: '',\n end_timestamp: 0,\n status: 'ok',\n is_segment: span === INTERNAL_getSegmentSpan(span),\n };\n}\n\n/**\n * In preparation for the next major of OpenTelemetry, we want to support\n * looking up the parent span id according to the new API\n * In OTel v1, the parent span id is accessed as `parentSpanId`\n * In OTel v2, the parent span id is accessed as `spanId` on the `parentSpanContext`\n */\nfunction getOtelParentSpanId(span: OpenTelemetrySdkTraceBaseSpan): string | undefined {\n return 'parentSpanId' in span\n ? span.parentSpanId\n : 'parentSpanContext' in span\n ? (span.parentSpanContext as { spanId?: string } | undefined)?.spanId\n : undefined;\n}\n\n/**\n * Converts a {@link StreamedSpanJSON} to a {@link SerializedSpan}.\n * This is the final serialized span format that is sent to Sentry.\n * The returned serilaized spans must not be consumed by users or SDK integrations.\n */\nexport function streamedSpanJsonToSerializedSpan(spanJson: StreamedSpanJSON): SerializedStreamedSpan {\n return {\n ...spanJson,\n attributes: serializeAttributes(spanJson.attributes),\n links: spanJson.links?.map(link => ({\n ...link,\n attributes: serializeAttributes(link.attributes),\n })),\n };\n}\n\nfunction spanIsOpenTelemetrySdkTraceBaseSpan(span: Span): span is OpenTelemetrySdkTraceBaseSpan {\n const castSpan = span as Partial<OpenTelemetrySdkTraceBaseSpan>;\n return !!castSpan.attributes && !!castSpan.startTime && !!castSpan.name && !!castSpan.endTime && !!castSpan.status;\n}\n\n/** Exported only for tests. */\nexport interface OpenTelemetrySdkTraceBaseSpan extends Span {\n attributes: SpanAttributes;\n startTime: SpanTimeInput;\n name: string;\n status: SpanStatus;\n endTime: SpanTimeInput;\n parentSpanId?: string;\n links?: SpanLink[];\n}\n\n/**\n * Sadly, due to circular dependency checks we cannot actually import the Span class here and check for instanceof.\n * :( So instead we approximate this by checking if it has the `getSpanJSON` method.\n */\nfunction spanIsSentrySpan(span: Span): span is SentrySpan {\n return typeof (span as SentrySpan).getSpanJSON === 'function';\n}\n\n/**\n * Returns true if a span is sampled.\n * In most cases, you should just use `span.isRecording()` instead.\n * However, this has a slightly different semantic, as it also returns false if the span is finished.\n * So in the case where this distinction is important, use this method.\n */\nexport function spanIsSampled(span: Span): boolean {\n // We align our trace flags with the ones OpenTelemetry use\n // So we also check for sampled the same way they do.\n const { traceFlags } = span.spanContext();\n return traceFlags === TRACE_FLAG_SAMPLED;\n}\n\n/** Get the status message to use for a JSON representation of a span. */\nexport function getStatusMessage(status: SpanStatus | undefined): string | undefined {\n if (!status || status.code === SPAN_STATUS_UNSET) {\n return undefined;\n }\n\n if (status.code === SPAN_STATUS_OK) {\n return 'ok';\n }\n\n return status.message || 'internal_error';\n}\n\n/**\n * Convert the various statuses to the simple ones expected by Sentry for streamed spans ('ok' is default).\n */\nexport function getSimpleStatus(status: SpanStatus | undefined): 'ok' | 'error' {\n return !status ||\n status.code === SPAN_STATUS_OK ||\n status.code === SPAN_STATUS_UNSET ||\n status.message === 'cancelled'\n ? 'ok'\n : 'error';\n}\n\n/**\n * Returns the span's attributes with the SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE attribute added\n * if the span has an error status message worth preserving.\n *\n * An explicitly set attribute is never overwritten.\n */\nexport function addStatusMessageAttribute(\n attributes: SpanAttributes,\n status: SpanStatus | undefined,\n): RawAttributes<Record<string, unknown>> {\n const statusMessage = getSimpleStatus(status) === 'error' ? status?.message : undefined;\n return {\n ...(statusMessage && { [SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE]: statusMessage }),\n ...attributes,\n };\n}\n\nconst CHILD_SPANS_FIELD = '_sentryChildSpans';\nconst ROOT_SPAN_FIELD = '_sentryRootSpan';\n\ntype SpanWithPotentialChildren = Span & {\n [CHILD_SPANS_FIELD]?: Set<Span>;\n [ROOT_SPAN_FIELD]?: Span;\n};\n\n/**\n * Adds an opaque child span reference to a span.\n */\nexport function addChildSpanToSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n // We store the root span reference on the child span\n // We need this for `getRootSpan()` to work\n const rootSpan = span[ROOT_SPAN_FIELD] || span;\n addNonEnumerableProperty(childSpan as SpanWithPotentialChildren, ROOT_SPAN_FIELD, rootSpan);\n\n // We store a list of child spans on the parent span\n // We need this for `getSpanDescendants()` to work\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].add(childSpan);\n } else {\n addNonEnumerableProperty(span, CHILD_SPANS_FIELD, new Set([childSpan]));\n }\n}\n\n/** This is only used internally by Idle Spans. */\nexport function removeChildSpanFromSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].delete(childSpan);\n }\n}\n\n/**\n * Returns an array of the given span and all of its descendants.\n */\nexport function getSpanDescendants(span: SpanWithPotentialChildren): Span[] {\n const resultSet = new Set<Span>();\n\n function addSpanChildren(span: SpanWithPotentialChildren): void {\n // This exit condition is required to not infinitely loop in case of a circular dependency.\n if (resultSet.has(span)) {\n return;\n // We want to ignore unsampled spans (e.g. non recording spans)\n } else if (spanIsSampled(span)) {\n resultSet.add(span);\n const childSpans = span[CHILD_SPANS_FIELD] ? Array.from(span[CHILD_SPANS_FIELD]) : [];\n for (const childSpan of childSpans) {\n addSpanChildren(childSpan);\n }\n }\n }\n\n addSpanChildren(span);\n\n return Array.from(resultSet);\n}\n\n/**\n * Returns the root span of a given span.\n */\nexport const getRootSpan = INTERNAL_getSegmentSpan;\n\n/**\n * Returns the segment span of a given span.\n */\nexport function INTERNAL_getSegmentSpan(span: SpanWithPotentialChildren): Span {\n return span[ROOT_SPAN_FIELD] || span;\n}\n\n/**\n * Returns the currently active span.\n */\nexport function getActiveSpan(): Span | undefined {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.getActiveSpan) {\n return acs.getActiveSpan();\n }\n\n return _getSpanForScope(getCurrentScope());\n}\n\n/**\n * Logs a warning once if `beforeSendSpan` is used to drop spans.\n */\nexport function showSpanDropWarning(): void {\n if (!hasShownSpanDropWarning) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.',\n );\n });\n hasShownSpanDropWarning = true;\n }\n}\n\n/**\n * Updates the name of the given span and ensures that the span name is not\n * overwritten by the Sentry SDK.\n *\n * Use this function instead of `span.updateName()` if you want to make sure that\n * your name is kept. For some spans, for example root `http.server` spans the\n * Sentry SDK would otherwise overwrite the span name with a high-quality name\n * it infers when the span ends.\n *\n * Use this function in server code or when your span is started on the server\n * and on the client (browser). If you only update a span name on the client,\n * you can also use `span.updateName()` the SDK does not overwrite the name.\n *\n * @param span - The span to update the name of.\n * @param name - The name to set on the span.\n */\nexport function updateSpanName(span: Span, name: string): void {\n span.updateName(name);\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]: name,\n });\n}\n"],"names":["span"],"mappings":";;;;;;;;;;;;;;AAoCO,MAAM,eAAA,GAAkB;AACxB,MAAM,kBAAA,GAAqB;AAElC,IAAI,uBAAA,GAA0B,KAAA;AAOvB,SAAS,8BAA8B,IAAA,EAA0B;AACtE,EAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAS,SAAS,QAAA,EAAS,GAAI,KAAK,WAAA,EAAY;AAChE,EAAA,MAAM,EAAE,MAAM,EAAA,EAAI,cAAA,EAAgB,QAAQ,MAAA,EAAQ,KAAA,EAAM,GAAI,UAAA,CAAW,IAAI,CAAA;AAE3E,EAAA,OAAO;AAAA,IACL,cAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,EAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF;AAKO,SAAS,mBAAmB,IAAA,EAA0B;AAC3D,EAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAS,UAAU,QAAA,EAAS,GAAI,KAAK,WAAA,EAAY;AAIjE,EAAA,MAAM,cAAA,GAAiB,QAAA,GAAW,MAAA,GAAS,UAAA,CAAW,IAAI,CAAA,CAAE,cAAA;AAC5D,EAAA,MAAM,KAAA,GAAQ,uBAAA,CAAwB,IAAI,CAAA,CAAE,KAAA;AAE5C,EAAA,MAAM,UAAU,QAAA,GAAW,KAAA,EAAO,uBAAsB,CAAE,iBAAA,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,OAAO,gBAAA,CAAiB,iBAAiB,CAAA;AAC3C;AAKO,SAAS,mBAAA,GAA4B;AAC1C,EAAA,IAAI,CAAC,uBAAA,EAAyB;AAC5B,IAAA,cAAA,CAAe,MAAM;AAEnB,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN;AAAA,OACF;AAAA,IACF,CAAC,CAAA;AACD,IAAA,uBAAA,GAA0B,IAAA;AAAA,EAC5B;AACF;AAkBO,SAAS,cAAA,CAAe,MAAY,IAAA,EAAoB;AAC7D,EAAA,IAAA,CAAK,WAAW,IAAI,CAAA;AACpB,EAAA,IAAA,CAAK,aAAA,CAAc;AAAA,IACjB,CAAC,gCAAgC,GAAG,QAAA;AAAA,IACpC,CAAC,0CAA0C,GAAG;AAAA,GAC/C,CAAA;AACH;;;;"} | ||
| {"version":3,"file":"spanUtils.js","sources":["../../../src/utils/spanUtils.ts"],"sourcesContent":["// oxlint-disable max-lines\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { RawAttributes } from '../attributes';\nimport { serializeAttributes } from '../attributes';\nimport { getMainCarrier } from '../carrier';\nimport { getCurrentScope } from '../currentScopes';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE,\n} from '../semanticAttributes';\nimport type { SentrySpan } from '../tracing/sentrySpan';\nimport { SPAN_STATUS_OK, SPAN_STATUS_UNSET } from '../tracing/spanstatus';\nimport { getCapturedScopesOnSpan } from '../tracing/utils';\nimport type { TraceContext } from '../types/context';\nimport type { SpanLink, SpanLinkJSON } from '../types/link';\nimport type {\n SerializedStreamedSpan,\n Span,\n SpanAttributes,\n SpanJSON,\n SpanOrigin,\n SpanTimeInput,\n StreamedSpanJSON,\n} from '../types/span';\nimport type { SpanStatus } from '../types/spanStatus';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { generateSpanId } from '../utils/propagationContext';\nimport { timestampInSeconds } from '../utils/time';\nimport { generateSentryTraceHeader, generateTraceparentHeader } from '../utils/tracing';\nimport { consoleSandbox } from './debug-logger';\nimport { _getSpanForScope } from './spanOnScope';\n\n// These are aligned with OpenTelemetry trace flags\nexport const TRACE_FLAG_NONE = 0x0;\nexport const TRACE_FLAG_SAMPLED = 0x1;\n\nlet hasShownSpanDropWarning = false;\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in an event.\n * By default, this will only include trace_id, span_id & parent_span_id.\n * If `includeAllData` is true, it will also include data, op, status & origin.\n */\nexport function spanToTransactionTraceContext(span: Span): TraceContext {\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n const { data, op, parent_span_id, status, origin, links } = spanToJSON(span);\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n data,\n op,\n status,\n origin,\n links,\n };\n}\n\n/**\n * Convert a span to a trace context, which can be sent as the `trace` context in a non-transaction event.\n */\nexport function spanToTraceContext(span: Span): TraceContext {\n const { spanId, traceId: trace_id, isRemote } = span.spanContext();\n\n // If the span is remote, we use a random/virtual span as span_id to the trace context,\n // and the remote span as parent_span_id\n const parent_span_id = isRemote ? spanId : spanToJSON(span).parent_span_id;\n const scope = getCapturedScopesOnSpan(span).scope;\n\n const span_id = isRemote ? scope?.getPropagationContext().propagationSpanId || generateSpanId() : spanId;\n\n return {\n parent_span_id,\n span_id,\n trace_id,\n };\n}\n\n/**\n * Convert a Span to a Sentry trace header.\n */\nexport function spanToTraceHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateSentryTraceHeader(traceId, spanId, sampled);\n}\n\n/**\n * Convert a Span to a W3C traceparent header.\n */\nexport function spanToTraceparentHeader(span: Span): string {\n const { traceId, spanId } = span.spanContext();\n const sampled = spanIsSampled(span);\n return generateTraceparentHeader(traceId, spanId, sampled);\n}\n\n/**\n * Converts the span links array to a flattened version to be sent within an envelope.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function convertSpanLinksForEnvelope(links?: SpanLink[]): SpanLinkJSON[] | undefined {\n if (links && links.length > 0) {\n return links.map(({ context: { spanId, traceId, traceFlags, ...restContext }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n ...restContext,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Converts the span links array to a flattened version with serialized attributes for V2 spans.\n *\n * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.\n */\nexport function getStreamedSpanLinks(\n links?: SpanLink[],\n): SpanLinkJSON<RawAttributes<Record<string, unknown>>>[] | undefined {\n if (links?.length) {\n return links.map(({ context: { spanId, traceId, traceFlags }, attributes }) => ({\n span_id: spanId,\n trace_id: traceId,\n sampled: traceFlags === TRACE_FLAG_SAMPLED,\n attributes,\n }));\n } else {\n return undefined;\n }\n}\n\n/**\n * Convert a span time input into a timestamp in seconds.\n */\nexport function spanTimeInputToSeconds(input: SpanTimeInput | undefined): number {\n if (typeof input === 'number') {\n return ensureTimestampInSeconds(input);\n }\n\n if (Array.isArray(input)) {\n // See {@link HrTime} for the array-based time format\n return input[0] + input[1] / 1e9;\n }\n\n if (input instanceof Date) {\n return ensureTimestampInSeconds(input.getTime());\n }\n\n return timestampInSeconds();\n}\n\n/**\n * Converts a timestamp to second, if it was in milliseconds, or keeps it as second.\n */\nfunction ensureTimestampInSeconds(timestamp: number): number {\n const isMs = timestamp > 9999999999;\n return isMs ? timestamp / 1000 : timestamp;\n}\n\n/**\n * Convert a span to a JSON representation.\n */\n// Note: Because of this, we currently have a circular type dependency (which we opted out of in package.json).\n// This is not avoidable as we need `spanToJSON` in `spanUtils.ts`, which in turn is needed by `span.ts` for backwards compatibility.\n// And `spanToJSON` needs the Span class from `span.ts` to check here.\nexport function spanToJSON(span: Span): SpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n span_id,\n trace_id,\n data: attributes,\n description: name,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n // This is [0,0] by default in OTEL, in which case we want to interpret this as no end time\n timestamp: spanTimeInputToSeconds(endTime) || undefined,\n status: getStatusMessage(status),\n op: attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n origin: attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,\n links: convertSpanLinksForEnvelope(links),\n };\n }\n\n // Finally, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n data: {},\n };\n}\n\n/**\n * Convert a span to the intermediate {@link StreamedSpanJSON} representation.\n */\nexport function spanToStreamedSpanJSON(span: Span): StreamedSpanJSON {\n if (spanIsSentrySpan(span)) {\n return span.getStreamedSpanJSON();\n }\n\n const { spanId: span_id, traceId: trace_id } = span.spanContext();\n\n // Handle a span from @opentelemetry/sdk-base-trace's `Span` class\n if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {\n const { attributes, startTime, name, endTime, status, links } = span;\n\n return {\n name,\n span_id,\n trace_id,\n parent_span_id: getOtelParentSpanId(span),\n start_timestamp: spanTimeInputToSeconds(startTime),\n end_timestamp: spanTimeInputToSeconds(endTime),\n is_segment: span === INTERNAL_getSegmentSpan(span),\n status: getSimpleStatus(status),\n attributes: addStatusMessageAttribute(attributes, status),\n links: getStreamedSpanLinks(links),\n };\n }\n\n // Finally, as a fallback, at least we have `spanContext()`....\n // This should not actually happen in reality, but we need to handle it for type safety.\n return {\n span_id,\n trace_id,\n start_timestamp: 0,\n name: '',\n end_timestamp: 0,\n status: 'ok',\n is_segment: span === INTERNAL_getSegmentSpan(span),\n };\n}\n\n/**\n * In preparation for the next major of OpenTelemetry, we want to support\n * looking up the parent span id according to the new API\n * In OTel v1, the parent span id is accessed as `parentSpanId`\n * In OTel v2, the parent span id is accessed as `spanId` on the `parentSpanContext`\n */\nfunction getOtelParentSpanId(span: OpenTelemetrySdkTraceBaseSpan): string | undefined {\n return 'parentSpanId' in span\n ? span.parentSpanId\n : 'parentSpanContext' in span\n ? (span.parentSpanContext as { spanId?: string } | undefined)?.spanId\n : undefined;\n}\n\n/**\n * Converts a {@link StreamedSpanJSON} to a {@link SerializedSpan}.\n * This is the final serialized span format that is sent to Sentry.\n * The returned serilaized spans must not be consumed by users or SDK integrations.\n */\nexport function streamedSpanJsonToSerializedSpan(spanJson: StreamedSpanJSON): SerializedStreamedSpan {\n return {\n ...spanJson,\n attributes: serializeAttributes(spanJson.attributes),\n links: spanJson.links?.map(link => ({\n ...link,\n attributes: serializeAttributes(link.attributes),\n })),\n };\n}\n\nfunction spanIsOpenTelemetrySdkTraceBaseSpan(span: Span): span is OpenTelemetrySdkTraceBaseSpan {\n const castSpan = span as Partial<OpenTelemetrySdkTraceBaseSpan>;\n return !!castSpan.attributes && !!castSpan.startTime && !!castSpan.name && !!castSpan.endTime && !!castSpan.status;\n}\n\n/** Exported only for tests. */\nexport interface OpenTelemetrySdkTraceBaseSpan extends Span {\n attributes: SpanAttributes;\n startTime: SpanTimeInput;\n name: string;\n status: SpanStatus;\n endTime: SpanTimeInput;\n parentSpanId?: string;\n links?: SpanLink[];\n}\n\n/**\n * Sadly, due to circular dependency checks we cannot actually import the Span class here and check for instanceof.\n * :( So instead we approximate this by checking if it has the `getSpanJSON` method.\n */\nexport function spanIsSentrySpan(span: Span): span is SentrySpan {\n return typeof (span as SentrySpan).getSpanJSON === 'function';\n}\n\n/**\n * Returns true if a span is sampled.\n * In most cases, you should just use `span.isRecording()` instead.\n * However, this has a slightly different semantic, as it also returns false if the span is finished.\n * So in the case where this distinction is important, use this method.\n */\nexport function spanIsSampled(span: Span): boolean {\n // We align our trace flags with the ones OpenTelemetry use\n // So we also check for sampled the same way they do.\n const { traceFlags } = span.spanContext();\n return traceFlags === TRACE_FLAG_SAMPLED;\n}\n\n/** Get the status message to use for a JSON representation of a span. */\nexport function getStatusMessage(status: SpanStatus | undefined): string | undefined {\n if (!status || status.code === SPAN_STATUS_UNSET) {\n return undefined;\n }\n\n if (status.code === SPAN_STATUS_OK) {\n return 'ok';\n }\n\n return status.message || 'internal_error';\n}\n\n/**\n * Convert the various statuses to the simple ones expected by Sentry for streamed spans ('ok' is default).\n */\nexport function getSimpleStatus(status: SpanStatus | undefined): 'ok' | 'error' {\n return !status ||\n status.code === SPAN_STATUS_OK ||\n status.code === SPAN_STATUS_UNSET ||\n status.message === 'cancelled'\n ? 'ok'\n : 'error';\n}\n\n/**\n * Returns the span's attributes with the SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE attribute added\n * if the span has an error status message worth preserving.\n *\n * An explicitly set attribute is never overwritten.\n */\nexport function addStatusMessageAttribute(\n attributes: SpanAttributes,\n status: SpanStatus | undefined,\n): RawAttributes<Record<string, unknown>> {\n const statusMessage = getSimpleStatus(status) === 'error' ? status?.message : undefined;\n return {\n ...(statusMessage && { [SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE]: statusMessage }),\n ...attributes,\n };\n}\n\nconst CHILD_SPANS_FIELD = '_sentryChildSpans';\nconst ROOT_SPAN_FIELD = '_sentryRootSpan';\n\ntype SpanWithPotentialChildren = Span & {\n [CHILD_SPANS_FIELD]?: Set<Span>;\n [ROOT_SPAN_FIELD]?: Span;\n};\n\n/**\n * Adds an opaque child span reference to a span.\n */\nexport function addChildSpanToSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n // We store the root span reference on the child span\n // We need this for `getRootSpan()` to work\n const rootSpan = span[ROOT_SPAN_FIELD] || span;\n addNonEnumerableProperty(childSpan as SpanWithPotentialChildren, ROOT_SPAN_FIELD, rootSpan);\n\n // We store a list of child spans on the parent span\n // We need this for `getSpanDescendants()` to work\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].add(childSpan);\n } else {\n addNonEnumerableProperty(span, CHILD_SPANS_FIELD, new Set([childSpan]));\n }\n}\n\n/** This is only used internally by Idle Spans. */\nexport function removeChildSpanFromSpan(span: SpanWithPotentialChildren, childSpan: Span): void {\n if (span[CHILD_SPANS_FIELD]) {\n span[CHILD_SPANS_FIELD].delete(childSpan);\n }\n}\n\n/**\n * Returns an array of the given span and all of its descendants.\n */\nexport function getSpanDescendants(span: SpanWithPotentialChildren): Span[] {\n const resultSet = new Set<Span>();\n\n function addSpanChildren(span: SpanWithPotentialChildren): void {\n // This exit condition is required to not infinitely loop in case of a circular dependency.\n if (resultSet.has(span)) {\n return;\n // We want to ignore unsampled spans (e.g. non recording spans)\n } else if (spanIsSampled(span)) {\n resultSet.add(span);\n const childSpans = span[CHILD_SPANS_FIELD] ? Array.from(span[CHILD_SPANS_FIELD]) : [];\n for (const childSpan of childSpans) {\n addSpanChildren(childSpan);\n }\n }\n }\n\n addSpanChildren(span);\n\n return Array.from(resultSet);\n}\n\n/**\n * Returns the root span of a given span.\n */\nexport const getRootSpan = INTERNAL_getSegmentSpan;\n\n/**\n * Returns the segment span of a given span.\n */\nexport function INTERNAL_getSegmentSpan(span: SpanWithPotentialChildren): Span {\n return span[ROOT_SPAN_FIELD] || span;\n}\n\n/**\n * Returns the currently active span.\n */\nexport function getActiveSpan(): Span | undefined {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.getActiveSpan) {\n return acs.getActiveSpan();\n }\n\n return _getSpanForScope(getCurrentScope());\n}\n\n/**\n * Logs a warning once if `beforeSendSpan` is used to drop spans.\n */\nexport function showSpanDropWarning(): void {\n if (!hasShownSpanDropWarning) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.',\n );\n });\n hasShownSpanDropWarning = true;\n }\n}\n\n/**\n * Updates the name of the given span and ensures that the span name is not\n * overwritten by the Sentry SDK.\n *\n * Use this function instead of `span.updateName()` if you want to make sure that\n * your name is kept. For some spans, for example root `http.server` spans the\n * Sentry SDK would otherwise overwrite the span name with a high-quality name\n * it infers when the span ends.\n *\n * Use this function in server code or when your span is started on the server\n * and on the client (browser). If you only update a span name on the client,\n * you can also use `span.updateName()` the SDK does not overwrite the name.\n *\n * @param span - The span to update the name of.\n * @param name - The name to set on the span.\n */\nexport function updateSpanName(span: Span, name: string): void {\n span.updateName(name);\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]: name,\n });\n}\n"],"names":["span"],"mappings":";;;;;;;;;;;;;;AAoCO,MAAM,eAAA,GAAkB;AACxB,MAAM,kBAAA,GAAqB;AAElC,IAAI,uBAAA,GAA0B,KAAA;AAOvB,SAAS,8BAA8B,IAAA,EAA0B;AACtE,EAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAS,SAAS,QAAA,EAAS,GAAI,KAAK,WAAA,EAAY;AAChE,EAAA,MAAM,EAAE,MAAM,EAAA,EAAI,cAAA,EAAgB,QAAQ,MAAA,EAAQ,KAAA,EAAM,GAAI,UAAA,CAAW,IAAI,CAAA;AAE3E,EAAA,OAAO;AAAA,IACL,cAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,EAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF;AAKO,SAAS,mBAAmB,IAAA,EAA0B;AAC3D,EAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAS,UAAU,QAAA,EAAS,GAAI,KAAK,WAAA,EAAY;AAIjE,EAAA,MAAM,cAAA,G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AKO,SAAS,aAAA,GAAkC;AAChD,EAAA,MAAM,UAAU,cAAA,EAAe;AAC/B,EAAA,MAAM,GAAA,GAAM,wBAAwB,OAAO,CAAA;AAC3C,EAAA,IAAI,IAAI,aAAA,EAAe;AACrB,IAAA,OAAO,IAAI,aAAA,EAAc;AAAA,EAC3B;AAEA,EAAA,OAAO,gBAAA,CAAiB,iBAAiB,CAAA;AAC3C;AAKO,SAAS,mBAAA,GAA4B;AAC1C,EAAA,IAAI,CAAC,uBAAA,EAAyB;AAC5B,IAAA,cAAA,CAAe,MAAM;AAEnB,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN;AAAA,OACF;AAAA,IACF,CAAC,CAAA;AACD,IAAA,uBAAA,GAA0B,IAAA;AAAA,EAC5B;AACF;AAkBO,SAAS,cAAA,CAAe,MAAY,IAAA,EAAoB;AAC7D,EAAA,IAAA,CAAK,WAAW,IAAI,CAAA;AACpB,EAAA,IAAA,CAAK,aAAA,CAAc;AAAA,IACjB,CAAC,gCAAgC,GAAG,QAAA;AAAA,IACpC,CAAC,0CAA0C,GAAG;AAAA,GAC/C,CAAA;AACH;;;;"} |
@@ -1,4 +0,4 @@ | ||
| const SDK_VERSION = "10.63.0" ; | ||
| const SDK_VERSION = "10.64.0" ; | ||
| export { SDK_VERSION }; | ||
| //# sourceMappingURL=version.js.map |
@@ -5,2 +5,3 @@ import { AsyncContextStack } from './asyncContext/stackStrategy'; | ||
| import { Scope } from './scope'; | ||
| import { SegmentSpanCaptureStrategy } from './tracing/segmentSpanCaptureStrategy'; | ||
| import { SerializedLog } from './types/log'; | ||
@@ -37,2 +38,4 @@ import { SerializedMetric } from './types/metric'; | ||
| clientToMetricBufferMap?: WeakMap<Client, Array<SerializedMetric>>; | ||
| /** Strategy for assembling segment spans into transactions; set by SDKs that defer capture. */ | ||
| segmentSpanCaptureStrategy?: SegmentSpanCaptureStrategy; | ||
| /** Overwrites TextEncoder used in `@sentry/core`, need for `react-native@0.73` and older */ | ||
@@ -39,0 +42,0 @@ encodePolyfill?: (input: string) => Uint8Array; |
@@ -6,3 +6,3 @@ import { IntegrationFn } from '../../types/integration'; | ||
| } | ||
| export type GrowthBookClassLike = new (...args: unknown[]) => GrowthBookLike; | ||
| export type GrowthBookClassLike = new (...args: any[]) => GrowthBookLike; | ||
| /** | ||
@@ -9,0 +9,0 @@ * Sentry integration for capturing feature flag evaluations from GrowthBook. |
| /** | ||
| * Use this attribute to represent the source of a span name. | ||
| * Must be one of: custom, url, route, view, component, task | ||
| * TODO(v11): rename this to sentry.span.source' | ||
| * TODO(v11): remove this export | ||
| */ | ||
@@ -6,0 +6,0 @@ export declare const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = "sentry.source"; |
@@ -46,3 +46,3 @@ export { ClientClass as SentryCoreCurrentScopes } from './sdk'; | ||
| export { addAutoIpAddressToUser } from './utils/ipAddress'; | ||
| export { convertSpanLinksForEnvelope, spanToTraceHeader, spanToJSON, spanToStreamedSpanJSON, spanIsSampled, spanToTraceContext, getSpanDescendants, getStatusMessage, getRootSpan, INTERNAL_getSegmentSpan, getActiveSpan, addChildSpanToSpan, spanTimeInputToSeconds, updateSpanName, } from './utils/spanUtils'; | ||
| export { convertSpanLinksForEnvelope, spanToTraceHeader, spanToJSON, spanToStreamedSpanJSON, spanIsSampled, spanIsSentrySpan, spanToTraceContext, getSpanDescendants, getStatusMessage, getRootSpan, INTERNAL_getSegmentSpan, getActiveSpan, addChildSpanToSpan, spanTimeInputToSeconds, updateSpanName, } from './utils/spanUtils'; | ||
| export { _setSpanForScope as _INTERNAL_setSpanForScope } from './utils/spanOnScope'; | ||
@@ -96,9 +96,12 @@ export { parseSampleRate } from './utils/parseSampleRate'; | ||
| export { addVercelAiProcessors, getProviderMetadataAttributes } from './tracing/vercel-ai'; | ||
| export { getTruncatedJsonString, shouldEnableTruncation } from './tracing/ai/utils'; | ||
| export { GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, } from './tracing/ai/gen-ai-attributes'; | ||
| export { getTruncatedJsonString, shouldEnableTruncation, resolveAIRecordingOptions } from './tracing/ai/utils'; | ||
| export { GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, } from './tracing/ai/gen-ai-attributes'; | ||
| export { _INTERNAL_getSpanContextForToolCallId, _INTERNAL_cleanupToolCallSpanContext } from './tracing/vercel-ai/utils'; | ||
| export { toolCallSpanContextMap as _INTERNAL_toolCallSpanContextMap } from './tracing/vercel-ai/constants'; | ||
| export { instrumentOpenAiClient } from './tracing/openai'; | ||
| export { instrumentOpenAiClient, extractRequestAttributes as extractOpenAiRequestAttributes, addRequestAttributes as addOpenAiRequestAttributes, } from './tracing/openai'; | ||
| export { addResponseAttributes as addOpenAiResponseAttributes, extractRequestParameters as extractOpenAiRequestParameters, } from './tracing/openai/utils'; | ||
| export { instrumentStream as instrumentOpenAiStream } from './tracing/openai/streaming'; | ||
| export { OPENAI_INTEGRATION_NAME } from './tracing/openai/constants'; | ||
| export { instrumentAnthropicAiClient } from './tracing/anthropic-ai'; | ||
| export { instrumentAnthropicAiClient, extractRequestAttributes as extractAnthropicRequestAttributes, addPrivateRequestAttributes as addAnthropicRequestAttributes, addResponseAttributes as addAnthropicResponseAttributes, } from './tracing/anthropic-ai'; | ||
| export { instrumentAsyncIterableStream, instrumentMessageStream } from './tracing/anthropic-ai/streaming'; | ||
| export { ANTHROPIC_AI_INTEGRATION_NAME } from './tracing/anthropic-ai/constants'; | ||
@@ -105,0 +108,0 @@ export { instrumentGoogleGenAIClient } from './tracing/google-genai'; |
@@ -1,3 +0,17 @@ | ||
| import { AnthropicAiOptions } from './types'; | ||
| import { Span } from '../../types/span'; | ||
| import { AnthropicAiOptions, AnthropicAiResponse } from './types'; | ||
| /** | ||
| * Extract request attributes from method arguments | ||
| */ | ||
| export declare function extractRequestAttributes(args: unknown[], methodPath: string, operationName: string): Record<string, unknown>; | ||
| /** | ||
| * Add private request attributes to spans. | ||
| * This is only recorded if recordInputs is true. | ||
| */ | ||
| export declare function addPrivateRequestAttributes(span: Span, params: Record<string, unknown>, enableTruncation: boolean): void; | ||
| /** | ||
| * Add response attributes to spans | ||
| */ | ||
| export declare function addResponseAttributes(span: Span, response: AnthropicAiResponse, recordOutputs?: boolean): void; | ||
| /** | ||
| * Instrument an Anthropic AI client with Sentry tracing | ||
@@ -4,0 +18,0 @@ * Can be used across Node.js, Cloudflare Workers, and Vercel Edge |
| export { registerSpanErrorInstrumentation } from './errors'; | ||
| export { setCapturedScopesOnSpan, getCapturedScopesOnSpan, markSpanForOtelSourceInference, spanShouldInferOtelSource, } from './utils'; | ||
| export { setCapturedScopesOnSpan, getCapturedScopesOnSpan, markSpanForOtelSourceInference, spanShouldInferOtelSource, markSpanSourceAsExplicit, spanSourceWasExplicitlySet, markSpanAsTracerProviderSpan, spanIsTracerProviderSpan, } from './utils'; | ||
| export { startIdleSpan, TRACING_DEFAULTS } from './idleSpan'; | ||
| export { SentrySpan } from './sentrySpan'; | ||
| export { _INTERNAL_setDeferSegmentSpanCapture } from './deferSegmentSpanCapture'; | ||
| export { SentryNonRecordingSpan } from './sentryNonRecordingSpan'; | ||
| export { setHttpStatus, getSpanStatusFromHttpCode } from './spanstatus'; | ||
| export { SPAN_STATUS_ERROR, SPAN_STATUS_OK, SPAN_STATUS_UNSET } from './spanstatus'; | ||
| export { startSpan, startInactiveSpan, startSpanManual, continueTrace, withActiveSpan, suppressTracing, isTracingSuppressed, startNewTrace, SUPPRESS_TRACING_KEY, } from './trace'; | ||
| export { startSpan, startInactiveSpan, _INTERNAL_startInactiveSpan, startSpanManual, continueTrace, withActiveSpan, suppressTracing, isTracingSuppressed, startNewTrace, spanIsIgnored, SUPPRESS_TRACING_KEY, } from './trace'; | ||
| export { bindScopeToEmitter } from './bindScopeToEmitter'; | ||
@@ -10,0 +11,0 @@ export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromSpan, getDynamicSamplingContextFromScope, spanToBaggageHeader, } from './dynamicSamplingContext'; |
@@ -0,3 +1,9 @@ | ||
| import { Span } from '../../types/span'; | ||
| import { OpenAiOptions } from './types'; | ||
| /** | ||
| * Extract request attributes from method arguments | ||
| */ | ||
| export declare function extractRequestAttributes(args: unknown[], operationName: string): Record<string, unknown>; | ||
| export declare function addRequestAttributes(span: Span, params: Record<string, unknown>, operationName: string, enableTruncation: boolean): void; | ||
| /** | ||
| * Instrument an OpenAI client with Sentry tracing | ||
@@ -4,0 +10,0 @@ * Can be used across Node.js, Cloudflare Workers, and Vercel Edge |
@@ -26,2 +26,4 @@ import { SpanLink } from '../types/link'; | ||
| private _isStandaloneSpan?; | ||
| /** if true, the span is sealed and ignores further mutations (set after end for tracer-provider spans) */ | ||
| private _frozen?; | ||
| /** | ||
@@ -46,3 +48,3 @@ * You should never call the constructor manually, always use `Sentry.startSpan()` | ||
| */ | ||
| recordException(_exception: unknown, _time?: number | undefined): void; | ||
| recordException(_exception: unknown, _time?: SpanTimeInput | undefined): void; | ||
| /** @inheritdoc */ | ||
@@ -49,0 +51,0 @@ spanContext(): SpanContextData; |
@@ -5,2 +5,3 @@ import { Scope } from '../scope'; | ||
| import { propagationContextFromHeaders } from '../utils/tracing'; | ||
| import { SentryNonRecordingSpan } from './sentryNonRecordingSpan'; | ||
| export declare const SUPPRESS_TRACING_KEY = "__SENTRY_SUPPRESS_TRACING__"; | ||
@@ -40,2 +41,9 @@ /** | ||
| /** | ||
| * Internal version of startInactiveSpan that bypasses the ACS check. | ||
| * Used by SentryTracerProvider to create spans without triggering recursion | ||
| * through ACS overrides. | ||
| * @hidden | ||
| */ | ||
| export declare function _INTERNAL_startInactiveSpan(options: StartSpanOptions): Span; | ||
| /** | ||
| * Continue a trace from `sentry-trace` and `baggage` values. | ||
@@ -83,2 +91,8 @@ * These values can be obtained from incoming request headers, or in the browser from `<meta name="sentry-trace">` | ||
| export declare function startNewTrace<T>(callback: () => T): T; | ||
| /** | ||
| * Whether a span is an ignored (`ignoreSpans`) placeholder. Such a span must not be set as the active | ||
| * span when it has a parent, so its children attach to that parent and get re-parented rather than | ||
| * dropped with it. Shared with the OTel-based provider so both span pipelines apply the same rule. | ||
| */ | ||
| export declare function spanIsIgnored(span: Span): span is SentryNonRecordingSpan; | ||
| //# sourceMappingURL=trace.d.ts.map |
@@ -21,2 +21,19 @@ import { Scope } from '../scope'; | ||
| export declare function spanShouldInferOtelSource(span: Span): boolean; | ||
| /** | ||
| * Mark that user code explicitly set `sentry.source` on a span subject to OTel-style inference, so | ||
| * `applyOtelSpanData` keeps that source (and name) instead of overriding it. Set by `SentrySpan` | ||
| * when `setAttribute` writes the source on an already-branded span (the default `custom` source is | ||
| * stamped at construction, before the brand, so it doesn't trip this). | ||
| */ | ||
| export declare function markSpanSourceAsExplicit(span: Span): void; | ||
| /** Whether user code explicitly set `sentry.source` on a span (see {@link markSpanSourceAsExplicit}). */ | ||
| export declare function spanSourceWasExplicitlySet(span: Span): boolean; | ||
| /** | ||
| * Mark a span as created by the `SentryTracerProvider` (via the OTel tracer). Set by `SentryTracer` | ||
| * on every span it creates; read by `SentrySpan.end()` to seal the span against further writes once | ||
| * it has ended, mirroring OTel SDK spans (which are immutable after `end()`). | ||
| */ | ||
| export declare function markSpanAsTracerProviderSpan(span: Span): void; | ||
| /** Whether a span was created by the `SentryTracerProvider` (see {@link markSpanAsTracerProviderSpan}). */ | ||
| export declare function spanIsTracerProviderSpan(span: Span): boolean; | ||
| //# sourceMappingURL=utils.d.ts.map |
@@ -11,2 +11,3 @@ import { Event } from './event'; | ||
| trace_ids: string[]; | ||
| segment_names: string[]; | ||
| replay_id: string; | ||
@@ -13,0 +14,0 @@ segment_id: number; |
@@ -272,5 +272,5 @@ import { Attributes, RawAttributes } from '../attributes'; | ||
| */ | ||
| recordException(exception: unknown, time?: number): void; | ||
| recordException(exception: unknown, time?: SpanTimeInput): void; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=span.d.ts.map |
| import { RawAttributes } from '../attributes'; | ||
| import { SentrySpan } from '../tracing/sentrySpan'; | ||
| import { TraceContext } from '../types/context'; | ||
@@ -67,2 +68,7 @@ import { SpanLink, SpanLinkJSON } from '../types/link'; | ||
| /** | ||
| * Sadly, due to circular dependency checks we cannot actually import the Span class here and check for instanceof. | ||
| * :( So instead we approximate this by checking if it has the `getSpanJSON` method. | ||
| */ | ||
| export declare function spanIsSentrySpan(span: Span): span is SentrySpan; | ||
| /** | ||
| * Returns true if a span is sampled. | ||
@@ -69,0 +75,0 @@ * In most cases, you should just use `span.isRecording()` instead. |
@@ -5,2 +5,3 @@ import type { AsyncContextStack } from './asyncContext/stackStrategy'; | ||
| import type { Scope } from './scope'; | ||
| import type { SegmentSpanCaptureStrategy } from './tracing/segmentSpanCaptureStrategy'; | ||
| import type { SerializedLog } from './types/log'; | ||
@@ -37,2 +38,4 @@ import type { SerializedMetric } from './types/metric'; | ||
| clientToMetricBufferMap?: WeakMap<Client, Array<SerializedMetric>>; | ||
| /** Strategy for assembling segment spans into transactions; set by SDKs that defer capture. */ | ||
| segmentSpanCaptureStrategy?: SegmentSpanCaptureStrategy; | ||
| /** Overwrites TextEncoder used in `@sentry/core`, need for `react-native@0.73` and older */ | ||
@@ -39,0 +42,0 @@ encodePolyfill?: (input: string) => Uint8Array; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"carrier.d.ts","sourceRoot":"","sources":["../../src/carrier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAA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AO,CAAC,MAAM,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEnE,+FAA+F;IAC/F,0BAA0B,CAAC,EAAE,0BAA0B,CAAC;IAExD,4FAA4F;IAC5F,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,UAAU,CAAC;IAC/C,4FAA4F;IAC5F,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,MAAM,CAAC;CAChD;AAED;;;;;;IAMI;AACJ,wBAAgB,cAAc,IAAI,OAAO,CAIxC;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CAShE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,SAAS,MAAM,aAAa,EACjE,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,EAC/C,GAAG,4CAAa,GACf,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAKlC"} |
@@ -6,3 +6,3 @@ import type { IntegrationFn } from '../../types/integration'; | ||
| } | ||
| export type GrowthBookClassLike = new (...args: unknown[]) => GrowthBookLike; | ||
| export type GrowthBookClassLike = new (...args: any[]) => GrowthBookLike; | ||
| /** | ||
@@ -9,0 +9,0 @@ * Sentry integration for capturing feature flag evaluations from GrowthBook. |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"growthbook.d.ts","sourceRoot":"","sources":["../../../../src/integrations/featureFlags/growthbook.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAQ7D,UAAU,cAAc;IACtB,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5E,eAAe,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;CAC/G;AAED,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,cAAc,CAAC;AAE7E;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAwBnC,CAAC"} | ||
| {"version":3,"file":"growthbook.d.ts","sourceRoot":"","sources":["../../../../src/integrations/featureFlags/growthbook.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAQ7D,UAAU,cAAc;IACtB,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5E,eAAe,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;CAC/G;AAID,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,cAAc,CAAC;AAEzE;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAwBnC,CAAC"} |
| /** | ||
| * Use this attribute to represent the source of a span name. | ||
| * Must be one of: custom, url, route, view, component, task | ||
| * TODO(v11): rename this to sentry.span.source' | ||
| * TODO(v11): remove this export | ||
| */ | ||
@@ -6,0 +6,0 @@ export declare const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = "sentry.source"; |
@@ -49,3 +49,3 @@ /** | ||
| export { addAutoIpAddressToUser } from './utils/ipAddress'; | ||
| export { convertSpanLinksForEnvelope, spanToTraceHeader, spanToJSON, spanToStreamedSpanJSON, spanIsSampled, spanToTraceContext, getSpanDescendants, getStatusMessage, getRootSpan, INTERNAL_getSegmentSpan, getActiveSpan, addChildSpanToSpan, spanTimeInputToSeconds, updateSpanName, } from './utils/spanUtils'; | ||
| export { convertSpanLinksForEnvelope, spanToTraceHeader, spanToJSON, spanToStreamedSpanJSON, spanIsSampled, spanIsSentrySpan, spanToTraceContext, getSpanDescendants, getStatusMessage, getRootSpan, INTERNAL_getSegmentSpan, getActiveSpan, addChildSpanToSpan, spanTimeInputToSeconds, updateSpanName, } from './utils/spanUtils'; | ||
| export { _setSpanForScope as _INTERNAL_setSpanForScope } from './utils/spanOnScope'; | ||
@@ -97,9 +97,12 @@ export { parseSampleRate } from './utils/parseSampleRate'; | ||
| export { addVercelAiProcessors, getProviderMetadataAttributes } from './tracing/vercel-ai'; | ||
| export { getTruncatedJsonString, shouldEnableTruncation } from './tracing/ai/utils'; | ||
| export { GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, } from './tracing/ai/gen-ai-attributes'; | ||
| export { getTruncatedJsonString, shouldEnableTruncation, resolveAIRecordingOptions } from './tracing/ai/utils'; | ||
| export { GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE, GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE, } from './tracing/ai/gen-ai-attributes'; | ||
| export { _INTERNAL_getSpanContextForToolCallId, _INTERNAL_cleanupToolCallSpanContext } from './tracing/vercel-ai/utils'; | ||
| export { toolCallSpanContextMap as _INTERNAL_toolCallSpanContextMap } from './tracing/vercel-ai/constants'; | ||
| export { instrumentOpenAiClient } from './tracing/openai'; | ||
| export { instrumentOpenAiClient, extractRequestAttributes as extractOpenAiRequestAttributes, addRequestAttributes as addOpenAiRequestAttributes, } from './tracing/openai'; | ||
| export { addResponseAttributes as addOpenAiResponseAttributes, extractRequestParameters as extractOpenAiRequestParameters, } from './tracing/openai/utils'; | ||
| export { instrumentStream as instrumentOpenAiStream } from './tracing/openai/streaming'; | ||
| export { OPENAI_INTEGRATION_NAME } from './tracing/openai/constants'; | ||
| export { instrumentAnthropicAiClient } from './tracing/anthropic-ai'; | ||
| export { instrumentAnthropicAiClient, extractRequestAttributes as extractAnthropicRequestAttributes, addPrivateRequestAttributes as addAnthropicRequestAttributes, addResponseAttributes as addAnthropicResponseAttributes, } from './tracing/anthropic-ai'; | ||
| export { instrumentAsyncIterableStream, instrumentMessageStream } from './tracing/anthropic-ai/streaming'; | ||
| export { ANTHROPIC_AI_INTEGRATION_NAME } from './tracing/anthropic-ai/constants'; | ||
@@ -106,0 +109,0 @@ export { instrumentGoogleGenAIClient } from './tracing/google-genai'; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"shared-exports.d.ts","sourceRoot":"","sources":["../../src/shared-exports.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EAAE,WAAW,IAAI,uBAAuB,EAAE,MAAM,OAAO,CAAC;AACpE,YAAY,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACxF,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAClF,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC5F,OAAO,EACL,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,WAAW,EACX,KAAK,EACL,KAAK,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,YAAY,EACZ,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,YAAY,EACZ,UAAU,EACV,cAAc,EACd,iBAAiB,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B,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,2CAA2C,CAAC;AACnD,YAAY,EAAE,uBAAuB,IAAI,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAC9G,OAAO,EACL,qBAAqB,IAAI,+BAA+B,EACxD,cAAc,IAAI,wBAAwB,EAC1C,WAAW,IAAI,qBAAqB,GACrC,MAAM,2BAA2B,CAAC"} |
@@ -1,3 +0,17 @@ | ||
| import type { AnthropicAiOptions } from './types'; | ||
| import type { Span } from '../../types/span'; | ||
| import type { AnthropicAiOptions, AnthropicAiResponse } from './types'; | ||
| /** | ||
| * Extract request attributes from method arguments | ||
| */ | ||
| export declare function extractRequestAttributes(args: unknown[], methodPath: string, operationName: string): Record<string, unknown>; | ||
| /** | ||
| * Add private request attributes to spans. | ||
| * This is only recorded if recordInputs is true. | ||
| */ | ||
| export declare function addPrivateRequestAttributes(span: Span, params: Record<string, unknown>, enableTruncation: boolean): void; | ||
| /** | ||
| * Add response attributes to spans | ||
| */ | ||
| export declare function addResponseAttributes(span: Span, response: AnthropicAiResponse, recordOutputs?: boolean): void; | ||
| /** | ||
| * Instrument an Anthropic AI client with Sentry tracing | ||
@@ -4,0 +18,0 @@ * Can be used across Node.js, Cloudflare Workers, and Vercel Edge |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tracing/anthropic-ai/index.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,kBAAkB,EAAgE,MAAM,SAAS,CAAC;AAmUhH;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,MAAM,EAAE,iBAAiB,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,CAAC,CAEnH"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tracing/anthropic-ai/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAsB,MAAM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I,CAAA;CAAE,EACpF,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,OAAO,GACrB,CAAC,CAuCH"} | ||
| {"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../../../src/tracing/anthropic-ai/streaming.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAwMzD;;;;GAIG;AACH,wBAAuB,6BAA6B,CAClD,MAAM,EAAE,aAAa,CAAC,yBAAyB,CAAC,EAChD,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,OAAO,GACrB,cAAc,CAAC,yBAAyB,EAAE,IAAI,EAAE,OAAO,CAAC,CAsB1D;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;CAAE,EACpF,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,OAAO,GACrB,CAAC,CAuCH"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"dynamicSamplingContext.d.ts","sourceRoot":"","sources":["../../../src/tracing/dynamicSamplingContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGxC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAMtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAmB1C;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAAG,IAAI,CAGtF;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CAAC,QA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AAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAGlE"} |
| export { registerSpanErrorInstrumentation } from './errors'; | ||
| export { setCapturedScopesOnSpan, getCapturedScopesOnSpan, markSpanForOtelSourceInference, spanShouldInferOtelSource, } from './utils'; | ||
| export { setCapturedScopesOnSpan, getCapturedScopesOnSpan, markSpanForOtelSourceInference, spanShouldInferOtelSource, markSpanSourceAsExplicit, spanSourceWasExplicitlySet, markSpanAsTracerProviderSpan, spanIsTracerProviderSpan, } from './utils'; | ||
| export { startIdleSpan, TRACING_DEFAULTS } from './idleSpan'; | ||
| export { SentrySpan } from './sentrySpan'; | ||
| export { _INTERNAL_setDeferSegmentSpanCapture } from './deferSegmentSpanCapture'; | ||
| export { SentryNonRecordingSpan } from './sentryNonRecordingSpan'; | ||
| export { setHttpStatus, getSpanStatusFromHttpCode } from './spanstatus'; | ||
| export { SPAN_STATUS_ERROR, SPAN_STATUS_OK, SPAN_STATUS_UNSET } from './spanstatus'; | ||
| export { startSpan, startInactiveSpan, startSpanManual, continueTrace, withActiveSpan, suppressTracing, isTracingSuppressed, startNewTrace, SUPPRESS_TRACING_KEY, } from './trace'; | ||
| export { startSpan, startInactiveSpan, _INTERNAL_startInactiveSpan, startSpanManual, continueTrace, withActiveSpan, suppressTracing, isTracingSuppressed, startNewTrace, spanIsIgnored, SUPPRESS_TRACING_KEY, } from './trace'; | ||
| export { bindScopeToEmitter } from './bindScopeToEmitter'; | ||
@@ -10,0 +11,0 @@ export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromSpan, getDynamicSamplingContextFromScope, spanToBaggageHeader, } from './dynamicSamplingContext'; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,8BAA8B,EAC9B,yBAAyB,GAC1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C;AAC1C,OAAO,EAAE,oCAAoC,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,2BAA2B,EAC3B,eAAe,EACf,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,oBAAoB,GACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EACL,mCAAmC,EACnC,iCAAiC,EACjC,kCAAkC,EAClC,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGtD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC"} |
@@ -0,3 +1,9 @@ | ||
| import type { Span } from '../../types/span'; | ||
| import type { OpenAiOptions } from './types'; | ||
| /** | ||
| * Extract request attributes from method arguments | ||
| */ | ||
| export declare function extractRequestAttributes(args: unknown[], operationName: string): Record<string, unknown>; | ||
| export declare function addRequestAttributes(span: Span, params: Record<string, unknown>, operationName: string, enableTruncation: boolean): void; | ||
| /** | ||
| * Instrument an OpenAI client with Sentry tracing | ||
@@ -4,0 +10,0 @@ * Can be used across Node.js, Cloudflare Workers, and Vercel Edge |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tracing/openai/index.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAuB,aAAa,EAAwC,MAAM,SAAS,CAAC;AAkPxG;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,CAAC,CAE9F"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tracing/openai/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAsB,MAAM,kBAAkB,CAAC;AAwBjE,OAAO,KAAK,EAAuB,aAAa,EAAwC,MAAM,SAAS,CAAC;AA0BxG;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqBxG;AAGD,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,OAAO,GACxB,IAAI,CAmDN;AAqID;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,CAAC,CAE9F"} |
@@ -26,2 +26,4 @@ import type { SpanLink } from '../types/link'; | ||
| private _isStandaloneSpan?; | ||
| /** if true, the span is sealed and ignores further mutations (set after end for tracer-provider spans) */ | ||
| private _frozen?; | ||
| /** | ||
@@ -46,3 +48,3 @@ * You should never call the constructor manually, always use `Sentry.startSpan()` | ||
| */ | ||
| recordException(_exception: unknown, _time?: number | undefined): void; | ||
| recordException(_exception: unknown, _time?: SpanTimeInput | undefined): void; | ||
| /** @inheritdoc */ | ||
@@ -49,0 +51,0 @@ spanContext(): SpanContextData; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"sentrySpan.d.ts","sourceRoot":"","sources":["../../../src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 -5,2 +5,3 @@ import type { Scope } from '../scope'; | ||
| import { propagationContextFromHeaders } from '../utils/tracing'; | ||
| import { SentryNonRecordingSpan } from './sentryNonRecordingSpan'; | ||
| export declare const SUPPRESS_TRACING_KEY = "__SENTRY_SUPPRESS_TRACING__"; | ||
@@ -40,2 +41,9 @@ /** | ||
| /** | ||
| * Internal version of startInactiveSpan that bypasses the ACS check. | ||
| * Used by SentryTracerProvider to create spans without triggering recursion | ||
| * through ACS overrides. | ||
| * @hidden | ||
| */ | ||
| export declare function _INTERNAL_startInactiveSpan(options: StartSpanOptions): Span; | ||
| /** | ||
| * Continue a trace from `sentry-trace` and `baggage` values. | ||
@@ -83,2 +91,8 @@ * These values can be obtained from incoming request headers, or in the browser from `<meta name="sentry-trace">` | ||
| export declare function startNewTrace<T>(callback: () => T): T; | ||
| /** | ||
| * Whether a span is an ignored (`ignoreSpans`) placeholder. Such a span must not be set as the active | ||
| * span when it has a parent, so its children attach to that parent and get re-parented rather than | ||
| * dropped with it. Shared with the OTel-based provider so both span pipelines apply the same rule. | ||
| */ | ||
| export declare function spanIsIgnored(span: Span): span is SentryNonRecordingSpan; | ||
| //# sourceMappingURL=trace.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../../src/tracing/trace.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAOtC,OAAO,KAAK,EAAuB,IAAI,EAAiB,MAAM,eAAe,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAYlE,OAAO,EAAE,6BAA6B,EAAuB,MAAM,kBAAkB,CAAC;AAUtF,eAAO,MAAM,oBAAoB,gCAAgC,CAAC;AAElE;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,C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B,mBAAmB,CAAC,KAAK,QAAoB,GAAG,OAAO,CAQtE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAcrD;AA+TD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,sBAAsB,CAExE"} |
@@ -21,2 +21,19 @@ import type { Scope } from '../scope'; | ||
| export declare function spanShouldInferOtelSource(span: Span): boolean; | ||
| /** | ||
| * Mark that user code explicitly set `sentry.source` on a span subject to OTel-style inference, so | ||
| * `applyOtelSpanData` keeps that source (and name) instead of overriding it. Set by `SentrySpan` | ||
| * when `setAttribute` writes the source on an already-branded span (the default `custom` source is | ||
| * stamped at construction, before the brand, so it doesn't trip this). | ||
| */ | ||
| export declare function markSpanSourceAsExplicit(span: Span): void; | ||
| /** Whether user code explicitly set `sentry.source` on a span (see {@link markSpanSourceAsExplicit}). */ | ||
| export declare function spanSourceWasExplicitlySet(span: Span): boolean; | ||
| /** | ||
| * Mark a span as created by the `SentryTracerProvider` (via the OTel tracer). Set by `SentryTracer` | ||
| * on every span it creates; read by `SentrySpan.end()` to seal the span against further writes once | ||
| * it has ended, mirroring OTel SDK spans (which are immutable after `end()`). | ||
| */ | ||
| export declare function markSpanAsTracerProviderSpan(span: Span): void; | ||
| /** Whether a span was created by the `SentryTracerProvider` (see {@link markSpanAsTracerProviderSpan}). */ | ||
| export declare function spanIsTracerProviderSpan(span: Span): boolean; | ||
| //# sourceMappingURL=utils.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tracing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAsB1C,+FAA+F;AAC/F,wBAAgB,uBAAuB,CA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AgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAE7D;AAED,2GAA2G;AAC3G,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAE5D"} |
@@ -11,2 +11,3 @@ import type { Event } from './event'; | ||
| trace_ids: string[]; | ||
| segment_names: string[]; | ||
| replay_id: string; | ||
@@ -13,0 +14,0 @@ segment_id: number; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../../src/types/replay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,WAAY,SAAQ,KAAK;IACxC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,mBAAmB,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,UAAU,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEvD;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR,gBAAgB,GAChB,WAAW,GACX,eAAe,GACf,kBAAkB,GAClB,qBAAqB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,mBAAmB,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,gBAAgB,CAAC;CAC1B"} | ||
| {"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../../src/types/replay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,WAAY,SAAQ,KAAK;IACxC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,mBAAmB,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,UAAU,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEvD;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR,gBAAgB,GAChB,WAAW,GACX,eAAe,GACf,kBAAkB,GAClB,qBAAqB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,mBAAmB,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,gBAAgB,CAAC;CAC1B"} |
@@ -272,5 +272,5 @@ import type { Attributes, RawAttributes } from '../attributes'; | ||
| */ | ||
| recordException(exception: unknown, time?: number): void; | ||
| recordException(exception: unknown, time?: SpanTimeInput): void; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=span.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"span.d.ts","sourceRoot":"","sources":["../../../src/types/span.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe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AAK,EAAE,kBAAkB,GAAG,SAAS,GAAG,IAAI,CAAC;IAEvE;;;OAGG;IACH,aAAa,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI,CAAC;IAEhD;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAEpC;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,qBAAqB,CAAC,EAAE,cAAc,GAAG,aAAa,EAAE,SAAS,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAEhH;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IAE9B;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAElC;;OAEG;IACH,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;CACjE"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/utils/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAIxE"} | ||
| {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/utils/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAQxE"} |
| import type { RawAttributes } from '../attributes'; | ||
| import type { SentrySpan } from '../tracing/sentrySpan'; | ||
| import type { TraceContext } from '../types/context'; | ||
@@ -67,2 +68,7 @@ import type { SpanLink, SpanLinkJSON } from '../types/link'; | ||
| /** | ||
| * Sadly, due to circular dependency checks we cannot actually import the Span class here and check for instanceof. | ||
| * :( So instead we approximate this by checking if it has the `getSpanJSON` method. | ||
| */ | ||
| export declare function spanIsSentrySpan(span: Span): span is SentrySpan; | ||
| /** | ||
| * Returns true if a span is sampled. | ||
@@ -69,0 +75,0 @@ * In most cases, you should just use `span.isRecording()` instead. |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"spanUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/spanUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAcnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EACV,sBAAsB,EACtB,IAAI,EACJ,cAAc,EACd,QAAQ,EAER,aAAa,EACb,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAStD,eAAO,MAAM,eAAe,IAAM,CAAC;AACnC,eAAO,MAAM,kBAAkB,IAAM,CAAC;AAItC;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,IAAI,GAAG,YAAY,CActE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,YAAY,CAe3D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAIpD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAI1D;AAED;;;;GAIG;AACH,wBAAgB,2BA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AkD;AAClD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,yBAAyB,EAAE,SAAS,EAAE,IAAI,GAAG,IAAI,CAI9F;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,yBAAyB,GAAG,IAAI,EAAE,CAoB1E;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,gCAA0B,CAAC;AAEnD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,yBAAyB,GAAG,IAAI,CAE7E;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,IAAI,GAAG,SAAS,CAQhD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAU1C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAM7D"} |
+4
-1
| { | ||
| "name": "@sentry/core", | ||
| "version": "10.63.0", | ||
| "version": "10.64.0", | ||
| "description": "Base implementation for all Sentry JavaScript SDKs", | ||
@@ -109,3 +109,6 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
| "zod": "^3.24.1" | ||
| }, | ||
| "dependencies": { | ||
| "@sentry/conventions": "^0.15.1" | ||
| } | ||
| } |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
6734705
1.16%1839
0.77%68712
0.95%1
Infinity%+ Added
+ Added