@obsunified/collector 2.2.3 → 2.4.3

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.
Files changed (58) hide show
  1. package/dist/auth.d.ts +2 -1
  2. package/dist/{chunk-ZSF5XP3B.js → chunk-RASSTGNB.js} +30 -22
  3. package/dist/chunk-RASSTGNB.js.map +1 -0
  4. package/dist/index.d.ts +264 -62
  5. package/dist/index.js +3390 -2350
  6. package/dist/index.js.map +1 -1
  7. package/dist/{ingest-auth-C5-8Mly5.d.ts → ingest-auth-BTowieER.d.ts} +96 -1
  8. package/dist/{openai-GSJZGFGL.js → openai-VDKVVZAV.js} +2 -2
  9. package/package.json +4 -2
  10. package/src/__tests__/autosre-closed-loop.test.ts +110 -0
  11. package/src/__tests__/db-parity.integration.test.ts +961 -0
  12. package/src/__tests__/internal-contracts-routes.test.ts +451 -0
  13. package/src/framework/env.ts +113 -0
  14. package/src/index.ts +27 -4
  15. package/src/lib/ai-store/evaluations.test.ts +3 -3
  16. package/src/lib/alert-email.ts +104 -0
  17. package/src/lib/alerts-store.test.ts +116 -2
  18. package/src/lib/alerts-store.ts +421 -57
  19. package/src/lib/analyses-store.test.ts +6 -6
  20. package/src/lib/db-parity.ts +883 -0
  21. package/src/lib/eval-cases-store.test.ts +1 -1
  22. package/src/lib/eval-cases-store.ts +16 -4
  23. package/src/lib/evidence-references.ts +30 -22
  24. package/src/lib/metric-alerts.test.ts +769 -0
  25. package/src/lib/metric-alerts.ts +640 -0
  26. package/src/lib/metrics-store.ts +9 -2
  27. package/src/lib/sql-db-postgres.integration.test.ts +247 -0
  28. package/src/lib/stage6.test.ts +1 -1
  29. package/src/lib/store/trace-queries.ts +1 -1
  30. package/src/migrations/054_alert_rules_pending_secs.sql +11 -0
  31. package/src/migrations/055_alert_state_pending_since.sql +12 -0
  32. package/src/migrations/056_metric_point_series_received.sql +9 -0
  33. package/src/migrations/057_alert_evaluations_outcome.sql +11 -0
  34. package/src/migrations/058_alert_state_pending_seen_at.sql +12 -0
  35. package/src/migrations/059_alert_evaluations_error.sql +11 -0
  36. package/src/migrations/parity.test.ts +105 -3
  37. package/src/migrations-postgres/054_alert_rules_pending_secs.sql +7 -0
  38. package/src/migrations-postgres/055_alert_state_pending_since.sql +6 -0
  39. package/src/migrations-postgres/056_metric_point_series_received.sql +7 -0
  40. package/src/migrations-postgres/057_alert_evaluations_outcome.sql +6 -0
  41. package/src/migrations-postgres/058_alert_state_pending_seen_at.sql +6 -0
  42. package/src/migrations-postgres/059_alert_evaluations_error.sql +6 -0
  43. package/src/migrations-postgres/README.md +13 -0
  44. package/src/plugins/ai-receiver.ts +6 -1
  45. package/src/plugins/alerts-evaluator-pending.test.ts +322 -0
  46. package/src/plugins/alerts-evaluator-retention.test.ts +2 -0
  47. package/src/plugins/alerts-evaluator.test.ts +10 -2
  48. package/src/plugins/alerts-evaluator.ts +239 -40
  49. package/src/plugins/alerts-routes.ts +17 -2
  50. package/src/plugins/autosre-routes.ts +251 -140
  51. package/src/plugins/connected-routes/manifest.test.ts +114 -32
  52. package/src/plugins/connected-routes/manifest.ts +59 -76
  53. package/src/plugins/connected-routes.test.ts +10 -8
  54. package/src/plugins/connected-routes.ts +42 -12
  55. package/src/plugins/eval-cases-routes.ts +33 -10
  56. package/src/plugins/evidence-retrieval-routes.ts +60 -25
  57. package/dist/chunk-ZSF5XP3B.js.map +0 -1
  58. /package/dist/{openai-GSJZGFGL.js.map → openai-VDKVVZAV.js.map} +0 -0
