@neat.is/core 0.4.22 → 0.4.23

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/neatd.js CHANGED
@@ -2,11 +2,11 @@
2
2
  import {
3
3
  reconcileDaemonRecordSync,
4
4
  startDaemon
5
- } from "./chunk-XRE4OQWJ.js";
5
+ } from "./chunk-IABNGQT2.js";
6
6
  import {
7
7
  listProjects,
8
8
  registryPath
9
- } from "./chunk-OQ7CHOY2.js";
9
+ } from "./chunk-O25KZNZK.js";
10
10
  import {
11
11
  BindAuthorityError,
12
12
  __require
package/dist/server.cjs CHANGED
@@ -3028,6 +3028,16 @@ async function appendErrorEvent(ctx, ev) {
3028
3028
  await import_node_fs5.promises.mkdir(import_node_path5.default.dirname(ctx.errorsPath), { recursive: true });
3029
3029
  await import_node_fs5.promises.appendFile(ctx.errorsPath, JSON.stringify(ev) + "\n", "utf8");
3030
3030
  }
3031
+ function incidentAffectedNode(span, graph, scanPath) {
3032
+ const sid = (0, import_types4.serviceId)(span.service, span.env);
3033
+ const serviceNode = graph && graph.hasNode(sid) ? graph.getNodeAttributes(sid) : void 0;
3034
+ const callSite = callSiteFromSpan(span, serviceNode, scanPath);
3035
+ if (callSite) {
3036
+ const relPath = graph ? reconcileObservedRelPath(graph, span.service, callSite.relPath) : callSite.relPath;
3037
+ return (0, import_types4.fileId)(span.service, relPath);
3038
+ }
3039
+ return sid;
3040
+ }
3031
3041
  function sanitizeAttributes(attrs) {
3032
3042
  const out = {};
3033
3043
  for (const [k, v] of Object.entries(attrs)) {
@@ -3058,6 +3068,22 @@ async function recordFailingResponseIncident(ctx, span, affectedNode, timestamp,
3058
3068
  };
3059
3069
  await appendErrorEvent(ctx, ev);
3060
3070
  }
3071
+ async function recordExceptionIncident(ctx, span, ts) {
3072
+ const attrs = sanitizeAttributes(span.attributes);
3073
+ const ev = {
3074
+ id: `${span.traceId}:${span.spanId}`,
3075
+ timestamp: ts,
3076
+ service: span.service,
3077
+ traceId: span.traceId,
3078
+ spanId: span.spanId,
3079
+ errorMessage: incidentMessage(span),
3080
+ ...span.exception?.type ? { exceptionType: span.exception.type } : {},
3081
+ ...span.exception?.stacktrace ? { exceptionStacktrace: span.exception.stacktrace } : {},
3082
+ ...Object.keys(attrs).length > 0 ? { attributes: attrs } : {},
3083
+ affectedNode: incidentAffectedNode(span, ctx.graph, ctx.scanPath)
3084
+ };
3085
+ await appendErrorEvent(ctx, ev);
3086
+ }
3061
3087
  async function advance4xxBurst(ctx, span, affectedNode, ts, nowMs, status2) {
3062
3088
  const { threshold, windowMs } = loadIncidentThresholdsFromEnv();
3063
3089
  if (!ctx.burstState) ctx.burstState = /* @__PURE__ */ new Map();
@@ -3214,7 +3240,9 @@ async function handleSpan(ctx, span) {
3214
3240
  }
3215
3241
  if (span.statusCode !== 2) {
3216
3242
  const status2 = httpResponseStatus(span);
3217
- if (status2 !== void 0 && status2 >= 500) {
3243
+ if (span.exception) {
3244
+ await recordExceptionIncident(ctx, span, ts);
3245
+ } else if (status2 !== void 0 && status2 >= 500) {
3218
3246
  await recordFailingResponseIncident(ctx, span, sourceId, ts, status2, 1);
3219
3247
  } else if (status2 !== void 0 && status2 >= 400 && spanMintsObservedEdge(span.kind)) {
3220
3248
  await advance4xxBurst(ctx, span, sourceId, ts, nowMs, status2);