@bleedingdev/modern-js-server-runtime-extensions 3.9.0-ultramodern.5 → 3.9.0-ultramodern.6
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/README.md +5 -5
- package/dist/cjs/bff-policy/crossProjectPolicy.js +1 -11
- package/dist/cjs/contract-gate-snapshot-store/http-store.js +1 -8
- package/dist/cjs/telemetry/exporters.js +4 -4
- package/dist/cjs/telemetry/healthSetup.js +14 -18
- package/dist/cjs/telemetry/lifecycle.js +5 -5
- package/dist/cjs/telemetry/plugin.js +3 -4
- package/dist/cjs/telemetry/runtimeEndpoints.js +1 -7
- package/dist/cjs/telemetryCore.js +5 -5
- package/dist/esm/bff-policy/crossProjectPolicy.mjs +1 -11
- package/dist/esm/contract-gate-snapshot-store/http-store.mjs +1 -8
- package/dist/esm/telemetry/exporters.mjs +2 -2
- package/dist/esm/telemetry/healthSetup.mjs +14 -18
- package/dist/esm/telemetry/lifecycle.mjs +6 -6
- package/dist/esm/telemetry/plugin.mjs +3 -4
- package/dist/esm/telemetry/runtimeEndpoints.mjs +1 -7
- package/dist/esm/telemetryCore.mjs +1 -1
- package/dist/esm-node/bff-policy/crossProjectPolicy.mjs +1 -11
- package/dist/esm-node/contract-gate-snapshot-store/http-store.mjs +1 -8
- package/dist/esm-node/telemetry/exporters.mjs +2 -2
- package/dist/esm-node/telemetry/healthSetup.mjs +14 -18
- package/dist/esm-node/telemetry/lifecycle.mjs +6 -6
- package/dist/esm-node/telemetry/plugin.mjs +3 -4
- package/dist/esm-node/telemetry/runtimeEndpoints.mjs +1 -7
- package/dist/esm-node/telemetryCore.mjs +1 -1
- package/dist/types/bff-policy/crossProjectPolicy.d.ts +2 -11
- package/dist/types/telemetry/exporters.d.ts +1 -1
- package/dist/types/telemetry/healthSetup.d.ts +2 -4
- package/dist/types/telemetry/lifecycle.d.ts +2 -2
- package/dist/types/telemetry/runtimeEndpoints.d.ts +1 -3
- package/dist/types/telemetryCore.d.ts +1 -1
- package/dist/types-esm/bff-policy/crossProjectPolicy.d.mts +2 -11
- package/dist/types-esm/telemetry/exporters.d.mts +1 -1
- package/dist/types-esm/telemetry/healthSetup.d.mts +2 -4
- package/dist/types-esm/telemetry/lifecycle.d.mts +2 -2
- package/dist/types-esm/telemetry/runtimeEndpoints.d.mts +1 -3
- package/dist/types-esm/telemetryCore.d.mts +1 -1
- package/package.json +10 -10
- package/src/bff-policy/crossProjectPolicy.ts +7 -34
- package/src/contract-gate-snapshot-store/http-store.ts +1 -11
- package/src/telemetry/exporters.ts +1 -1
- package/src/telemetry/healthSetup.ts +16 -27
- package/src/telemetry/lifecycle.ts +7 -7
- package/src/telemetry/plugin.ts +2 -4
- package/src/telemetry/runtimeEndpoints.ts +0 -10
- package/src/telemetryCore.ts +1 -1
- package/tests/bff-policy/crossProjectPolicy.test.ts +0 -34
- package/tests/nativeServerAssembly.test.ts +4 -4
- package/tests/registration.test.ts +1 -1
- package/tests/{telemetryAutopilot.test.ts → telemetryHealthObservation.test.ts} +38 -36
- package/dist/cjs/telemetry/canaryCompatibility.js +0 -73
- package/dist/esm/telemetry/canaryCompatibility.mjs +0 -35
- package/dist/esm-node/telemetry/canaryCompatibility.mjs +0 -36
- package/dist/types/telemetry/canaryCompatibility.d.ts +0 -19
- package/dist/types-esm/telemetry/canaryCompatibility.d.mts +0 -19
- package/src/telemetry/canaryCompatibility.ts +0 -55
- package/tests/telemetryCanaryCompatibility.test.ts +0 -152
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { TelemetryHealthEvaluation, TelemetryHealthStatusSnapshot } from './healthMonitor.mjs';
|
|
2
|
-
import type { TelemetryRegistry } from './registry.mjs';
|
|
3
|
-
type CanaryState = 'canary' | 'promoted' | 'rolled_back';
|
|
4
|
-
export declare const createTelemetryCanaryCompatibility: (registry: TelemetryRegistry) => {
|
|
5
|
-
observe(evaluation: TelemetryHealthEvaluation): void;
|
|
6
|
-
getStatusSnapshot(snapshot: TelemetryHealthStatusSnapshot): {
|
|
7
|
-
timestamp: number;
|
|
8
|
-
consecutiveHealthy: number;
|
|
9
|
-
consecutiveFailures: number;
|
|
10
|
-
queueStats: import("./registryTypes.mjs").TelemetryQueueStats;
|
|
11
|
-
unhealthyExporterCount: number;
|
|
12
|
-
requiredContractGates: string[];
|
|
13
|
-
contractGates: import("./healthMonitor.mjs").TelemetryContractGateStatus[];
|
|
14
|
-
failurePreview: import("./healthMonitor.mjs").TelemetryHealthFailure[];
|
|
15
|
-
state: CanaryState;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export type TelemetryCanaryCompatibility = ReturnType<typeof createTelemetryCanaryCompatibility>;
|
|
19
|
-
export {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
TelemetryHealthEvaluation,
|
|
3
|
-
TelemetryHealthStatusSnapshot,
|
|
4
|
-
} from './healthMonitor';
|
|
5
|
-
import type { TelemetryRegistry } from './registry';
|
|
6
|
-
|
|
7
|
-
type CanaryState = 'canary' | 'promoted' | 'rolled_back';
|
|
8
|
-
|
|
9
|
-
// Preserve the legacy reporting contract without a second monitor or timer.
|
|
10
|
-
// Rollback remains terminal in this view even when observed health recovers.
|
|
11
|
-
export const createTelemetryCanaryCompatibility = (
|
|
12
|
-
registry: TelemetryRegistry,
|
|
13
|
-
) => {
|
|
14
|
-
let state: CanaryState = 'canary';
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
observe(evaluation: TelemetryHealthEvaluation) {
|
|
18
|
-
let action: 'promote' | 'rollback';
|
|
19
|
-
if (evaluation.transition === 'became_healthy' && state === 'canary') {
|
|
20
|
-
state = 'promoted';
|
|
21
|
-
action = 'promote';
|
|
22
|
-
} else if (
|
|
23
|
-
evaluation.transition === 'became_unhealthy' &&
|
|
24
|
-
state !== 'rolled_back'
|
|
25
|
-
) {
|
|
26
|
-
state = 'rolled_back';
|
|
27
|
-
action = 'rollback';
|
|
28
|
-
} else {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
registry.enqueueMetric({
|
|
34
|
-
name: `telemetry.canary.${action}`,
|
|
35
|
-
value: 1,
|
|
36
|
-
unit: 'count',
|
|
37
|
-
tags: {
|
|
38
|
-
action,
|
|
39
|
-
state,
|
|
40
|
-
failures: String(evaluation.failures.length),
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
} catch (_error) {
|
|
44
|
-
// Legacy decision metrics must not break health observation.
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
getStatusSnapshot(snapshot: TelemetryHealthStatusSnapshot) {
|
|
48
|
-
return { ...snapshot, state };
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export type TelemetryCanaryCompatibility = ReturnType<
|
|
54
|
-
typeof createTelemetryCanaryCompatibility
|
|
55
|
-
>;
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { setupTelemetryHealthMonitoring } from '../src/telemetry/healthSetup';
|
|
2
|
-
import { TelemetryRegistry } from '../src/telemetryCore';
|
|
3
|
-
|
|
4
|
-
const createMonitoring = (initiallyHealthy = true) => {
|
|
5
|
-
const registry = new TelemetryRegistry({
|
|
6
|
-
service: 'svc',
|
|
7
|
-
module: 'server',
|
|
8
|
-
environment: 'test',
|
|
9
|
-
flushIntervalMs: 60_000,
|
|
10
|
-
});
|
|
11
|
-
const monitoring = setupTelemetryHealthMonitoring({
|
|
12
|
-
registry,
|
|
13
|
-
appDirectory: process.cwd(),
|
|
14
|
-
legacyHealthConfig: {
|
|
15
|
-
enabled: true,
|
|
16
|
-
minConsecutiveHealthyEvaluations: 2,
|
|
17
|
-
rollbackConsecutiveFailures: 2,
|
|
18
|
-
contractGates: { contracts: initiallyHealthy },
|
|
19
|
-
autopilot: { enabled: false },
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
if (!monitoring.healthMonitor || !monitoring.canaryCompatibility) {
|
|
23
|
-
throw new Error('Expected enabled telemetry health monitoring');
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
registry,
|
|
27
|
-
monitor: monitoring.healthMonitor,
|
|
28
|
-
compatibility: monitoring.canaryCompatibility,
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
describe('telemetry canary reporting compatibility', () => {
|
|
33
|
-
test('preserves legacy decisions while native health recovers', async () => {
|
|
34
|
-
const { registry, monitor, compatibility } = createMonitoring();
|
|
35
|
-
const enqueueMetric = rs.spyOn(registry, 'enqueueMetric');
|
|
36
|
-
const snapshot = () =>
|
|
37
|
-
compatibility.getStatusSnapshot(monitor.getStatusSnapshot());
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
expect(snapshot().state).toBe('canary');
|
|
41
|
-
monitor.evaluate();
|
|
42
|
-
expect(snapshot().state).toBe('canary');
|
|
43
|
-
monitor.evaluate();
|
|
44
|
-
monitor.evaluate();
|
|
45
|
-
expect(snapshot()).toEqual({
|
|
46
|
-
...monitor.getStatusSnapshot(),
|
|
47
|
-
timestamp: expect.any(Number),
|
|
48
|
-
state: 'promoted',
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
monitor.setContractGate('contracts', false, 'schema drift');
|
|
52
|
-
monitor.evaluate();
|
|
53
|
-
expect(snapshot().state).toBe('promoted');
|
|
54
|
-
monitor.evaluate();
|
|
55
|
-
expect(snapshot()).toMatchObject({
|
|
56
|
-
state: 'rolled_back',
|
|
57
|
-
consecutiveFailures: 2,
|
|
58
|
-
failurePreview: [{ reason: 'contract_gate_failed', gate: 'contracts' }],
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
monitor.setContractGate('contracts', true);
|
|
62
|
-
monitor.evaluate();
|
|
63
|
-
monitor.evaluate();
|
|
64
|
-
expect(monitor.getStatusSnapshot().state).toBe('healthy');
|
|
65
|
-
expect(snapshot()).toMatchObject({
|
|
66
|
-
state: 'rolled_back',
|
|
67
|
-
consecutiveHealthy: 2,
|
|
68
|
-
failurePreview: [],
|
|
69
|
-
});
|
|
70
|
-
monitor.setContractGate('contracts', false);
|
|
71
|
-
monitor.evaluate();
|
|
72
|
-
monitor.evaluate();
|
|
73
|
-
expect(snapshot().state).toBe('rolled_back');
|
|
74
|
-
|
|
75
|
-
const metrics = enqueueMetric.mock.calls.map(([metric]) => metric);
|
|
76
|
-
expect(
|
|
77
|
-
metrics.filter(metric => metric.name.startsWith('telemetry.canary.')),
|
|
78
|
-
).toEqual([
|
|
79
|
-
{
|
|
80
|
-
name: 'telemetry.canary.promote',
|
|
81
|
-
value: 1,
|
|
82
|
-
unit: 'count',
|
|
83
|
-
tags: { action: 'promote', state: 'promoted', failures: '0' },
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: 'telemetry.canary.rollback',
|
|
87
|
-
value: 1,
|
|
88
|
-
unit: 'count',
|
|
89
|
-
tags: { action: 'rollback', state: 'rolled_back', failures: '1' },
|
|
90
|
-
},
|
|
91
|
-
]);
|
|
92
|
-
expect(
|
|
93
|
-
metrics
|
|
94
|
-
.filter(metric => metric.name === 'telemetry.health.transition')
|
|
95
|
-
.map(metric => metric.tags?.transition),
|
|
96
|
-
).toEqual([
|
|
97
|
-
'became_healthy',
|
|
98
|
-
'became_unhealthy',
|
|
99
|
-
'became_healthy',
|
|
100
|
-
'became_unhealthy',
|
|
101
|
-
]);
|
|
102
|
-
} finally {
|
|
103
|
-
await registry.shutdown();
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
test('does not promote after an initial rollback', async () => {
|
|
108
|
-
const { registry, monitor, compatibility } = createMonitoring(false);
|
|
109
|
-
const enqueueMetric = rs.spyOn(registry, 'enqueueMetric');
|
|
110
|
-
try {
|
|
111
|
-
monitor.evaluate();
|
|
112
|
-
monitor.evaluate();
|
|
113
|
-
monitor.setContractGate('contracts', true);
|
|
114
|
-
monitor.evaluate();
|
|
115
|
-
monitor.evaluate();
|
|
116
|
-
expect(monitor.getStatusSnapshot().state).toBe('healthy');
|
|
117
|
-
expect(
|
|
118
|
-
compatibility.getStatusSnapshot(monitor.getStatusSnapshot()).state,
|
|
119
|
-
).toBe('rolled_back');
|
|
120
|
-
expect(
|
|
121
|
-
enqueueMetric.mock.calls
|
|
122
|
-
.filter(([metric]) => metric.name.startsWith('telemetry.canary.'))
|
|
123
|
-
.map(([metric]) => metric.name),
|
|
124
|
-
).toEqual(['telemetry.canary.rollback']);
|
|
125
|
-
} finally {
|
|
126
|
-
await registry.shutdown();
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
test('isolates metric failures and retains the legacy decision', async () => {
|
|
131
|
-
const { registry, monitor, compatibility } = createMonitoring();
|
|
132
|
-
const enqueueMetric = rs
|
|
133
|
-
.spyOn(registry, 'enqueueMetric')
|
|
134
|
-
.mockImplementation(() => {
|
|
135
|
-
throw new Error('metric unavailable');
|
|
136
|
-
});
|
|
137
|
-
try {
|
|
138
|
-
expect(() => {
|
|
139
|
-
monitor.evaluate();
|
|
140
|
-
monitor.evaluate();
|
|
141
|
-
}).not.toThrow();
|
|
142
|
-
expect(monitor.getStatusSnapshot().state).toBe('healthy');
|
|
143
|
-
expect(
|
|
144
|
-
compatibility.getStatusSnapshot(monitor.getStatusSnapshot()).state,
|
|
145
|
-
).toBe('promoted');
|
|
146
|
-
expect(enqueueMetric).toHaveBeenCalledTimes(2);
|
|
147
|
-
} finally {
|
|
148
|
-
enqueueMetric.mockRestore();
|
|
149
|
-
await registry.shutdown();
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
});
|