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
77 lines
2.3 KiB
Plaintext
77 lines
2.3 KiB
Plaintext
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
|
const instrumentation = require('@opentelemetry/instrumentation');
|
|
const core = require('@sentry/core');
|
|
|
|
const supportedVersions = ['>=0.0.0 <2.0.0'];
|
|
|
|
/**
|
|
* Sentry LangGraph instrumentation using OpenTelemetry.
|
|
*/
|
|
class SentryLangGraphInstrumentation extends instrumentation.InstrumentationBase {
|
|
constructor(config = {}) {
|
|
super('@sentry/instrumentation-langgraph', core.SDK_VERSION, config);
|
|
}
|
|
|
|
/**
|
|
* Initializes the instrumentation by defining the modules to be patched.
|
|
*/
|
|
init() {
|
|
const module = new instrumentation.InstrumentationNodeModuleDefinition(
|
|
'@langchain/langgraph',
|
|
supportedVersions,
|
|
this._patch.bind(this),
|
|
exports$1 => exports$1,
|
|
[
|
|
new instrumentation.InstrumentationNodeModuleFile(
|
|
/**
|
|
* In CJS, LangGraph packages re-export from dist/index.cjs files.
|
|
* Patching only the root module sometimes misses the real implementation or
|
|
* gets overwritten when that file is loaded. We add a file-level patch so that
|
|
* _patch runs again on the concrete implementation
|
|
*/
|
|
'@langchain/langgraph/dist/index.cjs',
|
|
supportedVersions,
|
|
this._patch.bind(this),
|
|
exports$1 => exports$1,
|
|
),
|
|
],
|
|
);
|
|
return module;
|
|
}
|
|
|
|
/**
|
|
* Core patch logic applying instrumentation to the LangGraph module.
|
|
*/
|
|
_patch(exports$1) {
|
|
const client = core.getClient();
|
|
const defaultPii = Boolean(client?.getOptions().sendDefaultPii);
|
|
|
|
const config = this.getConfig();
|
|
const recordInputs = config.recordInputs ?? defaultPii;
|
|
const recordOutputs = config.recordOutputs ?? defaultPii;
|
|
|
|
const options = {
|
|
recordInputs,
|
|
recordOutputs,
|
|
};
|
|
|
|
// Patch StateGraph.compile to instrument both compile() and invoke()
|
|
if (exports$1.StateGraph && typeof exports$1.StateGraph === 'function') {
|
|
const StateGraph = exports$1.StateGraph
|
|
|
|
;
|
|
|
|
StateGraph.prototype.compile = core.instrumentStateGraphCompile(
|
|
StateGraph.prototype.compile ,
|
|
options,
|
|
);
|
|
}
|
|
|
|
return exports$1;
|
|
}
|
|
}
|
|
|
|
exports.SentryLangGraphInstrumentation = SentryLangGraphInstrumentation;
|
|
//# sourceMappingURL=instrumentation.js.map
|