Files
klz-cables.com/.pnpm-store/v10/files/a9/d8481b5266e13adca72c6d5e2444c7517d525b20e3f9124e7e8a4e41f097010dafcf8de35a7bd7025925d3c51ab3fc88267b1c1124f7c70c35b1d4d7176e0b
Marc Mintel 5397309103
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
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

98 lines
3.2 KiB
Plaintext

Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const instrumentation = require('@opentelemetry/instrumentation');
const core = require('@sentry/core');
const supportedVersions = ['>=0.10.0 <2'];
/**
* Represents the patched shape of the Google GenAI module export.
*/
/**
* Sentry Google GenAI instrumentation using OpenTelemetry.
*/
class SentryGoogleGenAiInstrumentation extends instrumentation.InstrumentationBase {
constructor(config = {}) {
super('@sentry/instrumentation-google-genai', core.SDK_VERSION, config);
}
/**
* Initializes the instrumentation by defining the modules to be patched.
*/
init() {
const module = new instrumentation.InstrumentationNodeModuleDefinition(
'@google/genai',
supportedVersions,
exports$1 => this._patch(exports$1),
exports$1 => exports$1,
// In CJS, @google/genai re-exports from (dist/node/index.cjs) file.
// 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
[
new instrumentation.InstrumentationNodeModuleFile(
'@google/genai/dist/node/index.cjs',
supportedVersions,
exports$1 => this._patch(exports$1),
exports$1 => exports$1,
),
],
);
return module;
}
/**
* Core patch logic applying instrumentation to the Google GenAI client constructor.
*/
_patch(exports$1) {
const Original = exports$1.GoogleGenAI;
const config = this.getConfig();
if (typeof Original !== 'function') {
return exports$1;
}
const WrappedGoogleGenAI = function ( ...args) {
// Check if wrapping should be skipped (e.g., when LangChain is handling instrumentation)
if (core._INTERNAL_shouldSkipAiProviderWrapping(core.GOOGLE_GENAI_INTEGRATION_NAME)) {
return Reflect.construct(Original, args) ;
}
const instance = Reflect.construct(Original, args);
const client = core.getClient();
const defaultPii = Boolean(client?.getOptions().sendDefaultPii);
const typedConfig = config;
const recordInputs = typedConfig?.recordInputs ?? defaultPii;
const recordOutputs = typedConfig?.recordOutputs ?? defaultPii;
return core.instrumentGoogleGenAIClient(instance, {
recordInputs,
recordOutputs,
});
};
// Preserve static and prototype chains
Object.setPrototypeOf(WrappedGoogleGenAI, Original);
Object.setPrototypeOf(WrappedGoogleGenAI.prototype, Original.prototype);
for (const key of Object.getOwnPropertyNames(Original)) {
if (!['length', 'name', 'prototype'].includes(key)) {
const descriptor = Object.getOwnPropertyDescriptor(Original, key);
if (descriptor) {
Object.defineProperty(WrappedGoogleGenAI, key, descriptor);
}
}
}
// Replace google genai exports with the wrapped constructor
core.replaceExports(exports$1, 'GoogleGenAI', WrappedGoogleGenAI);
return exports$1;
}
}
exports.SentryGoogleGenAiInstrumentation = SentryGoogleGenAiInstrumentation;
//# sourceMappingURL=instrumentation.js.map