@sentry/server-utils 11.17.0 → 11.19.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/flue/types.d.ts +4 -8
- package/build/types/ai/flue/types.d.ts.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
|
@@ -3448,11 +3448,7 @@ function extractLlmResponseAttributes(llmResult, recordOutputs) {
|
|
|
3448
3448
|
if (!llmResult) return;
|
|
3449
3449
|
const attrs = {};
|
|
3450
3450
|
if (Array.isArray(llmResult.generations)) {
|
|
3451
|
-
const finishReasons = llmResult.generations.flat().map((g) =>
|
|
3452
|
-
if (g.generationInfo?.finish_reason) return g.generationInfo.finish_reason;
|
|
3453
|
-
if (g.generation_info?.finish_reason) return g.generation_info.finish_reason;
|
|
3454
|
-
return null;
|
|
3455
|
-
}).filter((r) => typeof r === "string");
|
|
3451
|
+
const finishReasons = llmResult.generations.flat().map((g) => g.generationInfo?.finish_reason || g.generation_info?.finish_reason || g.message?.response_metadata?.finish_reason).filter((r) => typeof r === "string");
|
|
3456
3452
|
if (finishReasons.length > 0) setIfDefined(attrs, _sentry_conventions_attributes.GEN_AI_RESPONSE_FINISH_REASONS, (0, _sentry_core.stringify)(finishReasons, String));
|
|
3457
3453
|
addToolCallsAttributes(llmResult.generations, attrs);
|
|
3458
3454
|
if (recordOutputs) {
|
|
@@ -5539,8 +5535,9 @@ function extractTableNames(sql) {
|
|
|
5539
5535
|
TOKEN_RE.lastIndex = 0;
|
|
5540
5536
|
let match;
|
|
5541
5537
|
while ((match = TOKEN_RE.exec(sql)) !== null) {
|
|
5542
|
-
|
|
5543
|
-
|
|
5538
|
+
const table = match[1] || match[2];
|
|
5539
|
+
if (table) {
|
|
5540
|
+
tables.push(table);
|
|
5544
5541
|
continue;
|
|
5545
5542
|
}
|
|
5546
5543
|
const rest = sql.slice(match.index + match[0].length);
|
|
@@ -5647,7 +5644,7 @@ function stripLiteralsAndComments(sql, dialect) {
|
|
|
5647
5644
|
const out = [];
|
|
5648
5645
|
let i = 0;
|
|
5649
5646
|
while (i < sql.length) {
|
|
5650
|
-
const char = sql
|
|
5647
|
+
const char = sql.charAt(i);
|
|
5651
5648
|
const next = sql[i + 1];
|
|
5652
5649
|
if (char === "-" && next === "-" || (isMysql || rules.hashComments) && char === "#") {
|
|
5653
5650
|
const lineEnd = sql.indexOf("\n", i);
|
|
@@ -5776,6 +5773,90 @@ function getSqlSpanName(attributes, fallback) {
|
|
|
5776
5773
|
function toSpanName(value, fallback) {
|
|
5777
5774
|
return typeof value === "string" && value ? value : fallback;
|
|
5778
5775
|
}
|
|
5776
|
+
// src/utils/installedModules.ts
|
|
5777
|
+
const NODE_MODULES = "/node_modules/";
|
|
5778
|
+
/**
|
|
5779
|
+
* Returns the app's packages: the dependencies declared in its `package.json`, plus loaded packages. Each gets the exact
|
|
5780
|
+
* version that a bare import from the app resolves through `node_modules`, or its declared range otherwise.
|
|
5781
|
+
*/
|
|
5782
|
+
function collectInstalledModules({ readFile, entryPath, cwd, loadedFiles = [] }) {
|
|
5783
|
+
const read = (dir) => {
|
|
5784
|
+
try {
|
|
5785
|
+
return JSON.parse(readFile(join(dir, "package.json")) || "null") || void 0;
|
|
5786
|
+
} catch {
|
|
5787
|
+
return;
|
|
5788
|
+
}
|
|
5789
|
+
};
|
|
5790
|
+
const entryDir = entryPath && dirname(toPosix(entryPath));
|
|
5791
|
+
const cwdDir = cwd && toPosix(cwd);
|
|
5792
|
+
const appRoot = findAppRoot(read, entryDir && cwdDir && !isIn(entryDir, cwdDir) ? [cwdDir, entryDir] : [entryDir, cwdDir]);
|
|
5793
|
+
const resolveFrom = entryDir && appRoot && isIn(entryDir, appRoot) && !inNodeModules(entryDir) ? entryDir : appRoot || entryDir || cwdDir;
|
|
5794
|
+
const nodeModulesDirs = resolveFrom ? ancestors(resolveFrom).map((dir) => join(dir, "node_modules")) : [];
|
|
5795
|
+
const resolve = (name) => {
|
|
5796
|
+
for (const dir of nodeModulesDirs) {
|
|
5797
|
+
const version = read(join(dir, name))?.version;
|
|
5798
|
+
if (version) return version;
|
|
5799
|
+
}
|
|
5800
|
+
};
|
|
5801
|
+
const pkg = appRoot ? read(appRoot) : void 0;
|
|
5802
|
+
const declared = {
|
|
5803
|
+
...pkg?.dependencies,
|
|
5804
|
+
...pkg?.devDependencies
|
|
5805
|
+
};
|
|
5806
|
+
const installed = {};
|
|
5807
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5808
|
+
for (const file of loadedFiles) {
|
|
5809
|
+
const path = toPosix(file);
|
|
5810
|
+
const start = path.lastIndexOf(NODE_MODULES) + 14;
|
|
5811
|
+
const [first = "", second] = path.slice(start).split("/");
|
|
5812
|
+
const name = first.startsWith("@") ? `${first}/${second}` : first;
|
|
5813
|
+
const dir = path.slice(0, start) + name;
|
|
5814
|
+
if (start < 14 || seen.has(dir) || !nodeModulesDirs.some((d) => isIn(path, d))) continue;
|
|
5815
|
+
seen.add(dir);
|
|
5816
|
+
const version = read(dir)?.version;
|
|
5817
|
+
if (version && installed[name] !== version) installed[name] = name in installed && resolve(name) || installed[name] || version;
|
|
5818
|
+
}
|
|
5819
|
+
for (const name of Object.keys(declared)) {
|
|
5820
|
+
const version = resolve(name);
|
|
5821
|
+
if (version) installed[name] = version;
|
|
5822
|
+
}
|
|
5823
|
+
return {
|
|
5824
|
+
...declared,
|
|
5825
|
+
...installed
|
|
5826
|
+
};
|
|
5827
|
+
}
|
|
5828
|
+
/** Skips start dirs inside `node_modules` and `package.json` files that only set fields like `"type"`. */
|
|
5829
|
+
function findAppRoot(read, startDirs) {
|
|
5830
|
+
for (const startDir of startDirs) {
|
|
5831
|
+
const root = startDir && !inNodeModules(startDir) ? ancestors(startDir).find((dir) => {
|
|
5832
|
+
const pkg = read(dir);
|
|
5833
|
+
return pkg && (pkg.name || pkg.dependencies || pkg.devDependencies);
|
|
5834
|
+
}) : void 0;
|
|
5835
|
+
if (root) return root;
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
function inNodeModules(dir) {
|
|
5839
|
+
return `${dir}/`.includes(NODE_MODULES);
|
|
5840
|
+
}
|
|
5841
|
+
/** `dir` and its parents, up to the root. */
|
|
5842
|
+
function ancestors(dir) {
|
|
5843
|
+
const dirs = [dir];
|
|
5844
|
+
for (let parent = dirname(dir); parent !== dirs[dirs.length - 1]; parent = dirname(parent)) dirs.push(parent);
|
|
5845
|
+
return dirs;
|
|
5846
|
+
}
|
|
5847
|
+
function dirname(path) {
|
|
5848
|
+
const index = path.lastIndexOf("/");
|
|
5849
|
+
return index > 0 ? path.slice(0, index) : index === 0 ? "/" : path;
|
|
5850
|
+
}
|
|
5851
|
+
function join(dir, name) {
|
|
5852
|
+
return dir.endsWith("/") ? dir + name : `${dir}/${name}`;
|
|
5853
|
+
}
|
|
5854
|
+
function isIn(path, dir) {
|
|
5855
|
+
return path === dir || path.startsWith(dir.endsWith("/") ? dir : `${dir}/`);
|
|
5856
|
+
}
|
|
5857
|
+
function toPosix(path) {
|
|
5858
|
+
return path.replace(/\\/g, "/");
|
|
5859
|
+
}
|
|
5779
5860
|
// src/integrations/postgresjs-wrapper.ts
|
|
5780
5861
|
const CONNECTION_CONTEXT_SYMBOL = Symbol("sentryPostgresConnectionContext");
|
|
5781
5862
|
const INSTRUMENTED_MARKER = Symbol.for("sentry.instrumented.postgresjs");
|
|
@@ -6356,12 +6437,13 @@ function installRouteHookOnPrototype(honoBaseProto) {
|
|
|
6356
6437
|
require_debug_build.DEBUG_BUILD && _sentry_core.debug.log("[hono] Installed route hook on HonoBase.prototype.");
|
|
6357
6438
|
return handle;
|
|
6358
6439
|
}
|
|
6440
|
+
const ERROR_AND_NOT_FOUND_METHODS = /* @__PURE__ */ new Set(["@ERROR", "@NOT_FOUND"]);
|
|
6359
6441
|
/**
|
|
6360
6442
|
* Wraps the middleware handlers of a sub-app's routes in spans.
|
|
6361
6443
|
*/
|
|
6362
6444
|
function wrapSubAppMiddleware(routes) {
|
|
6363
6445
|
const middlewareFlags = getMiddlewareFlags(routes);
|
|
6364
|
-
for (const [i, route] of routes.entries()) if (middlewareFlags[i] && typeof route.handler === "function") route.handler = wrapMiddlewareWithSpan(route.handler);
|
|
6446
|
+
for (const [i, route] of routes.entries()) if (middlewareFlags[i] && !ERROR_AND_NOT_FOUND_METHODS.has(route.method) && typeof route.handler === "function") route.handler = wrapMiddlewareWithSpan(route.handler);
|
|
6365
6447
|
}
|
|
6366
6448
|
// src/integrations/hono/applyPatches.ts
|
|
6367
6449
|
let _routeHook;
|
|
@@ -6548,6 +6630,22 @@ function resolveRouteName(context, routes, middlewareFlags) {
|
|
|
6548
6630
|
function isSentryMiddleware(handler) {
|
|
6549
6631
|
return typeof handler === "function" && Boolean(Reflect.get(handler, "__SENTRY_HONO_MIDDLEWARE__"));
|
|
6550
6632
|
}
|
|
6633
|
+
// src/integrations/hono/unwrapThrownValue.ts
|
|
6634
|
+
/**
|
|
6635
|
+
* Returns the value that a handler threw, so that `shouldHandleError` and the event get that value
|
|
6636
|
+
* and not Hono's wrapper.
|
|
6637
|
+
*
|
|
6638
|
+
* Hono 5 wraps a thrown non-Error before its error handlers run:
|
|
6639
|
+
* `new Error(typeof err === 'string' ? err : undefined, { cause: err })`.
|
|
6640
|
+
* The wrapper has no marker, so it is found by its shape. A user error with the same shape is also unwrapped.
|
|
6641
|
+
*/
|
|
6642
|
+
function unwrapThrownValue(error) {
|
|
6643
|
+
if (!(0, _sentry_core.isError)(error) || error.constructor !== Error || !("cause" in error)) return error;
|
|
6644
|
+
const { cause } = error;
|
|
6645
|
+
if ((0, _sentry_core.isError)(cause)) return error;
|
|
6646
|
+
const wrapperMessage = typeof cause === "string" ? cause : "";
|
|
6647
|
+
return error.message === wrapperMessage ? cause : error;
|
|
6648
|
+
}
|
|
6551
6649
|
// src/integrations/hono/middlewareHandlers.ts
|
|
6552
6650
|
/**
|
|
6553
6651
|
* Request handler for Hono framework
|
|
@@ -6621,7 +6719,8 @@ function responseHandler(context, shouldHandleError) {
|
|
|
6621
6719
|
*/
|
|
6622
6720
|
function captureContextError(context, shouldHandleError) {
|
|
6623
6721
|
if (context.error) {
|
|
6624
|
-
|
|
6722
|
+
const error = unwrapThrownValue(context.error);
|
|
6723
|
+
if ((shouldHandleError ?? defaultShouldHandleError)(error)) (0, _sentry_core.captureException)(error, { mechanism: {
|
|
6625
6724
|
handled: false,
|
|
6626
6725
|
type: "auto.http.hono.context_error"
|
|
6627
6726
|
} });
|
|
@@ -6923,6 +7022,12 @@ Object.defineProperty(exports, "applyPatches", {
|
|
|
6923
7022
|
return applyPatches;
|
|
6924
7023
|
}
|
|
6925
7024
|
});
|
|
7025
|
+
Object.defineProperty(exports, "collectInstalledModules", {
|
|
7026
|
+
enumerable: true,
|
|
7027
|
+
get: function() {
|
|
7028
|
+
return collectInstalledModules;
|
|
7029
|
+
}
|
|
7030
|
+
});
|
|
6926
7031
|
Object.defineProperty(exports, "createFlueInstrumentation", {
|
|
6927
7032
|
enumerable: true,
|
|
6928
7033
|
get: function() {
|