@@ -91,7 +91,7 @@ describe("EvalCasesStore", () => {
91
91
  expect.objectContaining({
92
92
  entityKind: "span",
93
93
  entityId: "trace-1:span-1",
94
- route: "#/traces/trace-1#span=span-1",
94
+ route: "#/traces?trace=trace-1&span=span-1",
95
95
  }),
96
96
  ]),
97
97
  );
@@ -3,7 +3,10 @@ import type {
3
3
  EvidenceReferenceContract as EvidenceReferenceContractType,
4
4
  JsonValue,
5
5
  } from "@obsunified/types";
6
- import { EVIDENCE_REFERENCE_CONTRACT } from "@obsunified/types";
6
+ import {
7
+ dashboardRouteToHref,
8
+ EVIDENCE_REFERENCE_CONTRACT,
9
+ } from "@obsunified/types";
7
10
  import { sourceLinkEvidenceReferences } from "./evidence-references";
8
11
  import { randomHex } from "./hash";
9
12
  import { parseJsonArray, parseJsonValue } from "./json";
@@ -345,7 +348,10 @@ const evalCaseEvidenceReferences = (evalCase: EvalCase): EvidenceReference[] =>
345
348
  sourceLabel: `Eval case "${evalCase.name}"`,
346
349
  sourceId: evalCase.id,
347
350
  sourceKind: "eval_case",
348
- sourceRoute: `#/evaluations?case=${encodeURIComponent(evalCase.id)}`,
351
+ sourceRoute: dashboardRouteToHref({
352
+ tab: "evaluations",
353
+ evaluationId: evalCase.id,
354
+ }),
349
355
  sourceName: evalCase.name,
350
356
  },
351
357
  evalCase,
@@ -384,7 +390,10 @@ const evalRunEvidenceReferences = (run: EvalRun): EvidenceReference[] => {
384
390
  sourceLabel: `Eval run "${run.id}"`,
385
391
  sourceId: run.id,
386
392
  sourceKind: "eval_run",
387
- sourceRoute: `#/evaluations?run=${encodeURIComponent(run.id)}`,
393
+ sourceRoute: dashboardRouteToHref({
394
+ tab: "evaluations",
395
+ evaluationId: run.evalCaseId ?? run.id,
396
+ }),
388
397
  sourceName: run.sourceEvalCase.name,
389
398
  },
390
399
  run.sourceEvalCase,
@@ -413,7 +422,10 @@ const rowToEvalRun = (row: EvalRunRow): EvalRun => {
413
422
  sourceLabel: `Eval case "${sourceEvalCase.name}"`,
414
423
  sourceId: sourceEvalCase.id,
415
424
  sourceKind: "eval_case",
416
- sourceRoute: `#/evaluations?case=${encodeURIComponent(sourceEvalCase.id)}`,
425
+ sourceRoute: dashboardRouteToHref({
426
+ tab: "evaluations",
427
+ evaluationId: sourceEvalCase.id,
428
+ }),
417
429
  sourceName: sourceEvalCase.name,
418
430
  },
419
431
  sourceEvalCase,
@@ -10,9 +10,10 @@ import type {
10
10
  EvidenceReference,
11
11
  JsonValue,
12
12
  } from "@obsunified/types";
13
+ import { dashboardRouteToHref, hrefForEntity } from "@obsunified/types";
13
14
 
14
15
  const analysisRoute = (analysisId: string) =>
15
- `#/investigate/${encodeURIComponent(analysisId)}`;
16
+ dashboardRouteToHref({ tab: "investigate", investigationId: analysisId });
16
17
 
