Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
4.3 KiB
Plaintext
1 line
4.3 KiB
Plaintext
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/langgraph/instrumentation.ts"],"sourcesContent":["import {\n InstrumentationBase,\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n} from '@opentelemetry/instrumentation';\nimport type { CompiledGraph, LangGraphOptions } from '@sentry/core';\nimport { getClient, instrumentStateGraphCompile, SDK_VERSION } from '@sentry/core';\n\nconst supportedVersions = ['>=0.0.0 <2.0.0'];\n\ntype LangGraphInstrumentationOptions = InstrumentationConfig & LangGraphOptions;\n\n/**\n * Represents the patched shape of the LangGraph module export.\n */\ninterface PatchedModuleExports {\n [key: string]: unknown;\n StateGraph?: abstract new (...args: unknown[]) => unknown;\n}\n\n/**\n * Sentry LangGraph instrumentation using OpenTelemetry.\n */\nexport class SentryLangGraphInstrumentation extends InstrumentationBase<LangGraphInstrumentationOptions> {\n public constructor(config: LangGraphInstrumentationOptions = {}) {\n super('@sentry/instrumentation-langgraph', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation by defining the modules to be patched.\n */\n public init(): InstrumentationModuleDefinition {\n const module = new InstrumentationNodeModuleDefinition(\n '@langchain/langgraph',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n [\n new InstrumentationNodeModuleFile(\n /**\n * In CJS, LangGraph packages re-export from dist/index.cjs files.\n * Patching only the root module sometimes misses the real implementation or\n * gets overwritten when that file is loaded. We add a file-level patch so that\n * _patch runs again on the concrete implementation\n */\n '@langchain/langgraph/dist/index.cjs',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n ),\n ],\n );\n return module;\n }\n\n /**\n * Core patch logic applying instrumentation to the LangGraph module.\n */\n private _patch(exports: PatchedModuleExports): PatchedModuleExports | void {\n const client = getClient();\n const defaultPii = Boolean(client?.getOptions().sendDefaultPii);\n\n const config = this.getConfig();\n const recordInputs = config.recordInputs ?? defaultPii;\n const recordOutputs = config.recordOutputs ?? defaultPii;\n\n const options: LangGraphOptions = {\n recordInputs,\n recordOutputs,\n };\n\n // Patch StateGraph.compile to instrument both compile() and invoke()\n if (exports.StateGraph && typeof exports.StateGraph === 'function') {\n const StateGraph = exports.StateGraph as {\n prototype: Record<string, unknown>;\n };\n\n StateGraph.prototype.compile = instrumentStateGraphCompile(\n StateGraph.prototype.compile as (...args: unknown[]) => CompiledGraph,\n options,\n );\n }\n\n return exports;\n }\n}\n"],"names":["exports"],"mappings":";;;AAUA,MAAM,iBAAA,GAAoB,CAAC,gBAAgB,CAAC;;AAY5C;AACA;AACA;AACO,MAAM,8BAAA,SAAuC,mBAAmB,CAAkC;AACzG,GAAS,WAAW,CAAC,MAAM,GAAoC,EAAE,EAAE;AACnE,IAAI,KAAK,CAAC,mCAAmC,EAAE,WAAW,EAAE,MAAM,CAAC;AACnE,EAAE;;AAEF;AACA;AACA;AACA,GAAS,IAAI,GAAoC;AACjD,IAAI,MAAM,MAAA,GAAS,IAAI,mCAAmC;AAC1D,MAAM,sBAAsB;AAC5B,MAAM,iBAAiB;AACvB,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;AAC5B,MAAMA,SAAA,IAAWA,SAAO;AACxB,MAAM;AACN,QAAQ,IAAI,6BAA6B;AACzC;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,qCAAqC;AAC/C,UAAU,iBAAiB;AAC3B,UAAU,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;AAChC,UAAUA,SAAA,IAAWA,SAAO;AAC5B,SA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