@sentry/server-utils 11.17.0 → 11.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/chunks/config.js +2 -2
- package/build/cjs/chunks/config.js.map +1 -1
- package/build/cjs/chunks/exports.js +115 -10
- package/build/cjs/chunks/exports.js.map +1 -1
- package/build/cjs/index.js +148 -31
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/index.no-diagnostic-channels.js +1 -0
- package/build/cjs/index.request-handler.js +48 -3
- package/build/cjs/index.request-handler.js.map +1 -1
- package/build/esm/ai/langchain/utils.js +1 -5
- package/build/esm/ai/langchain/utils.js.map +1 -1
- package/build/esm/ai/mistral/streaming.js.map +1 -1
- package/build/esm/exports.js +2 -1
- package/build/esm/index.js +3 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/index.no-diagnostic-channels.js +2 -1
- package/build/esm/index.request-handler.js +3 -1
- package/build/esm/integrations/amqplib.js.map +1 -1
- package/build/esm/integrations/anthropic.js.map +1 -1
- package/build/esm/integrations/bullmq/tracer.js.map +1 -1
- package/build/esm/integrations/graphql/utils.js.map +1 -1
- package/build/esm/integrations/hapi/hapi-utils.js +6 -9
- package/build/esm/integrations/hapi/hapi-utils.js.map +1 -1
- package/build/esm/integrations/hono/isMiddleware.js.map +1 -1
- package/build/esm/integrations/hono/middlewareHandlers.js +3 -1
- package/build/esm/integrations/hono/middlewareHandlers.js.map +1 -1
- package/build/esm/integrations/hono/patchRoute.js +2 -1
- package/build/esm/integrations/hono/patchRoute.js.map +1 -1
- package/build/esm/integrations/hono/unwrapThrownValue.js +20 -0
- package/build/esm/integrations/hono/unwrapThrownValue.js.map +1 -0
- package/build/esm/integrations/mongodb/mongodb-span.js +7 -9
- package/build/esm/integrations/mongodb/mongodb-span.js.map +1 -1
- package/build/esm/integrations/pino.js +2 -2
- package/build/esm/integrations/pino.js.map +1 -1
- package/build/esm/integrations/prisma/tracing-helper.js.map +1 -1
- package/build/esm/integrations/serveTunnel.js +2 -2
- package/build/esm/integrations/serveTunnel.js.map +1 -1
- package/build/esm/integrations/vercel-ai/extract.js +88 -0
- package/build/esm/integrations/vercel-ai/extract.js.map +1 -0
- package/build/esm/integrations/vercel-ai/util.js +5 -1
- package/build/esm/integrations/vercel-ai/util.js.map +1 -1
- package/build/esm/integrations/vercel-ai/vercel-ai-dc-subscriber.js +19 -9
- package/build/esm/integrations/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
- package/build/esm/integrations/winston.js +2 -2
- package/build/esm/integrations/winston.js.map +1 -1
- package/build/esm/orchestrion/config/hono.js +2 -2
- package/build/esm/orchestrion/config/hono.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/utils/installedModules.js +87 -0
- package/build/esm/utils/installedModules.js.map +1 -0
- package/build/esm/utils/module.js +29 -0
- package/build/esm/utils/module.js.map +1 -0
- package/build/esm/utils/serverTimingTraceHeader.js +49 -0
- package/build/esm/utils/serverTimingTraceHeader.js.map +1 -0
- package/build/esm/utils/sql.js +4 -3
- package/build/esm/utils/sql.js.map +1 -1
- package/build/esm/utils/tunnelServer.js +3 -3
- package/build/esm/utils/tunnelServer.js.map +1 -1
- package/build/esm/utils/wrapServerRequestHandler.js +5 -4
- package/build/esm/utils/wrapServerRequestHandler.js.map +1 -1
- package/build/types/ai/langchain/utils.d.ts.map +1 -1
- package/build/types/ai/mistral/streaming.d.ts.map +1 -1
- package/build/types/exports.d.ts +1 -0
- package/build/types/exports.d.ts.map +1 -1
- package/build/types/index.d.ts +3 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/index.request-handler.d.ts +1 -0
- package/build/types/index.request-handler.d.ts.map +1 -1
- package/build/types/integrations/amqplib.d.ts.map +1 -1
- package/build/types/integrations/anthropic.d.ts.map +1 -1
- package/build/types/integrations/bullmq/tracer.d.ts.map +1 -1
- package/build/types/integrations/hapi/hapi-utils.d.ts.map +1 -1
- package/build/types/integrations/hono/isMiddleware.d.ts.map +1 -1
- package/build/types/integrations/hono/middlewareHandlers.d.ts.map +1 -1
- package/build/types/integrations/hono/patchRoute.d.ts.map +1 -1
- package/build/types/integrations/hono/unwrapThrownValue.d.ts +10 -0
- package/build/types/integrations/hono/unwrapThrownValue.d.ts.map +1 -0
- package/build/types/integrations/mongodb/mongodb-span.d.ts.map +1 -1
- package/build/types/integrations/prisma/tracing-helper.d.ts.map +1 -1
- package/build/types/integrations/vercel-ai/extract.d.ts +27 -0
- package/build/types/integrations/vercel-ai/extract.d.ts.map +1 -0
- package/build/types/integrations/vercel-ai/util.d.ts +2 -0
- package/build/types/integrations/vercel-ai/util.d.ts.map +1 -1
- package/build/types/integrations/vercel-ai/vercel-ai-dc-subscriber.d.ts +1 -1
- package/build/types/integrations/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -1
- package/build/types/utils/installedModules.d.ts +17 -0
- package/build/types/utils/installedModules.d.ts.map +1 -0
- package/build/types/utils/module.d.ts +3 -0
- package/build/types/utils/module.d.ts.map +1 -0
- package/build/types/utils/serverTimingTraceHeader.d.ts +18 -0
- package/build/types/utils/serverTimingTraceHeader.d.ts.map +1 -0
- package/build/types/utils/sql.d.ts.map +1 -1
- package/build/types/utils/tunnelServer.d.ts.map +1 -1
- package/build/types/utils/wrapServerRequestHandler.d.ts.map +1 -1
- package/package.json +4 -4
package/build/cjs/index.js
CHANGED
|
@@ -219,7 +219,7 @@ function wrapRouteHandler(route, pluginName) {
|
|
|
219
219
|
*/
|
|
220
220
|
function wrapExtMethods(method, extPoint, pluginName) {
|
|
221
221
|
if (Array.isArray(method)) {
|
|
222
|
-
for (
|
|
222
|
+
for (const [i, m] of method.entries()) method[i] = wrapExtMethods(m, extPoint);
|
|
223
223
|
return method;
|
|
224
224
|
} else if (isPatchableExtMethod(method)) {
|
|
225
225
|
if (method[handlerPatched] === true) return method;
|
|
@@ -240,7 +240,7 @@ function wrapExtMethods(method, extPoint, pluginName) {
|
|
|
240
240
|
*/
|
|
241
241
|
function wrapRouteArguments(args, pluginName) {
|
|
242
242
|
const route = args[0];
|
|
243
|
-
if (Array.isArray(route)) for (
|
|
243
|
+
if (Array.isArray(route)) for (const [i, r] of route.entries()) route[i] = wrapRouteHandler(r, pluginName);
|
|
244
244
|
else args[0] = wrapRouteHandler(route, pluginName);
|
|
245
245
|
}
|
|
246
246
|
/**
|
|
@@ -252,13 +252,10 @@ function wrapRouteArguments(args, pluginName) {
|
|
|
252
252
|
function wrapExtArguments(args, pluginName) {
|
|
253
253
|
if (Array.isArray(args[0])) {
|
|
254
254
|
const eventsList = args[0];
|
|
255
|
-
for (
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
lifecycleEventObj.method = wrapExtMethods(lifecycleEventObj.method, eventObj.type, pluginName);
|
|
260
|
-
eventsList[i] = lifecycleEventObj;
|
|
261
|
-
}
|
|
255
|
+
for (const [i, eventObj] of eventsList.entries()) if (isLifecycleExtType(eventObj.type)) {
|
|
256
|
+
const lifecycleEventObj = eventObj;
|
|
257
|
+
lifecycleEventObj.method = wrapExtMethods(lifecycleEventObj.method, eventObj.type, pluginName);
|
|
258
|
+
eventsList[i] = lifecycleEventObj;
|
|
262
259
|
}
|
|
263
260
|
return;
|
|
264
261
|
} else if (isDirectExtInput(args)) {
|
|
@@ -7294,12 +7291,12 @@ const tunnelServers = /* @__PURE__ */ new WeakSet();
|
|
|
7294
7291
|
function instrumentTunnelServer(message) {
|
|
7295
7292
|
try {
|
|
7296
7293
|
const server = message?.server;
|
|
7297
|
-
if (!server || tunnelServers.has(server) || (0, _sentry_core_server.
|
|
7294
|
+
if (!server || tunnelServers.has(server) || (0, _sentry_core_server.httpServerHandlesTunnel)()) return;
|
|
7298
7295
|
tunnelServers.add(server);
|
|
7299
7296
|
const originalEmit = server.emit;
|
|
7300
7297
|
server.emit = function(event, ...data) {
|
|
7301
7298
|
const [request, response] = data;
|
|
7302
|
-
if (event === "request" && (0, _sentry_core_server.
|
|
7299
|
+
if (event === "request" && (0, _sentry_core_server.handleServedNodeTunnelRequest)(request, response)) return true;
|
|
7303
7300
|
return originalEmit.call(this, event, ...data);
|
|
7304
7301
|
};
|
|
7305
7302
|
} catch (error) {
|
|
@@ -7315,7 +7312,7 @@ let isSubscribed = false;
|
|
|
7315
7312
|
function instrumentTunnelServers() {
|
|
7316
7313
|
if (isSubscribed) return;
|
|
7317
7314
|
isSubscribed = true;
|
|
7318
|
-
(0, _sentry_core_server.
|
|
7315
|
+
(0, _sentry_core_server.setNodeTunnelHandler)(_sentry_core_server.handleServedNodeTunnelRequest);
|
|
7319
7316
|
subscribe(_sentry_core_server.HTTP_ON_SERVER_REQUEST, instrumentTunnelServer);
|
|
7320
7317
|
}
|
|
7321
7318
|
/**
|
|
@@ -7335,6 +7332,30 @@ function makeServeTunnelIntegration(instrumentRuntimeServers) {
|
|
|
7335
7332
|
};
|
|
7336
7333
|
});
|
|
7337
7334
|
}
|
|
7335
|
+
// src/utils/module.ts
|
|
7336
|
+
/** normalizes Windows paths */
|
|
7337
|
+
function normalizeWindowsPath(path) {
|
|
7338
|
+
return path.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
7339
|
+
}
|
|
7340
|
+
/** Creates a function that gets the module name from a filename */
|
|
7341
|
+
function createGetModuleFromFilename(basePath = process.argv[1] ? (0, _sentry_core.dirname)(process.argv[1]) : process.cwd(), isWindows = node_path.sep === "\\") {
|
|
7342
|
+
const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
|
|
7343
|
+
return (filename) => {
|
|
7344
|
+
if (!filename) return;
|
|
7345
|
+
const normalizedFilename = isWindows ? normalizeWindowsPath(filename) : filename;
|
|
7346
|
+
let { dir, base: file, ext } = node_path.posix.parse(normalizedFilename);
|
|
7347
|
+
if (ext === ".js" || ext === ".mjs" || ext === ".cjs") file = file.slice(0, ext.length * -1);
|
|
7348
|
+
const decodedFile = decodeURIComponent(file);
|
|
7349
|
+
if (!dir) dir = ".";
|
|
7350
|
+
const n = dir.lastIndexOf("/node_modules");
|
|
7351
|
+
if (n > -1) return `${dir.slice(n + 14).replace(/\//g, ".")}:${decodedFile}`;
|
|
7352
|
+
if (dir.startsWith(normalizedBase)) {
|
|
7353
|
+
const moduleName = dir.slice(normalizedBase.length + 1).replace(/\//g, ".");
|
|
7354
|
+
return moduleName ? `${moduleName}:${decodedFile}` : decodedFile;
|
|
7355
|
+
}
|
|
7356
|
+
return decodedFile;
|
|
7357
|
+
};
|
|
7358
|
+
}
|
|
7338
7359
|
// src/integrations/lru-memoizer.ts
|
|
7339
7360
|
const INTEGRATION_NAME$14 = "LruMemoizer";
|
|
7340
7361
|
const _lruMemoizerIntegration = (() => {
|
|
@@ -7367,10 +7388,11 @@ function serializeDbStatement(commandObj) {
|
|
|
7367
7388
|
}
|
|
7368
7389
|
function scrubStatement(value) {
|
|
7369
7390
|
if (Array.isArray(value)) return value.map((element) => scrubStatement(element));
|
|
7370
|
-
if (isCommandObj(value))
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7391
|
+
if (isCommandObj(value)) {
|
|
7392
|
+
const scrubbed = {};
|
|
7393
|
+
for (const key of Object.keys(value)) scrubbed[key] = scrubStatement(value[key]);
|
|
7394
|
+
return scrubbed;
|
|
7395
|
+
}
|
|
7374
7396
|
return "?";
|
|
7375
7397
|
}
|
|
7376
7398
|
function isCommandObj(value) {
|
|
@@ -7379,9 +7401,6 @@ function isCommandObj(value) {
|
|
|
7379
7401
|
function isBuffer(value) {
|
|
7380
7402
|
return typeof Buffer !== "undefined" && Buffer.isBuffer(value);
|
|
7381
7403
|
}
|
|
7382
|
-
function isCommandEntry(value) {
|
|
7383
|
-
return Array.isArray(value);
|
|
7384
|
-
}
|
|
7385
7404
|
/**
|
|
7386
7405
|
* Build span attributes for a mongodb v4+ command from the connection
|
|
7387
7406
|
* context, namespace and command.
|
|
@@ -7420,7 +7439,7 @@ function getSpanAttributes(dbName, dbCollection, host, port, commandObj, operati
|
|
|
7420
7439
|
const portNumber = parseInt(port, 10);
|
|
7421
7440
|
if (!isNaN(portNumber)) attributes[_sentry_conventions_attributes.SERVER_PORT] = portNumber;
|
|
7422
7441
|
}
|
|
7423
|
-
if (commandObj) try {
|
|
7442
|
+
if (commandObj && (0, _sentry_core.getActiveSpan)()?.isRecording()) try {
|
|
7424
7443
|
attributes[_sentry_conventions_attributes.DB_QUERY_TEXT] = serializeDbStatement(commandObj);
|
|
7425
7444
|
} catch {}
|
|
7426
7445
|
return attributes;
|
|
@@ -8234,7 +8253,7 @@ const _pinoIntegration = (0, _sentry_core.defineIntegration)((userOptions = {})
|
|
|
8234
8253
|
[_sentry_conventions_attributes.SENTRY_ORIGIN]: "auto.log.pino",
|
|
8235
8254
|
"pino.logger.level": levelNumber
|
|
8236
8255
|
};
|
|
8237
|
-
(0, _sentry_core.
|
|
8256
|
+
(0, _sentry_core.captureLogEvent)({
|
|
8238
8257
|
level,
|
|
8239
8258
|
message: logMessage,
|
|
8240
8259
|
attributes
|
|
@@ -8347,7 +8366,7 @@ function createSentryWinstonTransport(TransportClass, sentryWinstonOptions) {
|
|
|
8347
8366
|
const customLevel = sentryWinstonOptions?.customLevelMap?.[levelFromSymbol];
|
|
8348
8367
|
const winstonLogLevel = WINSTON_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP[levelFromSymbol];
|
|
8349
8368
|
const logSeverityLevel = customLevel ?? winstonLogLevel ?? "info";
|
|
8350
|
-
if (this._levels.has(logSeverityLevel)) (0, _sentry_core.
|
|
8369
|
+
if (this._levels.has(logSeverityLevel)) (0, _sentry_core.captureLogEvent)({
|
|
8351
8370
|
level: logSeverityLevel,
|
|
8352
8371
|
message,
|
|
8353
8372
|
attributes: {
|
|
@@ -9332,6 +9351,93 @@ function accumulateChunk(state, chunk) {
|
|
|
9332
9351
|
default: return;
|
|
9333
9352
|
}
|
|
9334
9353
|
}
|
|
9354
|
+
/** Maps each object value of `record` and keeps the other values as they are. */
|
|
9355
|
+
function mapObjectValues(record, fn) {
|
|
9356
|
+
return Object.fromEntries(Object.entries(record).map(([key, value]) => [key, (0, _sentry_core.isObjectLike)(value) ? fn(value, key) : value]));
|
|
9357
|
+
}
|
|
9358
|
+
// src/integrations/vercel-ai/extract.ts
|
|
9359
|
+
/** Maps the AI SDK `experimental_extract` input and output to the Clairic shape of the `gen_ai.extract` schemas. */
|
|
9360
|
+
/**
|
|
9361
|
+
* Joins the text of the AI SDK state parts into one Clairic `state` string. The gateway does this join on
|
|
9362
|
+
* the server and does not show its separator, so this one is our choice. It only makes the recorded text
|
|
9363
|
+
* easier to read: the answer spans stay correct with any separator, because we add each part's offset.
|
|
9364
|
+
*/
|
|
9365
|
+
const EXTRACT_STATE_SEPARATOR = "\n\n";
|
|
9366
|
+
const BLOB_SUBSTITUTE = "[Blob substitute]";
|
|
9367
|
+
/**
|
|
9368
|
+
* Clairic takes the text as one `state` string, with images and PDF documents in their own arrays. The AI SDK
|
|
9369
|
+
* also takes a JSON object, or an array of text, JSON and file parts. Join the text of the parts and keep the
|
|
9370
|
+
* offset of each part, so that the answer spans point into the joined `state`.
|
|
9371
|
+
*/
|
|
9372
|
+
function toExtractState(state) {
|
|
9373
|
+
const images = [];
|
|
9374
|
+
const documents = [];
|
|
9375
|
+
let joined = "";
|
|
9376
|
+
const parts = (Array.isArray(state) ? state : [{
|
|
9377
|
+
type: "json",
|
|
9378
|
+
value: state
|
|
9379
|
+
}]).map((part) => {
|
|
9380
|
+
if (!(0, _sentry_core.isObjectLike)(part)) return;
|
|
9381
|
+
if (part.type === "file") {
|
|
9382
|
+
if (String(part.mediaType).split("/")[0] === "image") {
|
|
9383
|
+
images.push(BLOB_SUBSTITUTE);
|
|
9384
|
+
return "image";
|
|
9385
|
+
}
|
|
9386
|
+
if (part.mediaType === "application/pdf") documents.push(BLOB_SUBSTITUTE);
|
|
9387
|
+
return;
|
|
9388
|
+
}
|
|
9389
|
+
const text = part.type === "text" ? part.text : (0, _sentry_core.stringify)(part.value);
|
|
9390
|
+
if (typeof text !== "string") return;
|
|
9391
|
+
joined += EXTRACT_STATE_SEPARATOR + text;
|
|
9392
|
+
return joined.length - text.length - 2;
|
|
9393
|
+
});
|
|
9394
|
+
return {
|
|
9395
|
+
request: {
|
|
9396
|
+
state: joined ? joined.slice(2) : void 0,
|
|
9397
|
+
images: images.length ? images : void 0,
|
|
9398
|
+
documents: documents.length ? documents : void 0
|
|
9399
|
+
},
|
|
9400
|
+
parts
|
|
9401
|
+
};
|
|
9402
|
+
}
|
|
9403
|
+
/**
|
|
9404
|
+
* The AI SDK also takes JSON or `null` as field `instructions`, but the schema allows only a string.
|
|
9405
|
+
*/
|
|
9406
|
+
function toExtractFields(fields) {
|
|
9407
|
+
return (0, _sentry_core.isObjectLike)(fields) ? mapObjectValues(fields, (field) => ({
|
|
9408
|
+
...field,
|
|
9409
|
+
instructions: field.instructions === null ? void 0 : (0, _sentry_core.stringify)(field.instructions)
|
|
9410
|
+
})) : fields;
|
|
9411
|
+
}
|
|
9412
|
+
/**
|
|
9413
|
+
* The AI SDK normalizes the provider's extraction answers. Map them back to the provider shape of
|
|
9414
|
+
* `gen_ai.output.messages` on `gen_ai.extract` spans. The AI SDK does not expose `truncated`.
|
|
9415
|
+
*/
|
|
9416
|
+
function toExtractAnswers(answers, parts) {
|
|
9417
|
+
return mapObjectValues(answers, ({ pNull, source, items, ...rest }) => {
|
|
9418
|
+
const mapped = {
|
|
9419
|
+
...rest,
|
|
9420
|
+
p_null: pNull
|
|
9421
|
+
};
|
|
9422
|
+
const span = toExtractSpan(source, parts);
|
|
9423
|
+
if (span) {
|
|
9424
|
+
mapped.source = "input";
|
|
9425
|
+
mapped.span = span;
|
|
9426
|
+
} else if ((0, _sentry_core.isObjectLike)(source) && parts[Number(source.part)] === "image") mapped.source = "image";
|
|
9427
|
+
if (Array.isArray(items)) {
|
|
9428
|
+
const confidences = items.map((item) => (0, _sentry_core.isObjectLike)(item) ? item.confidence : void 0);
|
|
9429
|
+
if (confidences.every((confidence) => typeof confidence === "number")) mapped.confidences = confidences;
|
|
9430
|
+
const spans = items.map((item) => toExtractSpan((0, _sentry_core.isObjectLike)(item) ? item.source : void 0, parts));
|
|
9431
|
+
if (spans.some(Boolean)) mapped.spans = spans;
|
|
9432
|
+
}
|
|
9433
|
+
return mapped;
|
|
9434
|
+
});
|
|
9435
|
+
}
|
|
9436
|
+
function toExtractSpan(source, parts) {
|
|
9437
|
+
if (!(0, _sentry_core.isObjectLike)(source) || source.type !== "text") return null;
|
|
9438
|
+
const offset = parts[Number(source.part)];
|
|
9439
|
+
return typeof offset === "number" ? [offset + Number(source.start), offset + Number(source.end)] : null;
|
|
9440
|
+
}
|
|
9335
9441
|
// src/integrations/vercel-ai/vercel-ai-dc-subscriber.ts
|
|
9336
9442
|
/**
|
|
9337
9443
|
* The single tracing channel the `ai` package (>= 7) publishes all telemetry lifecycle events to
|
|
@@ -9344,6 +9450,7 @@ const GEN_AI_OPERATION_SPAN_OPS = {
|
|
|
9344
9450
|
embeddings: _sentry_conventions_op.GEN_AI_EMBEDDINGS,
|
|
9345
9451
|
rerank: _sentry_conventions_op.GEN_AI_RERANK,
|
|
9346
9452
|
decide: _sentry_conventions_op.GEN_AI_DECIDE,
|
|
9453
|
+
extract: _sentry_conventions_op.GEN_AI_EXTRACT,
|
|
9347
9454
|
invoke_agent: _sentry_conventions_op.GEN_AI_INVOKE_AGENT,
|
|
9348
9455
|
execute_tool: _sentry_conventions_op.GEN_AI_EXECUTE_TOOL,
|
|
9349
9456
|
generate_content: _sentry_conventions_op.GEN_AI_GENERATE_CONTENT
|
|
@@ -9630,6 +9737,14 @@ function startSpanFromEvent(type, event, recordInputs) {
|
|
|
9630
9737
|
questions: event.questions
|
|
9631
9738
|
}]) } : {}
|
|
9632
9739
|
});
|
|
9740
|
+
case "experimental_extract": return startGenAiSpan("extract", modelId, {
|
|
9741
|
+
...baseAttributes,
|
|
9742
|
+
...recordInputs && !(isStrippedInput(event.state) && isStrippedInput(event.fields)) ? { [_sentry_conventions_attributes.GEN_AI_INPUT_MESSAGES]: (0, _sentry_core.stringify)([{
|
|
9743
|
+
...toExtractState(event.state).request,
|
|
9744
|
+
fields: toExtractFields(event.fields),
|
|
9745
|
+
reference_date: event.referenceDate
|
|
9746
|
+
}]) } : {}
|
|
9747
|
+
});
|
|
9633
9748
|
default: return;
|
|
9634
9749
|
}
|
|
9635
9750
|
}
|
|
@@ -9754,12 +9869,13 @@ function enrichSpanOnEnd(span, data) {
|
|
|
9754
9869
|
dropLastStepOnlyUsage(providerAttributes, type);
|
|
9755
9870
|
span.setAttributes(providerAttributes);
|
|
9756
9871
|
if (recordOutputs) {
|
|
9757
|
-
const outputMessages = getOutputMessages(type, result, finishReason);
|
|
9872
|
+
const outputMessages = getOutputMessages(type, result, finishReason, data.event);
|
|
9758
9873
|
if (outputMessages) span.setAttribute(_sentry_conventions_attributes.GEN_AI_OUTPUT_MESSAGES, outputMessages);
|
|
9759
9874
|
}
|
|
9760
9875
|
}
|
|
9761
|
-
function getOutputMessages(type, result, finishReason) {
|
|
9876
|
+
function getOutputMessages(type, result, finishReason, event) {
|
|
9762
9877
|
if (type === "experimental_evaluate" || type === "experimental_decide") return require_exports.getEvaluationOutputMessages(withProviderAnswerFields(result));
|
|
9878
|
+
if (type === "experimental_extract") return (0, _sentry_core.isObjectLike)(result.answers) ? (0, _sentry_core.stringify)([{ answers: toExtractAnswers(result.answers, toExtractState(event.state).parts) }]) : void 0;
|
|
9763
9879
|
return buildOutputMessages(type === "languageModelCall" && Array.isArray(result.content) ? partsFromContent(result.content) : partsFromTextAndToolCalls(result.text, result.toolCalls), finishReason);
|
|
9764
9880
|
}
|
|
9765
9881
|
/**
|
|
@@ -9773,17 +9889,16 @@ function withProviderAnswerFields(result) {
|
|
|
9773
9889
|
const { openrouter } = providerMetadata;
|
|
9774
9890
|
const openrouterById = (0, _sentry_core.isObjectLike)(openrouter) && (0, _sentry_core.isObjectLike)(openrouter.answers) ? openrouter.answers : void 0;
|
|
9775
9891
|
if (!confidenceById && !openrouterById) return answers;
|
|
9776
|
-
return
|
|
9777
|
-
if (!(0, _sentry_core.isObjectLike)(answer)) return [id, answer];
|
|
9892
|
+
return mapObjectValues(answers, (answer, id) => {
|
|
9778
9893
|
const openrouterAnswer = openrouterById?.[id];
|
|
9779
9894
|
const fields = (0, _sentry_core.isObjectLike)(openrouterAnswer) ? openrouterAnswer : {};
|
|
9780
9895
|
const { confidence = asNumber(confidenceById?.[id]) ?? asNumber(fields.confidence), legend = (0, _sentry_core.isObjectLike)(fields.legend) ? fields.legend : void 0 } = answer;
|
|
9781
|
-
return
|
|
9896
|
+
return {
|
|
9782
9897
|
...answer,
|
|
9783
9898
|
confidence,
|
|
9784
9899
|
legend
|
|
9785
|
-
}
|
|
9786
|
-
})
|
|
9900
|
+
};
|
|
9901
|
+
});
|
|
9787
9902
|
}
|
|
9788
9903
|
/** Maps a Vercel AI finish reason to the OTel `gen_ai.output.messages` form (`tool-calls` → `tool_call`). */
|
|
9789
9904
|
function normalizeFinishReason(finishReason) {
|
|
@@ -11446,8 +11561,6 @@ const attachHapiErrorHandler = attachHapiErrorHandler$1;
|
|
|
11446
11561
|
exports.BullMQTelemetry = BullMQTelemetry;
|
|
11447
11562
|
exports.SentryMastraExporter = require_exports.SentryMastraExporter;
|
|
11448
11563
|
exports._INTERNAL_cronExpressionToMonitorConfig = cronExpressionToMonitorConfig;
|
|
11449
|
-
exports._INTERNAL_instrumentTunnelServer = instrumentTunnelServer;
|
|
11450
|
-
exports._INTERNAL_instrumentTunnelServers = instrumentTunnelServers;
|
|
11451
11564
|
exports.amqplibIntegration = amqplibIntegration;
|
|
11452
11565
|
exports.anthropicAIIntegration = anthropicAIIntegration;
|
|
11453
11566
|
exports.applyHonoPatches = require_exports.applyHonoPatches;
|
|
@@ -11456,7 +11569,9 @@ exports.attachKoaErrorHandler = attachKoaErrorHandler;
|
|
|
11456
11569
|
exports.awsIntegration = awsIntegration;
|
|
11457
11570
|
exports.bindTracingChannelToSpan = bindTracingChannelToSpan;
|
|
11458
11571
|
exports.clickhouseIntegration = clickhouseIntegration;
|
|
11572
|
+
exports.collectInstalledModules = require_exports.collectInstalledModules;
|
|
11459
11573
|
exports.createFlueInstrumentation = require_exports.createFlueInstrumentation;
|
|
11574
|
+
exports.createGetModuleFromFilename = createGetModuleFromFilename;
|
|
11460
11575
|
exports.createHonoRequestMiddleware = require_exports.createHonoRequestMiddleware;
|
|
11461
11576
|
exports.createLangChainCallbackHandler = require_exports.createLangChainCallbackHandler;
|
|
11462
11577
|
exports.createSentryWinstonTransport = createSentryWinstonTransport;
|
|
@@ -11497,6 +11612,8 @@ exports.instrumentOpenAiClient = require_exports.instrumentOpenAiClient;
|
|
|
11497
11612
|
exports.instrumentPostgresJsSql = require_exports.instrumentPostgresJsSql;
|
|
11498
11613
|
exports.instrumentStateGraph = require_exports.instrumentStateGraph;
|
|
11499
11614
|
exports.instrumentStateGraphCompile = require_exports.instrumentStateGraphCompile;
|
|
11615
|
+
exports.instrumentTunnelServer = instrumentTunnelServer;
|
|
11616
|
+
exports.instrumentTunnelServers = instrumentTunnelServers;
|
|
11500
11617
|
exports.instrumentTypeSafeClient = require_exports.instrumentTypeSafeClient;
|
|
11501
11618
|
exports.instrumentWorkersAiClient = require_exports.instrumentWorkersAiClient;
|
|
11502
11619
|
exports.isBun = require_exports.isBun;
|