17
18
  export const analysisEvidenceReference = (
18
19
  evidence: AskEvidence,
@@ -103,10 +104,10 @@ const valueFor = (
103
104
  };
104
105
 
105
106
  const traceRoute = (traceId: string) =>
106
- `#/traces/${encodeURIComponent(traceId)}`;
107
+ dashboardRouteToHref({ tab: "traces", traceId });
107
108
 
108
109
  const spanRoute = (traceId: string, spanId: string) =>
109
- `${traceRoute(traceId)}#span=${encodeURIComponent(spanId)}`;
110
+ dashboardRouteToHref({ tab: "traces", traceId, spanId });
110
111
 
111
112
  export const evidenceRouteFor = (
112
113
  entityKind: EvidenceEntityKind,
@@ -117,41 +118,48 @@ export const evidenceRouteFor = (
117
118
  case "analysis":
118
119
  return analysisRoute(entityId);
119
120
  case "action":
120
- return `#/actions/${encodeURIComponent(entityId)}`;
121
+ return dashboardRouteToHref({ tab: "actions", actionId: entityId });
121
122
  case "alert":
122
- return `#/alerts?alert=${encodeURIComponent(entityId)}`;
123
+ return dashboardRouteToHref({ tab: "alerts", alertId: entityId });
123
124
  case "agent_run":
124
- return `#/agent-runs/${encodeURIComponent(entityId)}`;
125
+ return dashboardRouteToHref({ tab: "agent-runs", agentRunId: entityId });
125
126
  case "ai_call":
126
- return `#/ai/calls/${encodeURIComponent(entityId)}`;
127
+ return dashboardRouteToHref({ tab: "ai", aiCallId: entityId });
127
128
  case "eval":
128
- return `#/evals/${encodeURIComponent(entityId)}`;
129
+ return dashboardRouteToHref({
130
+ tab: "evaluations",
131
+ evaluationId: entityId,
132
+ });
129
133
  case "log":
130
- return `#/logs?id=${encodeURIComponent(entityId)}`;
134
+ return dashboardRouteToHref({ tab: "logs", logId: entityId });
131
135
  case "profile":
132
- return traceId
133
- ? `#/profiles/${encodeURIComponent(entityId)}?trace_id=${encodeURIComponent(traceId)}`
134
- : `#/profiles/${encodeURIComponent(entityId)}`;
136
+ return dashboardRouteToHref({
137
+ tab: "profiles",
138
+ profileId: entityId,
139
+ ...(traceId ? { traceId } : {}),
140
+ });
135
141
  case "replay":
136
- return `#/replay?session=${encodeURIComponent(entityId)}`;
142
+ return dashboardRouteToHref({ tab: "replay", sessionId: entityId });
137
143
  case "service":
138
- return `#/traces?service=${encodeURIComponent(entityId)}`;
144
+ return dashboardRouteToHref({ tab: "service-map", service: entityId });
139
145
  case "span": {
140
146
  const [tracePart, spanPart] = entityId.split(":");
141
- return spanPart ? spanRoute(tracePart, spanPart) : `#/spans/${entityId}`;
147
+ return spanPart
148
+ ? spanRoute(tracePart, spanPart)
149
+ : hrefForEntity("span", entityId, traceId ? { traceId } : undefined);
142
150
  }
143
151
  case "tool_call":
144
- return `#/tool-calls/${encodeURIComponent(entityId)}`;
152
+ return dashboardRouteToHref({ tab: "tool-calls", toolCallId: entityId });
145
153
  case "trace":
146
154
  return traceRoute(entityId);
147
155
  case "docs":
148
- return entityId.startsWith("#/") ? entityId : `#/docs/${entityId}`;
156
+ return hrefForEntity("docs", entityId);
149
157
  case "change":
150
- return `#/changes/${encodeURIComponent(entityId)}`;
158
+ return dashboardRouteToHref({ tab: "changes", changeId: entityId });
151
159
  case "finding":
152
- return `#/findings/${encodeURIComponent(entityId)}`;
160
+ return dashboardRouteToHref({ tab: "findings", findingId: entityId });
153
161
  case "incident":
154
- return `#/incidents/${encodeURIComponent(entityId)}`;
162
+ return dashboardRouteToHref({ tab: "incidents", incidentId: entityId });
155
163
  }
156
164
  const exhaustive: never = entityKind;
157
165
  return exhaustive;
@@ -232,7 +240,7 @@ const instrumentationGapEvidenceReferences = (
232
240
  const thresholdText = thresholdVersion
233
241
  ? ` Thresholds: ${thresholdVersion}.`
234
242
  : "";
235
- const docsRoute = "#/docs/howto/ebpf";
243
+ const docsRoute = hrefForEntity("docs", "howto/ebpf");
236
244
  return {
237
245
  evidenceId: `analysis:${result.analysisId}:instrumentation-gap:${index}:span:${entityId}`,
238
246
  entityKind: "span",
@@ -262,7 +270,7 @@ const instrumentationGapEvidenceReferences = (
262
270
  label: "Open trace gap data",
263
271
  entityKind: "trace",
264
272
  entityId: traceId,
265
- route: `${traceRoute(traceId)}/gaps`,
273
+ route: traceRoute(traceId),
266
274
  reason:
267
275
  "Review all structured instrumentation blindspots for this trace.",
268
276
  },