@neat.is/core 0.9.3 → 0.9.4
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/dist/{chunk-EDE4XP2M.js → chunk-IVVF37OU.js} +130 -27
- package/dist/chunk-IVVF37OU.js.map +1 -0
- package/dist/{chunk-2D4Y5QHE.js → chunk-TGCWMMF6.js} +2 -2
- package/dist/cli.cjs +135 -31
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/index.cjs +130 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/neatd.cjs +130 -26
- package/dist/neatd.cjs.map +1 -1
- package/dist/neatd.js +2 -2
- package/dist/server.cjs +127 -24
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-EDE4XP2M.js.map +0 -1
- /package/dist/{chunk-2D4Y5QHE.js.map → chunk-TGCWMMF6.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
resolveHost,
|
|
7
7
|
resolveNeatVersion,
|
|
8
8
|
writeDaemonRecord
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-TGCWMMF6.js";
|
|
10
10
|
import {
|
|
11
11
|
buildSearchIndex
|
|
12
12
|
} from "./chunk-BC53SCT7.js";
|
|
@@ -75,7 +75,7 @@ import {
|
|
|
75
75
|
startStalenessLoop,
|
|
76
76
|
upsertConnectorEntry,
|
|
77
77
|
validateConnectorEntry
|
|
78
|
-
} from "./chunk-
|
|
78
|
+
} from "./chunk-IVVF37OU.js";
|
|
79
79
|
import {
|
|
80
80
|
startOtelGrpcReceiver
|
|
81
81
|
} from "./chunk-ERE47MCR.js";
|
package/dist/index.cjs
CHANGED
|
@@ -5456,6 +5456,64 @@ function latencyPercentiles(hist) {
|
|
|
5456
5456
|
return { p50: round(quantile(hist, 0.5)), p95: round(quantile(hist, 0.95)) };
|
|
5457
5457
|
}
|
|
5458
5458
|
|
|
5459
|
+
// src/stacktrace.ts
|
|
5460
|
+
init_cjs_shims();
|
|
5461
|
+
var FRAME_SHAPES = [
|
|
5462
|
+
// `File "<path>", line <N>, in <func>` — the "most recent call last" shape.
|
|
5463
|
+
{ re: /File "([^"]+)", line (\d+)(?:, in (\S+))?/, file: 1, line: 2, fn: 3, deepest: "last" },
|
|
5464
|
+
// `at <func> (<path>:<line>:<col>)` — named call frame, most recent first.
|
|
5465
|
+
{ re: /\bat\s+(.+?)\s+\((.+?):(\d+):\d+\)/, file: 2, line: 3, fn: 1, deepest: "first" },
|
|
5466
|
+
// `at <path>:<line>:<col>` — anonymous call frame, most recent first.
|
|
5467
|
+
{ re: /\bat\s+(.+?):(\d+):\d+/, file: 1, line: 2, deepest: "first" },
|
|
5468
|
+
// `at <qualified.method>(<File.ext>:<line>)` — JVM-style, most recent first.
|
|
5469
|
+
{ re: /\bat\s+(.+?)\((\S+\.\w+):(\d+)\)/, file: 2, line: 3, fn: 1, deepest: "first" }
|
|
5470
|
+
];
|
|
5471
|
+
var VENDOR_MARKERS = [
|
|
5472
|
+
"node_modules",
|
|
5473
|
+
// dependency root
|
|
5474
|
+
"site-packages",
|
|
5475
|
+
// installed-package root
|
|
5476
|
+
"dist-packages",
|
|
5477
|
+
// distro-packaged root
|
|
5478
|
+
"node:"
|
|
5479
|
+
// runtime-internal module scheme (a stdlib/runtime-root frame)
|
|
5480
|
+
];
|
|
5481
|
+
function matchFrame(line) {
|
|
5482
|
+
for (const shape of FRAME_SHAPES) {
|
|
5483
|
+
const m = shape.re.exec(line);
|
|
5484
|
+
if (!m) continue;
|
|
5485
|
+
const file = m[shape.file];
|
|
5486
|
+
const lineNo = Number(m[shape.line]);
|
|
5487
|
+
if (!file || !Number.isFinite(lineNo)) continue;
|
|
5488
|
+
const fn = shape.fn !== void 0 ? m[shape.fn] : void 0;
|
|
5489
|
+
return { frame: { file, line: lineNo, ...fn ? { fn } : {} }, deepest: shape.deepest };
|
|
5490
|
+
}
|
|
5491
|
+
return null;
|
|
5492
|
+
}
|
|
5493
|
+
function isApplicationFrame(file) {
|
|
5494
|
+
if (file.startsWith("<")) return false;
|
|
5495
|
+
const norm = file.split("\\").join("/");
|
|
5496
|
+
for (const marker of VENDOR_MARKERS) {
|
|
5497
|
+
if (norm.includes(marker)) return false;
|
|
5498
|
+
}
|
|
5499
|
+
return true;
|
|
5500
|
+
}
|
|
5501
|
+
function deepestApplicationFrame(stacktrace) {
|
|
5502
|
+
if (!stacktrace) return null;
|
|
5503
|
+
const appFrames = [];
|
|
5504
|
+
for (const raw of stacktrace.split("\n")) {
|
|
5505
|
+
const matched = matchFrame(raw);
|
|
5506
|
+
if (!matched) continue;
|
|
5507
|
+
if (!isApplicationFrame(matched.frame.file)) continue;
|
|
5508
|
+
appFrames.push(matched);
|
|
5509
|
+
}
|
|
5510
|
+
if (appFrames.length === 0) return null;
|
|
5511
|
+
const orientation = appFrames.some((f) => f.deepest === "last") ? "last" : "first";
|
|
5512
|
+
const oriented = appFrames.filter((f) => f.deepest === orientation);
|
|
5513
|
+
const chosen = orientation === "last" ? oriented[oriented.length - 1] : oriented[0];
|
|
5514
|
+
return chosen ? chosen.frame : null;
|
|
5515
|
+
}
|
|
5516
|
+
|
|
5459
5517
|
// src/ingest.ts
|
|
5460
5518
|
var HOUR_MS = 60 * 60 * 1e3;
|
|
5461
5519
|
var DAY_MS = 24 * HOUR_MS;
|
|
@@ -6307,29 +6365,71 @@ async function appendConnectorIncident(errorsPath, input) {
|
|
|
6307
6365
|
await import_node_fs7.promises.mkdir(import_node_path8.default.dirname(errorsPath), { recursive: true });
|
|
6308
6366
|
await import_node_fs7.promises.appendFile(errorsPath, JSON.stringify(ev) + "\n", "utf8");
|
|
6309
6367
|
}
|
|
6310
|
-
function
|
|
6368
|
+
function landIncidentCallSite(span, callSite, trusted, graph) {
|
|
6369
|
+
const relPath = graph ? reconcileObservedRelPath(graph, span.service, callSite.relPath) : callSite.relPath;
|
|
6370
|
+
const canonicalService = serviceNodeName(graph, span) ?? span.service;
|
|
6371
|
+
const recovered = !trusted;
|
|
6372
|
+
if (graph) {
|
|
6373
|
+
const fusedFileId = (0, import_types8.fileId)(canonicalService, relPath);
|
|
6374
|
+
if (graph.hasNode(fusedFileId)) {
|
|
6375
|
+
const node = landObservedSymbol(
|
|
6376
|
+
graph,
|
|
6377
|
+
fusedFileId,
|
|
6378
|
+
canonicalService,
|
|
6379
|
+
relPath,
|
|
6380
|
+
{ ...callSite, relPath },
|
|
6381
|
+
false
|
|
6382
|
+
);
|
|
6383
|
+
return {
|
|
6384
|
+
affectedNode: node,
|
|
6385
|
+
...recovered ? {
|
|
6386
|
+
codeFilepath: relPath,
|
|
6387
|
+
...callSite.line !== void 0 ? { codeLineno: callSite.line } : {}
|
|
6388
|
+
} : {}
|
|
6389
|
+
};
|
|
6390
|
+
}
|
|
6391
|
+
if (recovered) return null;
|
|
6392
|
+
}
|
|
6393
|
+
return { affectedNode: (0, import_types8.fileId)(span.service, relPath) };
|
|
6394
|
+
}
|
|
6395
|
+
function serviceNodeName(graph, span) {
|
|
6396
|
+
if (!graph) return void 0;
|
|
6397
|
+
const sid = resolveFusedServiceId(graph, span.service, span.env);
|
|
6398
|
+
if (!graph.hasNode(sid)) return void 0;
|
|
6399
|
+
const node = graph.getNodeAttributes(sid);
|
|
6400
|
+
return typeof node.name === "string" ? node.name : void 0;
|
|
6401
|
+
}
|
|
6402
|
+
function stacktraceCallSite(span, serviceNode, scanPath) {
|
|
6403
|
+
const frame = deepestApplicationFrame(span.exception?.stacktrace);
|
|
6404
|
+
if (!frame) return null;
|
|
6405
|
+
const relPath = relPathForRuntimeFile(frame.file, serviceNode, scanPath);
|
|
6406
|
+
if (!relPath) return null;
|
|
6407
|
+
return { relPath, line: frame.line, ...frame.fn ? { fn: frame.fn } : {} };
|
|
6408
|
+
}
|
|
6409
|
+
function incidentLocus(span, graph, scanPath) {
|
|
6311
6410
|
const sid = graph ? resolveFusedServiceId(graph, span.service, span.env) : (0, import_types8.serviceId)(span.service, span.env);
|
|
6312
6411
|
const serviceNode = graph && graph.hasNode(sid) ? graph.getNodeAttributes(sid) : void 0;
|
|
6313
6412
|
const callSite = callSiteFromSpan(span, serviceNode, scanPath);
|
|
6314
6413
|
if (callSite) {
|
|
6315
|
-
const
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
fusedFileId,
|
|
6323
|
-
canonicalService,
|
|
6324
|
-
relPath,
|
|
6325
|
-
{ ...callSite, relPath },
|
|
6326
|
-
false
|
|
6327
|
-
);
|
|
6328
|
-
}
|
|
6414
|
+
const landed = landIncidentCallSite(span, callSite, true, graph);
|
|
6415
|
+
if (landed) return landed;
|
|
6416
|
+
} else {
|
|
6417
|
+
const recovered = stacktraceCallSite(span, serviceNode, scanPath);
|
|
6418
|
+
if (recovered) {
|
|
6419
|
+
const landed = landIncidentCallSite(span, recovered, false, graph);
|
|
6420
|
+
if (landed) return landed;
|
|
6329
6421
|
}
|
|
6330
|
-
return (0, import_types8.fileId)(span.service, relPath);
|
|
6331
6422
|
}
|
|
6332
|
-
return sid;
|
|
6423
|
+
return { affectedNode: sid };
|
|
6424
|
+
}
|
|
6425
|
+
function incidentAffectedNode(span, graph, scanPath) {
|
|
6426
|
+
return incidentLocus(span, graph, scanPath).affectedNode;
|
|
6427
|
+
}
|
|
6428
|
+
function withRecoveredCodeAttrs(attrs, locus) {
|
|
6429
|
+
if (locus.codeFilepath === void 0) return attrs;
|
|
6430
|
+
attrs[CODE_FILEPATH_ATTR] = locus.codeFilepath;
|
|
6431
|
+
if (locus.codeLineno !== void 0) attrs[CODE_LINENO_ATTR] = locus.codeLineno;
|
|
6432
|
+
return attrs;
|
|
6333
6433
|
}
|
|
6334
6434
|
function sanitizeAttributes(attrs) {
|
|
6335
6435
|
const out = {};
|
|
@@ -6342,7 +6442,8 @@ function sanitizeAttributes(attrs) {
|
|
|
6342
6442
|
function buildErrorEventForReceiver(span, graph, scanPath) {
|
|
6343
6443
|
if (span.statusCode !== 2) return null;
|
|
6344
6444
|
const ts = span.startTimeIso ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
6345
|
-
const
|
|
6445
|
+
const locus = incidentLocus(span, graph, scanPath);
|
|
6446
|
+
const attrs = withRecoveredCodeAttrs(sanitizeAttributes(span.attributes), locus);
|
|
6346
6447
|
return {
|
|
6347
6448
|
id: `${span.traceId}:${span.spanId}`,
|
|
6348
6449
|
timestamp: ts,
|
|
@@ -6353,7 +6454,7 @@ function buildErrorEventForReceiver(span, graph, scanPath) {
|
|
|
6353
6454
|
...span.exception?.type ? { exceptionType: span.exception.type } : {},
|
|
6354
6455
|
...span.exception?.stacktrace ? { exceptionStacktrace: span.exception.stacktrace } : {},
|
|
6355
6456
|
...Object.keys(attrs).length > 0 ? { attributes: attrs } : {},
|
|
6356
|
-
affectedNode:
|
|
6457
|
+
affectedNode: locus.affectedNode
|
|
6357
6458
|
};
|
|
6358
6459
|
}
|
|
6359
6460
|
function makeErrorSpanWriter(errorsPath, graph, scanPath) {
|
|
@@ -6387,7 +6488,8 @@ async function recordFailingResponseIncident(ctx, span, affectedNode, timestamp,
|
|
|
6387
6488
|
await appendErrorEvent(ctx, ev);
|
|
6388
6489
|
}
|
|
6389
6490
|
async function recordExceptionIncident(ctx, span, ts) {
|
|
6390
|
-
const
|
|
6491
|
+
const locus = incidentLocus(span, ctx.graph, ctx.scanPath);
|
|
6492
|
+
const attrs = withRecoveredCodeAttrs(sanitizeAttributes(span.attributes), locus);
|
|
6391
6493
|
const ev = {
|
|
6392
6494
|
id: `${span.traceId}:${span.spanId}`,
|
|
6393
6495
|
timestamp: ts,
|
|
@@ -6398,7 +6500,7 @@ async function recordExceptionIncident(ctx, span, ts) {
|
|
|
6398
6500
|
...span.exception?.type ? { exceptionType: span.exception.type } : {},
|
|
6399
6501
|
...span.exception?.stacktrace ? { exceptionStacktrace: span.exception.stacktrace } : {},
|
|
6400
6502
|
...Object.keys(attrs).length > 0 ? { attributes: attrs } : {},
|
|
6401
|
-
affectedNode:
|
|
6503
|
+
affectedNode: locus.affectedNode
|
|
6402
6504
|
};
|
|
6403
6505
|
await appendErrorEvent(ctx, ev);
|
|
6404
6506
|
}
|
|
@@ -6701,7 +6803,8 @@ async function handleSpan(ctx, span) {
|
|
|
6701
6803
|
if (span.statusCode === 2) {
|
|
6702
6804
|
stitchTrace(ctx.graph, sourceId, ts);
|
|
6703
6805
|
if (ctx.writeErrorEventInline !== false) {
|
|
6704
|
-
const
|
|
6806
|
+
const locus = incidentLocus(span, ctx.graph, ctx.scanPath);
|
|
6807
|
+
const attrs = withRecoveredCodeAttrs(sanitizeAttributes(span.attributes), locus);
|
|
6705
6808
|
const ev = {
|
|
6706
6809
|
id: `${span.traceId}:${span.spanId}`,
|
|
6707
6810
|
timestamp: ts,
|
|
@@ -6713,10 +6816,11 @@ async function handleSpan(ctx, span) {
|
|
|
6713
6816
|
...span.exception?.stacktrace ? { exceptionStacktrace: span.exception.stacktrace } : {},
|
|
6714
6817
|
...Object.keys(attrs).length > 0 ? { attributes: attrs } : {},
|
|
6715
6818
|
// Attribute to where the failure originated — the symbol / file / service
|
|
6716
|
-
// the throwing span named (incidentAffectedNode
|
|
6717
|
-
//
|
|
6718
|
-
//
|
|
6719
|
-
|
|
6819
|
+
// the throwing span named (incidentAffectedNode / ADR-191, extended to
|
|
6820
|
+
// recover the locus from the stacktrace when the span stamped no code.*
|
|
6821
|
+
// attrs, ADR-216) — the same source-based attribution the durable
|
|
6822
|
+
// receiver write uses, not the outbound edge target this span minted.
|
|
6823
|
+
affectedNode: locus.affectedNode
|
|
6720
6824
|
};
|
|
6721
6825
|
await appendErrorEvent(ctx, ev);
|
|
6722
6826
|
}
|