@contractspec/lib.observability 1.57.0 → 1.58.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/CHANGELOG.md +13 -0
- package/dist/anomaly/alert-manager.d.ts +17 -0
- package/dist/anomaly/alert-manager.js +24 -0
- package/dist/anomaly/anomaly-detector.d.ts +22 -0
- package/dist/anomaly/anomaly-detector.js +102 -0
- package/dist/anomaly/baseline-calculator.d.ts +23 -0
- package/dist/anomaly/baseline-calculator.js +40 -0
- package/dist/anomaly/root-cause-analyzer.d.ts +19 -0
- package/dist/anomaly/root-cause-analyzer.js +32 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +1078 -0
- package/dist/intent/aggregator.d.ts +57 -0
- package/dist/intent/aggregator.js +110 -0
- package/dist/intent/detector.d.ts +28 -0
- package/dist/intent/detector.js +133 -0
- package/dist/logging/index.d.ts +17 -0
- package/dist/logging/index.js +42 -0
- package/dist/metrics/index.d.ts +12 -0
- package/dist/metrics/index.js +31 -0
- package/dist/node/anomaly/alert-manager.js +23 -0
- package/dist/node/anomaly/anomaly-detector.js +101 -0
- package/dist/node/anomaly/baseline-calculator.js +39 -0
- package/dist/node/anomaly/root-cause-analyzer.js +31 -0
- package/dist/node/index.js +1077 -0
- package/dist/node/intent/aggregator.js +109 -0
- package/dist/node/intent/detector.js +132 -0
- package/dist/node/logging/index.js +41 -0
- package/dist/node/metrics/index.js +30 -0
- package/dist/node/pipeline/evolution-pipeline.js +299 -0
- package/dist/node/pipeline/lifecycle-pipeline.js +85 -0
- package/dist/node/telemetry/posthog-baseline-reader.js +308 -0
- package/dist/node/telemetry/posthog-telemetry.js +60 -0
- package/dist/node/tracing/index.js +52 -0
- package/dist/node/tracing/middleware.js +150 -0
- package/dist/pipeline/evolution-pipeline.d.ts +36 -0
- package/dist/pipeline/evolution-pipeline.js +300 -0
- package/dist/pipeline/lifecycle-pipeline.d.ts +40 -0
- package/dist/pipeline/lifecycle-pipeline.js +86 -0
- package/dist/telemetry/posthog-baseline-reader.d.ts +27 -0
- package/dist/telemetry/posthog-baseline-reader.js +309 -0
- package/dist/telemetry/posthog-telemetry.d.ts +15 -0
- package/dist/telemetry/posthog-telemetry.js +61 -0
- package/dist/tracing/index.d.ts +5 -0
- package/dist/tracing/index.js +53 -0
- package/dist/tracing/middleware.d.ts +15 -0
- package/dist/tracing/middleware.js +151 -0
- package/package.json +140 -43
- package/dist/anomaly/alert-manager.d.mts +0 -21
- package/dist/anomaly/alert-manager.mjs +0 -23
- package/dist/anomaly/anomaly-detector.d.mts +0 -26
- package/dist/anomaly/anomaly-detector.mjs +0 -58
- package/dist/anomaly/baseline-calculator.d.mts +0 -26
- package/dist/anomaly/baseline-calculator.mjs +0 -37
- package/dist/anomaly/root-cause-analyzer.d.mts +0 -23
- package/dist/anomaly/root-cause-analyzer.mjs +0 -27
- package/dist/index.d.mts +0 -15
- package/dist/index.mjs +0 -16
- package/dist/intent/aggregator.d.mts +0 -60
- package/dist/intent/aggregator.mjs +0 -98
- package/dist/intent/detector.d.mts +0 -32
- package/dist/intent/detector.mjs +0 -122
- package/dist/logging/index.d.mts +0 -20
- package/dist/logging/index.mjs +0 -40
- package/dist/metrics/index.d.mts +0 -17
- package/dist/metrics/index.mjs +0 -26
- package/dist/pipeline/evolution-pipeline.d.mts +0 -40
- package/dist/pipeline/evolution-pipeline.mjs +0 -66
- package/dist/pipeline/lifecycle-pipeline.d.mts +0 -44
- package/dist/pipeline/lifecycle-pipeline.mjs +0 -73
- package/dist/telemetry/posthog-baseline-reader.d.mts +0 -31
- package/dist/telemetry/posthog-baseline-reader.mjs +0 -266
- package/dist/telemetry/posthog-telemetry.d.mts +0 -19
- package/dist/telemetry/posthog-telemetry.mjs +0 -61
- package/dist/tracing/index.d.mts +0 -9
- package/dist/tracing/index.mjs +0 -47
- package/dist/tracing/middleware.d.mts +0 -19
- package/dist/tracing/middleware.mjs +0 -80
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/lib.observability",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.58.0",
|
|
4
4
|
"description": "OpenTelemetry-based observability primitives",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contractspec",
|
|
@@ -10,68 +10,165 @@
|
|
|
10
10
|
"metrics",
|
|
11
11
|
"typescript"
|
|
12
12
|
],
|
|
13
|
-
"types": "./dist/index.d.
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
16
16
|
"publish:pkg:canary": "bun publish:pkg --tag canary",
|
|
17
|
-
"build": "bun build:
|
|
18
|
-
"build:bundle": "
|
|
19
|
-
"build:types": "
|
|
20
|
-
"dev": "bun
|
|
17
|
+
"build": "bun run prebuild && bun run build:bundle && bun run build:types",
|
|
18
|
+
"build:bundle": "contractspec-bun-build transpile",
|
|
19
|
+
"build:types": "contractspec-bun-build types",
|
|
20
|
+
"dev": "contractspec-bun-build dev",
|
|
21
21
|
"clean": "rimraf dist .turbo",
|
|
22
22
|
"lint": "bun lint:fix",
|
|
23
23
|
"lint:fix": "eslint src --fix",
|
|
24
24
|
"lint:check": "eslint src",
|
|
25
|
-
"test": "bun test"
|
|
25
|
+
"test": "bun test",
|
|
26
|
+
"prebuild": "contractspec-bun-build prebuild",
|
|
27
|
+
"typecheck": "tsc --noEmit"
|
|
26
28
|
},
|
|
27
29
|
"dependencies": {
|
|
28
|
-
"@contractspec/lib.lifecycle": "1.
|
|
29
|
-
"@contractspec/lib.contracts": "1.
|
|
30
|
+
"@contractspec/lib.lifecycle": "1.58.0",
|
|
31
|
+
"@contractspec/lib.contracts": "1.58.0"
|
|
30
32
|
},
|
|
31
33
|
"peerDependencies": {
|
|
32
34
|
"@opentelemetry/api": "*"
|
|
33
35
|
},
|
|
34
36
|
"devDependencies": {
|
|
35
|
-
"@contractspec/tool.
|
|
36
|
-
"
|
|
37
|
-
"
|
|
37
|
+
"@contractspec/tool.typescript": "1.58.0",
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
|
+
"@contractspec/tool.bun": "1.57.0"
|
|
38
40
|
},
|
|
39
41
|
"exports": {
|
|
40
|
-
".": "./
|
|
41
|
-
"./anomaly/alert-manager": "./
|
|
42
|
-
"./anomaly/anomaly-detector": "./
|
|
43
|
-
"./anomaly/baseline-calculator": "./
|
|
44
|
-
"./anomaly/root-cause-analyzer": "./
|
|
45
|
-
"./intent/aggregator": "./
|
|
46
|
-
"./intent/detector": "./
|
|
47
|
-
"./logging": "./
|
|
48
|
-
"./
|
|
49
|
-
"./
|
|
50
|
-
"./
|
|
51
|
-
"./
|
|
52
|
-
"./
|
|
53
|
-
"./
|
|
54
|
-
"./
|
|
55
|
-
"
|
|
42
|
+
".": "./src/index.ts",
|
|
43
|
+
"./anomaly/alert-manager": "./src/anomaly/alert-manager.ts",
|
|
44
|
+
"./anomaly/anomaly-detector": "./src/anomaly/anomaly-detector.ts",
|
|
45
|
+
"./anomaly/baseline-calculator": "./src/anomaly/baseline-calculator.ts",
|
|
46
|
+
"./anomaly/root-cause-analyzer": "./src/anomaly/root-cause-analyzer.ts",
|
|
47
|
+
"./intent/aggregator": "./src/intent/aggregator.ts",
|
|
48
|
+
"./intent/detector": "./src/intent/detector.ts",
|
|
49
|
+
"./logging": "./src/logging/index.ts",
|
|
50
|
+
"./logging/index": "./src/logging/index.ts",
|
|
51
|
+
"./metrics": "./src/metrics/index.ts",
|
|
52
|
+
"./metrics/index": "./src/metrics/index.ts",
|
|
53
|
+
"./pipeline/evolution-pipeline": "./src/pipeline/evolution-pipeline.ts",
|
|
54
|
+
"./pipeline/lifecycle-pipeline": "./src/pipeline/lifecycle-pipeline.ts",
|
|
55
|
+
"./telemetry/posthog-baseline-reader": "./src/telemetry/posthog-baseline-reader.ts",
|
|
56
|
+
"./telemetry/posthog-telemetry": "./src/telemetry/posthog-telemetry.ts",
|
|
57
|
+
"./tracing": "./src/tracing/index.ts",
|
|
58
|
+
"./tracing/index": "./src/tracing/index.ts",
|
|
59
|
+
"./tracing/middleware": "./src/tracing/middleware.ts"
|
|
56
60
|
},
|
|
57
61
|
"publishConfig": {
|
|
58
62
|
"access": "public",
|
|
59
63
|
"exports": {
|
|
60
|
-
".":
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"./
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"./
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
".": {
|
|
65
|
+
"types": "./dist/index.d.ts",
|
|
66
|
+
"bun": "./dist/index.js",
|
|
67
|
+
"node": "./dist/node/index.mjs",
|
|
68
|
+
"default": "./dist/index.js"
|
|
69
|
+
},
|
|
70
|
+
"./anomaly/alert-manager": {
|
|
71
|
+
"types": "./dist/anomaly/alert-manager.d.ts",
|
|
72
|
+
"bun": "./dist/anomaly/alert-manager.js",
|
|
73
|
+
"node": "./dist/node/anomaly/alert-manager.mjs",
|
|
74
|
+
"default": "./dist/anomaly/alert-manager.js"
|
|
75
|
+
},
|
|
76
|
+
"./anomaly/anomaly-detector": {
|
|
77
|
+
"types": "./dist/anomaly/anomaly-detector.d.ts",
|
|
78
|
+
"bun": "./dist/anomaly/anomaly-detector.js",
|
|
79
|
+
"node": "./dist/node/anomaly/anomaly-detector.mjs",
|
|
80
|
+
"default": "./dist/anomaly/anomaly-detector.js"
|
|
81
|
+
},
|
|
82
|
+
"./anomaly/baseline-calculator": {
|
|
83
|
+
"types": "./dist/anomaly/baseline-calculator.d.ts",
|
|
84
|
+
"bun": "./dist/anomaly/baseline-calculator.js",
|
|
85
|
+
"node": "./dist/node/anomaly/baseline-calculator.mjs",
|
|
86
|
+
"default": "./dist/anomaly/baseline-calculator.js"
|
|
87
|
+
},
|
|
88
|
+
"./anomaly/root-cause-analyzer": {
|
|
89
|
+
"types": "./dist/anomaly/root-cause-analyzer.d.ts",
|
|
90
|
+
"bun": "./dist/anomaly/root-cause-analyzer.js",
|
|
91
|
+
"node": "./dist/node/anomaly/root-cause-analyzer.mjs",
|
|
92
|
+
"default": "./dist/anomaly/root-cause-analyzer.js"
|
|
93
|
+
},
|
|
94
|
+
"./intent/aggregator": {
|
|
95
|
+
"types": "./dist/intent/aggregator.d.ts",
|
|
96
|
+
"bun": "./dist/intent/aggregator.js",
|
|
97
|
+
"node": "./dist/node/intent/aggregator.mjs",
|
|
98
|
+
"default": "./dist/intent/aggregator.js"
|
|
99
|
+
},
|
|
100
|
+
"./intent/detector": {
|
|
101
|
+
"types": "./dist/intent/detector.d.ts",
|
|
102
|
+
"bun": "./dist/intent/detector.js",
|
|
103
|
+
"node": "./dist/node/intent/detector.mjs",
|
|
104
|
+
"default": "./dist/intent/detector.js"
|
|
105
|
+
},
|
|
106
|
+
"./logging": {
|
|
107
|
+
"types": "./dist/logging/index.d.ts",
|
|
108
|
+
"bun": "./dist/logging/index.js",
|
|
109
|
+
"node": "./dist/node/logging/index.mjs",
|
|
110
|
+
"default": "./dist/logging/index.js"
|
|
111
|
+
},
|
|
112
|
+
"./logging/index": {
|
|
113
|
+
"types": "./dist/logging/index.d.ts",
|
|
114
|
+
"bun": "./dist/logging/index.js",
|
|
115
|
+
"node": "./dist/node/logging/index.mjs",
|
|
116
|
+
"default": "./dist/logging/index.js"
|
|
117
|
+
},
|
|
118
|
+
"./metrics": {
|
|
119
|
+
"types": "./dist/metrics/index.d.ts",
|
|
120
|
+
"bun": "./dist/metrics/index.js",
|
|
121
|
+
"node": "./dist/node/metrics/index.mjs",
|
|
122
|
+
"default": "./dist/metrics/index.js"
|
|
123
|
+
},
|
|
124
|
+
"./metrics/index": {
|
|
125
|
+
"types": "./dist/metrics/index.d.ts",
|
|
126
|
+
"bun": "./dist/metrics/index.js",
|
|
127
|
+
"node": "./dist/node/metrics/index.mjs",
|
|
128
|
+
"default": "./dist/metrics/index.js"
|
|
129
|
+
},
|
|
130
|
+
"./pipeline/evolution-pipeline": {
|
|
131
|
+
"types": "./dist/pipeline/evolution-pipeline.d.ts",
|
|
132
|
+
"bun": "./dist/pipeline/evolution-pipeline.js",
|
|
133
|
+
"node": "./dist/node/pipeline/evolution-pipeline.mjs",
|
|
134
|
+
"default": "./dist/pipeline/evolution-pipeline.js"
|
|
135
|
+
},
|
|
136
|
+
"./pipeline/lifecycle-pipeline": {
|
|
137
|
+
"types": "./dist/pipeline/lifecycle-pipeline.d.ts",
|
|
138
|
+
"bun": "./dist/pipeline/lifecycle-pipeline.js",
|
|
139
|
+
"node": "./dist/node/pipeline/lifecycle-pipeline.mjs",
|
|
140
|
+
"default": "./dist/pipeline/lifecycle-pipeline.js"
|
|
141
|
+
},
|
|
142
|
+
"./telemetry/posthog-baseline-reader": {
|
|
143
|
+
"types": "./dist/telemetry/posthog-baseline-reader.d.ts",
|
|
144
|
+
"bun": "./dist/telemetry/posthog-baseline-reader.js",
|
|
145
|
+
"node": "./dist/node/telemetry/posthog-baseline-reader.mjs",
|
|
146
|
+
"default": "./dist/telemetry/posthog-baseline-reader.js"
|
|
147
|
+
},
|
|
148
|
+
"./telemetry/posthog-telemetry": {
|
|
149
|
+
"types": "./dist/telemetry/posthog-telemetry.d.ts",
|
|
150
|
+
"bun": "./dist/telemetry/posthog-telemetry.js",
|
|
151
|
+
"node": "./dist/node/telemetry/posthog-telemetry.mjs",
|
|
152
|
+
"default": "./dist/telemetry/posthog-telemetry.js"
|
|
153
|
+
},
|
|
154
|
+
"./tracing": {
|
|
155
|
+
"types": "./dist/tracing/index.d.ts",
|
|
156
|
+
"bun": "./dist/tracing/index.js",
|
|
157
|
+
"node": "./dist/node/tracing/index.mjs",
|
|
158
|
+
"default": "./dist/tracing/index.js"
|
|
159
|
+
},
|
|
160
|
+
"./tracing/index": {
|
|
161
|
+
"types": "./dist/tracing/index.d.ts",
|
|
162
|
+
"bun": "./dist/tracing/index.js",
|
|
163
|
+
"node": "./dist/node/tracing/index.mjs",
|
|
164
|
+
"default": "./dist/tracing/index.js"
|
|
165
|
+
},
|
|
166
|
+
"./tracing/middleware": {
|
|
167
|
+
"types": "./dist/tracing/middleware.d.ts",
|
|
168
|
+
"bun": "./dist/tracing/middleware.js",
|
|
169
|
+
"node": "./dist/node/tracing/middleware.mjs",
|
|
170
|
+
"default": "./dist/tracing/middleware.js"
|
|
171
|
+
}
|
|
75
172
|
},
|
|
76
173
|
"registry": "https://registry.npmjs.org/"
|
|
77
174
|
},
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { AnomalySignal } from "./anomaly-detector.mjs";
|
|
2
|
-
import { RootCauseAnalysis } from "./root-cause-analyzer.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/anomaly/alert-manager.d.ts
|
|
5
|
-
interface AlertManagerOptions {
|
|
6
|
-
cooldownMs?: number;
|
|
7
|
-
transport: (payload: {
|
|
8
|
-
signal: AnomalySignal;
|
|
9
|
-
analysis: RootCauseAnalysis;
|
|
10
|
-
}) => Promise<void> | void;
|
|
11
|
-
}
|
|
12
|
-
declare class AlertManager {
|
|
13
|
-
private readonly options;
|
|
14
|
-
private readonly cooldownMs;
|
|
15
|
-
private readonly lastAlert;
|
|
16
|
-
constructor(options: AlertManagerOptions);
|
|
17
|
-
notify(signal: AnomalySignal, analysis: RootCauseAnalysis): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
export { AlertManager, AlertManagerOptions };
|
|
21
|
-
//# sourceMappingURL=alert-manager.d.mts.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region src/anomaly/alert-manager.ts
|
|
2
|
-
var AlertManager = class {
|
|
3
|
-
cooldownMs;
|
|
4
|
-
lastAlert = /* @__PURE__ */ new Map();
|
|
5
|
-
constructor(options) {
|
|
6
|
-
this.options = options;
|
|
7
|
-
this.cooldownMs = options.cooldownMs ?? 6e4;
|
|
8
|
-
}
|
|
9
|
-
async notify(signal, analysis) {
|
|
10
|
-
const key = `${signal.type}:${analysis.culprit?.id ?? "none"}`;
|
|
11
|
-
const now = Date.now();
|
|
12
|
-
if (now - (this.lastAlert.get(key) ?? 0) < this.cooldownMs) return;
|
|
13
|
-
await this.options.transport({
|
|
14
|
-
signal,
|
|
15
|
-
analysis
|
|
16
|
-
});
|
|
17
|
-
this.lastAlert.set(key, now);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
export { AlertManager };
|
|
23
|
-
//# sourceMappingURL=alert-manager.mjs.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { BaselineCalculator, MetricPoint } from "./baseline-calculator.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/anomaly/anomaly-detector.d.ts
|
|
4
|
-
interface AnomalyThresholds {
|
|
5
|
-
errorRateDelta?: number;
|
|
6
|
-
latencyDelta?: number;
|
|
7
|
-
throughputDrop?: number;
|
|
8
|
-
minSamples?: number;
|
|
9
|
-
}
|
|
10
|
-
interface AnomalySignal {
|
|
11
|
-
type: 'error_rate_spike' | 'latency_regression' | 'throughput_drop';
|
|
12
|
-
delta: number;
|
|
13
|
-
point: MetricPoint;
|
|
14
|
-
baseline: ReturnType<BaselineCalculator['getSnapshot']>;
|
|
15
|
-
}
|
|
16
|
-
declare class AnomalyDetector {
|
|
17
|
-
private readonly baseline;
|
|
18
|
-
private readonly thresholds;
|
|
19
|
-
constructor(options?: AnomalyThresholds);
|
|
20
|
-
evaluate(point: MetricPoint): AnomalySignal[];
|
|
21
|
-
private relativeDelta;
|
|
22
|
-
private relativeDrop;
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
export { AnomalyDetector, AnomalySignal, AnomalyThresholds };
|
|
26
|
-
//# sourceMappingURL=anomaly-detector.d.mts.map
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { BaselineCalculator } from "./baseline-calculator.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/anomaly/anomaly-detector.ts
|
|
4
|
-
var AnomalyDetector = class {
|
|
5
|
-
baseline;
|
|
6
|
-
thresholds = {
|
|
7
|
-
errorRateDelta: .5,
|
|
8
|
-
latencyDelta: .35,
|
|
9
|
-
throughputDrop: .4,
|
|
10
|
-
minSamples: 10
|
|
11
|
-
};
|
|
12
|
-
constructor(options = {}) {
|
|
13
|
-
this.baseline = new BaselineCalculator();
|
|
14
|
-
this.thresholds = {
|
|
15
|
-
...this.thresholds,
|
|
16
|
-
...options
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
evaluate(point) {
|
|
20
|
-
const baselineSnapshot = this.baseline.update(point);
|
|
21
|
-
if (baselineSnapshot.sampleCount < this.thresholds.minSamples) return [];
|
|
22
|
-
const signals = [];
|
|
23
|
-
const errorDelta = this.relativeDelta(point.errorRate, baselineSnapshot.errorRate);
|
|
24
|
-
if (errorDelta > this.thresholds.errorRateDelta) signals.push({
|
|
25
|
-
type: "error_rate_spike",
|
|
26
|
-
delta: errorDelta,
|
|
27
|
-
point,
|
|
28
|
-
baseline: baselineSnapshot
|
|
29
|
-
});
|
|
30
|
-
const latencyDelta = this.relativeDelta(point.latencyP99, baselineSnapshot.latencyP99);
|
|
31
|
-
if (latencyDelta > this.thresholds.latencyDelta) signals.push({
|
|
32
|
-
type: "latency_regression",
|
|
33
|
-
delta: latencyDelta,
|
|
34
|
-
point,
|
|
35
|
-
baseline: baselineSnapshot
|
|
36
|
-
});
|
|
37
|
-
const throughputDelta = this.relativeDrop(point.throughput, baselineSnapshot.throughput);
|
|
38
|
-
if (throughputDelta > this.thresholds.throughputDrop) signals.push({
|
|
39
|
-
type: "throughput_drop",
|
|
40
|
-
delta: throughputDelta,
|
|
41
|
-
point,
|
|
42
|
-
baseline: baselineSnapshot
|
|
43
|
-
});
|
|
44
|
-
return signals;
|
|
45
|
-
}
|
|
46
|
-
relativeDelta(value, baseline) {
|
|
47
|
-
if (baseline === 0) return 0;
|
|
48
|
-
return (value - baseline) / baseline;
|
|
49
|
-
}
|
|
50
|
-
relativeDrop(value, baseline) {
|
|
51
|
-
if (baseline === 0) return 0;
|
|
52
|
-
return (baseline - value) / baseline;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
//#endregion
|
|
57
|
-
export { AnomalyDetector };
|
|
58
|
-
//# sourceMappingURL=anomaly-detector.mjs.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
//#region src/anomaly/baseline-calculator.d.ts
|
|
2
|
-
interface MetricPoint {
|
|
3
|
-
latencyP99: number;
|
|
4
|
-
latencyP95: number;
|
|
5
|
-
errorRate: number;
|
|
6
|
-
throughput: number;
|
|
7
|
-
timestamp: Date;
|
|
8
|
-
}
|
|
9
|
-
interface BaselineSnapshot {
|
|
10
|
-
latencyP99: number;
|
|
11
|
-
latencyP95: number;
|
|
12
|
-
errorRate: number;
|
|
13
|
-
throughput: number;
|
|
14
|
-
sampleCount: number;
|
|
15
|
-
}
|
|
16
|
-
declare class BaselineCalculator {
|
|
17
|
-
private readonly alpha;
|
|
18
|
-
private snapshot;
|
|
19
|
-
constructor(alpha?: number);
|
|
20
|
-
update(point: MetricPoint): BaselineSnapshot;
|
|
21
|
-
getSnapshot(): BaselineSnapshot;
|
|
22
|
-
private mix;
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
export { BaselineCalculator, BaselineSnapshot, MetricPoint };
|
|
26
|
-
//# sourceMappingURL=baseline-calculator.d.mts.map
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
//#region src/anomaly/baseline-calculator.ts
|
|
2
|
-
var BaselineCalculator = class {
|
|
3
|
-
snapshot = {
|
|
4
|
-
latencyP99: 0,
|
|
5
|
-
latencyP95: 0,
|
|
6
|
-
errorRate: 0,
|
|
7
|
-
throughput: 0,
|
|
8
|
-
sampleCount: 0
|
|
9
|
-
};
|
|
10
|
-
constructor(alpha = .2) {
|
|
11
|
-
this.alpha = alpha;
|
|
12
|
-
}
|
|
13
|
-
update(point) {
|
|
14
|
-
const { sampleCount } = this.snapshot;
|
|
15
|
-
const nextCount = sampleCount + 1;
|
|
16
|
-
const weight = sampleCount === 0 ? 1 : this.alpha;
|
|
17
|
-
this.snapshot = {
|
|
18
|
-
latencyP99: this.mix(this.snapshot.latencyP99, point.latencyP99, weight),
|
|
19
|
-
latencyP95: this.mix(this.snapshot.latencyP95, point.latencyP95, weight),
|
|
20
|
-
errorRate: this.mix(this.snapshot.errorRate, point.errorRate, weight),
|
|
21
|
-
throughput: this.mix(this.snapshot.throughput, point.throughput, weight),
|
|
22
|
-
sampleCount: nextCount
|
|
23
|
-
};
|
|
24
|
-
return this.snapshot;
|
|
25
|
-
}
|
|
26
|
-
getSnapshot() {
|
|
27
|
-
return this.snapshot;
|
|
28
|
-
}
|
|
29
|
-
mix(current, next, weight) {
|
|
30
|
-
if (this.snapshot.sampleCount === 0) return next;
|
|
31
|
-
return current * (1 - weight) + next * weight;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
export { BaselineCalculator };
|
|
37
|
-
//# sourceMappingURL=baseline-calculator.mjs.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { AnomalySignal } from "./anomaly-detector.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/anomaly/root-cause-analyzer.d.ts
|
|
4
|
-
interface DeploymentEvent {
|
|
5
|
-
id: string;
|
|
6
|
-
operation: string;
|
|
7
|
-
deployedAt: Date;
|
|
8
|
-
stage?: string;
|
|
9
|
-
status: 'in_progress' | 'completed' | 'rolled_back';
|
|
10
|
-
}
|
|
11
|
-
interface RootCauseAnalysis {
|
|
12
|
-
signal: AnomalySignal;
|
|
13
|
-
culprit?: DeploymentEvent;
|
|
14
|
-
notes: string[];
|
|
15
|
-
}
|
|
16
|
-
declare class RootCauseAnalyzer {
|
|
17
|
-
private readonly lookbackMs;
|
|
18
|
-
constructor(lookbackMs?: number);
|
|
19
|
-
analyze(signal: AnomalySignal, deployments: DeploymentEvent[]): RootCauseAnalysis;
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { DeploymentEvent, RootCauseAnalysis, RootCauseAnalyzer };
|
|
23
|
-
//# sourceMappingURL=root-cause-analyzer.d.mts.map
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
//#region src/anomaly/root-cause-analyzer.ts
|
|
2
|
-
var RootCauseAnalyzer = class {
|
|
3
|
-
constructor(lookbackMs = 900 * 1e3) {
|
|
4
|
-
this.lookbackMs = lookbackMs;
|
|
5
|
-
}
|
|
6
|
-
analyze(signal, deployments) {
|
|
7
|
-
const windowStart = new Date(signal.point.timestamp.getTime() - this.lookbackMs);
|
|
8
|
-
const candidates = deployments.filter((deployment) => deployment.deployedAt >= windowStart).sort((a, b) => b.deployedAt.getTime() - a.deployedAt.getTime());
|
|
9
|
-
const notes = [];
|
|
10
|
-
let culprit;
|
|
11
|
-
if (candidates.length > 0) {
|
|
12
|
-
culprit = candidates[0];
|
|
13
|
-
if (culprit) notes.push(`Closest deployment ${culprit.id} (${culprit.operation}) at ${culprit.deployedAt.toISOString()}`);
|
|
14
|
-
} else notes.push("No deployments found within lookback window.");
|
|
15
|
-
if (signal.type === "latency_regression") notes.push("Verify recent schema changes and external dependency latency.");
|
|
16
|
-
if (signal.type === "error_rate_spike") notes.push("Check SLO monitor for correlated incidents.");
|
|
17
|
-
return {
|
|
18
|
-
signal,
|
|
19
|
-
culprit,
|
|
20
|
-
notes
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
export { RootCauseAnalyzer };
|
|
27
|
-
//# sourceMappingURL=root-cause-analyzer.mjs.map
|
package/dist/index.d.mts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { BaselineCalculator } from "./anomaly/baseline-calculator.mjs";
|
|
2
|
-
import { AnomalyDetector, AnomalySignal, AnomalyThresholds } from "./anomaly/anomaly-detector.mjs";
|
|
3
|
-
import { RootCauseAnalysis, RootCauseAnalyzer } from "./anomaly/root-cause-analyzer.mjs";
|
|
4
|
-
import { AlertManager } from "./anomaly/alert-manager.mjs";
|
|
5
|
-
import { getTracer, traceAsync, traceSync } from "./tracing/index.mjs";
|
|
6
|
-
import { createCounter, createHistogram, createUpDownCounter, getMeter, standardMetrics } from "./metrics/index.mjs";
|
|
7
|
-
import { LogEntry, LogLevel, Logger, logger } from "./logging/index.mjs";
|
|
8
|
-
import { IntentAggregator, IntentAggregatorSnapshot, TelemetrySample } from "./intent/aggregator.mjs";
|
|
9
|
-
import { TracingMiddlewareOptions, createTracingMiddleware } from "./tracing/middleware.mjs";
|
|
10
|
-
import { IntentDetector, IntentSignal, IntentSignalType } from "./intent/detector.mjs";
|
|
11
|
-
import { EvolutionPipeline, EvolutionPipelineEvent, EvolutionPipelineOptions } from "./pipeline/evolution-pipeline.mjs";
|
|
12
|
-
import { LifecycleKpiPipeline, LifecycleKpiPipelineOptions, LifecyclePipelineEvent } from "./pipeline/lifecycle-pipeline.mjs";
|
|
13
|
-
import { PosthogTelemetryProvider, PosthogTelemetryProviderOptions } from "./telemetry/posthog-telemetry.mjs";
|
|
14
|
-
import { PosthogBaselineReader } from "./telemetry/posthog-baseline-reader.mjs";
|
|
15
|
-
export { AlertManager, AnomalyDetector, type AnomalySignal, type AnomalyThresholds, BaselineCalculator, EvolutionPipeline, type EvolutionPipelineEvent, type EvolutionPipelineOptions, IntentAggregator, type IntentAggregatorSnapshot, IntentDetector, type IntentSignal, type IntentSignalType, LifecycleKpiPipeline, type LifecycleKpiPipelineOptions, type LifecyclePipelineEvent, type LogEntry, type LogLevel, Logger, PosthogBaselineReader, PosthogTelemetryProvider, type PosthogTelemetryProviderOptions, type RootCauseAnalysis, RootCauseAnalyzer, type TelemetrySample, type TracingMiddlewareOptions, createCounter, createHistogram, createTracingMiddleware, createUpDownCounter, getMeter, getTracer, logger, standardMetrics, traceAsync, traceSync };
|
package/dist/index.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { getTracer, traceAsync, traceSync } from "./tracing/index.mjs";
|
|
2
|
-
import { createCounter, createHistogram, createUpDownCounter, getMeter, standardMetrics } from "./metrics/index.mjs";
|
|
3
|
-
import { Logger, logger } from "./logging/index.mjs";
|
|
4
|
-
import { createTracingMiddleware } from "./tracing/middleware.mjs";
|
|
5
|
-
import { IntentAggregator } from "./intent/aggregator.mjs";
|
|
6
|
-
import { IntentDetector } from "./intent/detector.mjs";
|
|
7
|
-
import { EvolutionPipeline } from "./pipeline/evolution-pipeline.mjs";
|
|
8
|
-
import { LifecycleKpiPipeline } from "./pipeline/lifecycle-pipeline.mjs";
|
|
9
|
-
import { PosthogTelemetryProvider } from "./telemetry/posthog-telemetry.mjs";
|
|
10
|
-
import { PosthogBaselineReader } from "./telemetry/posthog-baseline-reader.mjs";
|
|
11
|
-
import { BaselineCalculator } from "./anomaly/baseline-calculator.mjs";
|
|
12
|
-
import { AnomalyDetector } from "./anomaly/anomaly-detector.mjs";
|
|
13
|
-
import { RootCauseAnalyzer } from "./anomaly/root-cause-analyzer.mjs";
|
|
14
|
-
import { AlertManager } from "./anomaly/alert-manager.mjs";
|
|
15
|
-
|
|
16
|
-
export { AlertManager, AnomalyDetector, BaselineCalculator, EvolutionPipeline, IntentAggregator, IntentDetector, LifecycleKpiPipeline, Logger, PosthogBaselineReader, PosthogTelemetryProvider, RootCauseAnalyzer, createCounter, createHistogram, createTracingMiddleware, createUpDownCounter, getMeter, getTracer, logger, standardMetrics, traceAsync, traceSync };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
//#region src/intent/aggregator.d.ts
|
|
2
|
-
interface TelemetrySample {
|
|
3
|
-
operation: {
|
|
4
|
-
name: string;
|
|
5
|
-
version: string;
|
|
6
|
-
};
|
|
7
|
-
durationMs: number;
|
|
8
|
-
success: boolean;
|
|
9
|
-
timestamp: Date;
|
|
10
|
-
errorCode?: string;
|
|
11
|
-
tenantId?: string;
|
|
12
|
-
traceId?: string;
|
|
13
|
-
actorId?: string;
|
|
14
|
-
metadata?: Record<string, unknown>;
|
|
15
|
-
}
|
|
16
|
-
interface AggregatedOperationMetrics {
|
|
17
|
-
operation: {
|
|
18
|
-
name: string;
|
|
19
|
-
version: string;
|
|
20
|
-
};
|
|
21
|
-
totalCalls: number;
|
|
22
|
-
successRate: number;
|
|
23
|
-
errorRate: number;
|
|
24
|
-
averageLatencyMs: number;
|
|
25
|
-
p95LatencyMs: number;
|
|
26
|
-
p99LatencyMs: number;
|
|
27
|
-
maxLatencyMs: number;
|
|
28
|
-
windowStart: Date;
|
|
29
|
-
windowEnd: Date;
|
|
30
|
-
topErrors: Record<string, number>;
|
|
31
|
-
}
|
|
32
|
-
interface OperationSequence {
|
|
33
|
-
steps: string[];
|
|
34
|
-
tenantId?: string;
|
|
35
|
-
count: number;
|
|
36
|
-
}
|
|
37
|
-
interface IntentAggregatorSnapshot {
|
|
38
|
-
metrics: AggregatedOperationMetrics[];
|
|
39
|
-
sequences: OperationSequence[];
|
|
40
|
-
sampleCount: number;
|
|
41
|
-
windowStart?: Date;
|
|
42
|
-
windowEnd?: Date;
|
|
43
|
-
}
|
|
44
|
-
interface IntentAggregatorOptions {
|
|
45
|
-
windowMs?: number;
|
|
46
|
-
sequenceSampleSize?: number;
|
|
47
|
-
}
|
|
48
|
-
declare class IntentAggregator {
|
|
49
|
-
private readonly windowMs;
|
|
50
|
-
private readonly sequenceSampleSize;
|
|
51
|
-
private readonly samples;
|
|
52
|
-
constructor(options?: IntentAggregatorOptions);
|
|
53
|
-
add(sample: TelemetrySample): void;
|
|
54
|
-
flush(now?: Date): IntentAggregatorSnapshot;
|
|
55
|
-
private aggregateMetrics;
|
|
56
|
-
private buildSequences;
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
export { AggregatedOperationMetrics, IntentAggregator, IntentAggregatorOptions, IntentAggregatorSnapshot, OperationSequence, TelemetrySample };
|
|
60
|
-
//# sourceMappingURL=aggregator.d.mts.map
|