@bleedingdev/modern-js-server-runtime-extensions 3.9.0-ultramodern.5 → 3.9.0-ultramodern.7
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.matrix.test.ts +0 -37
- package/tests/bff-policy/crossProjectPolicy.test.ts +26 -833
- package/tests/bff-policy/resolveCrossProjectPolicy.test.ts +0 -58
- package/tests/contractGateSnapshotStore.test.ts +0 -51
- package/tests/nativeErrorResponse.test.ts +0 -81
- package/tests/nativeServerAssembly.test.ts +34 -51
- package/tests/static-serving/static.test.ts +31 -20
- package/tests/telemetry.test.ts +0 -97
- package/tests/telemetryHealthMonitor.test.ts +0 -2
- package/tests/telemetryHealthObservation.test.ts +302 -0
- package/tests/telemetryLifecycle.test.ts +0 -54
- package/tests/telemetryRegistryQueueMatrix.test.ts +14 -110
- 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/registration.test.ts +0 -27
- package/tests/static-serving/provider.test.ts +0 -83
- package/tests/telemetryAutopilot.test.ts +0 -993
- package/tests/telemetryCanaryCompatibility.test.ts +0 -152
|
@@ -22,20 +22,15 @@ import {
|
|
|
22
22
|
TelemetryHealthMonitor,
|
|
23
23
|
TelemetryRegistry,
|
|
24
24
|
} from '../telemetryCore';
|
|
25
|
-
import {
|
|
26
|
-
createTelemetryCanaryCompatibility,
|
|
27
|
-
type TelemetryCanaryCompatibility,
|
|
28
|
-
} from './canaryCompatibility';
|
|
29
25
|
|
|
30
26
|
type SetupTelemetryHealthMonitoringOptions = {
|
|
31
27
|
registry: TelemetryRegistry;
|
|
32
28
|
appDirectory: string;
|
|
33
|
-
|
|
29
|
+
healthConfig: ServerTelemetryUserConfig['health'] | undefined;
|
|
34
30
|
};
|
|
35
31
|
|
|
36
32
|
type SetupTelemetryHealthMonitoringResult = {
|
|
37
33
|
healthMonitor?: TelemetryHealthMonitor;
|
|
38
|
-
canaryCompatibility?: TelemetryCanaryCompatibility;
|
|
39
34
|
gateSnapshotStorePromise?: Promise<ContractGateSnapshotStore>;
|
|
40
35
|
runtimeFallbackSignalConfig?: RuntimeFallbackSignalConfig;
|
|
41
36
|
runtimeStatusAuthConfig?: RuntimeFallbackSignalAuthConfig;
|
|
@@ -64,33 +59,29 @@ function emitHealthTransitionMetric(
|
|
|
64
59
|
export const setupTelemetryHealthMonitoring = ({
|
|
65
60
|
registry,
|
|
66
61
|
appDirectory,
|
|
67
|
-
|
|
62
|
+
healthConfig,
|
|
68
63
|
}: SetupTelemetryHealthMonitoringOptions): SetupTelemetryHealthMonitoringResult => {
|
|
69
|
-
if (!
|
|
64
|
+
if (!healthConfig?.enabled) {
|
|
70
65
|
return {};
|
|
71
66
|
}
|
|
72
67
|
|
|
73
|
-
const contractGates =
|
|
68
|
+
const contractGates = healthConfig.contractGates as
|
|
74
69
|
| Record<string, boolean | { passed: boolean; reason?: string }>
|
|
75
70
|
| undefined;
|
|
76
71
|
|
|
77
|
-
const canaryCompatibility = createTelemetryCanaryCompatibility(registry);
|
|
78
72
|
const healthMonitor = new TelemetryHealthMonitor({
|
|
79
73
|
registry,
|
|
80
|
-
evaluationIntervalMs:
|
|
74
|
+
evaluationIntervalMs: healthConfig.evaluationIntervalMs,
|
|
81
75
|
minConsecutiveHealthyEvaluations:
|
|
82
|
-
|
|
83
|
-
// `rollbackConsecutiveFailures` is the legacy public config key. It now
|
|
84
|
-
// controls health-state hysteresis and never triggers a deployment action.
|
|
76
|
+
healthConfig.minConsecutiveHealthyEvaluations,
|
|
85
77
|
minConsecutiveFailedEvaluations:
|
|
86
|
-
|
|
87
|
-
maxQueueUtilization:
|
|
88
|
-
maxTotalDropped:
|
|
89
|
-
maxUnhealthyExporters:
|
|
78
|
+
healthConfig.minConsecutiveFailedEvaluations,
|
|
79
|
+
maxQueueUtilization: healthConfig.maxQueueUtilization,
|
|
80
|
+
maxTotalDropped: healthConfig.maxTotalDropped,
|
|
81
|
+
maxUnhealthyExporters: healthConfig.maxUnhealthyExporters,
|
|
90
82
|
requiredContractGates: Object.keys(contractGates || {}),
|
|
91
83
|
onTransition: evaluation => {
|
|
92
84
|
emitHealthTransitionMetric(registry, evaluation);
|
|
93
|
-
canaryCompatibility.observe(evaluation);
|
|
94
85
|
},
|
|
95
86
|
});
|
|
96
87
|
|
|
@@ -101,22 +92,21 @@ export const setupTelemetryHealthMonitoring = ({
|
|
|
101
92
|
let gateSnapshotStorePromise: Promise<ContractGateSnapshotStore> | undefined;
|
|
102
93
|
let runtimeFallbackSignalConfig: RuntimeFallbackSignalConfig | undefined;
|
|
103
94
|
|
|
104
|
-
// `autopilot` is retained only as the legacy config key for snapshot input.
|
|
105
95
|
const snapshotObservationEnabled =
|
|
106
|
-
|
|
96
|
+
healthConfig.snapshotObservation?.enabled ?? true;
|
|
107
97
|
if (snapshotObservationEnabled) {
|
|
108
98
|
const gateSnapshotPath = resolveContractGateSnapshotPath(
|
|
109
99
|
appDirectory,
|
|
110
|
-
|
|
100
|
+
healthConfig.snapshotObservation?.gateSnapshotPath,
|
|
111
101
|
);
|
|
112
102
|
gateSnapshotStorePromise = resolveContractGateSnapshotStore({
|
|
113
103
|
appDirectory,
|
|
114
104
|
gateSnapshotPath: gateSnapshotPath || DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH,
|
|
115
|
-
stateStore:
|
|
105
|
+
stateStore: healthConfig.snapshotObservation?.stateStore,
|
|
116
106
|
});
|
|
117
107
|
|
|
118
108
|
const runtimeSignalConfig =
|
|
119
|
-
|
|
109
|
+
healthConfig.snapshotObservation?.runtimeFallbackSignal;
|
|
120
110
|
if (runtimeSignalConfig?.enabled === true) {
|
|
121
111
|
runtimeFallbackSignalConfig = {
|
|
122
112
|
endpoint: resolveRuntimeFallbackSignalEndpoint(
|
|
@@ -148,16 +138,15 @@ export const setupTelemetryHealthMonitoring = ({
|
|
|
148
138
|
}
|
|
149
139
|
|
|
150
140
|
// Detailed runtime status stays authenticated even when signal ingestion is
|
|
151
|
-
// disabled.
|
|
141
|
+
// disabled.
|
|
152
142
|
const runtimeStatusAuthConfig =
|
|
153
143
|
runtimeFallbackSignalConfig?.auth ??
|
|
154
144
|
normalizeRuntimeFallbackSignalAuthConfig(
|
|
155
|
-
|
|
145
|
+
healthConfig.snapshotObservation?.runtimeFallbackSignal?.auth,
|
|
156
146
|
);
|
|
157
147
|
|
|
158
148
|
return {
|
|
159
149
|
healthMonitor,
|
|
160
|
-
canaryCompatibility,
|
|
161
150
|
gateSnapshotStorePromise,
|
|
162
151
|
runtimeFallbackSignalConfig,
|
|
163
152
|
runtimeStatusAuthConfig,
|
|
@@ -8,9 +8,9 @@ import { ContractGateSnapshotObserver } from '../contractGateSnapshotObserver';
|
|
|
8
8
|
import {
|
|
9
9
|
createOtlpTelemetryExporter,
|
|
10
10
|
createVictoriaMetricsTelemetryExporter,
|
|
11
|
-
maybeWarnLegacyOtlpEndpoint,
|
|
12
11
|
TelemetryHealthMonitor,
|
|
13
12
|
TelemetryRegistry,
|
|
13
|
+
warnOnMetricsOtlpEndpoint,
|
|
14
14
|
} from '../telemetryCore';
|
|
15
15
|
|
|
16
16
|
type TelemetryLifecycleApi = {
|
|
@@ -22,7 +22,7 @@ type RegisterTelemetryLifecycleOptions = {
|
|
|
22
22
|
api: TelemetryLifecycleApi;
|
|
23
23
|
registry: TelemetryRegistry;
|
|
24
24
|
telemetryConfig: ServerTelemetryUserConfig;
|
|
25
|
-
|
|
25
|
+
healthConfig: ServerTelemetryUserConfig['health'] | undefined;
|
|
26
26
|
healthMonitor?: TelemetryHealthMonitor;
|
|
27
27
|
gateSnapshotStorePromise?: Promise<ContractGateSnapshotStore>;
|
|
28
28
|
appDirectory: string;
|
|
@@ -51,7 +51,7 @@ export const registerTelemetryLifecycle = ({
|
|
|
51
51
|
api,
|
|
52
52
|
registry,
|
|
53
53
|
telemetryConfig,
|
|
54
|
-
|
|
54
|
+
healthConfig,
|
|
55
55
|
healthMonitor,
|
|
56
56
|
gateSnapshotStorePromise,
|
|
57
57
|
appDirectory,
|
|
@@ -82,7 +82,7 @@ export const registerTelemetryLifecycle = ({
|
|
|
82
82
|
prepared = true;
|
|
83
83
|
|
|
84
84
|
if (telemetryConfig.exporters?.otlp?.enabled) {
|
|
85
|
-
|
|
85
|
+
warnOnMetricsOtlpEndpoint(telemetryConfig.exporters.otlp.endpoint);
|
|
86
86
|
await registry.register(
|
|
87
87
|
createOtlpTelemetryExporter(telemetryConfig.exporters.otlp),
|
|
88
88
|
);
|
|
@@ -111,11 +111,11 @@ export const registerTelemetryLifecycle = ({
|
|
|
111
111
|
monitor: healthMonitor,
|
|
112
112
|
gateSnapshotPath: resolveContractGateSnapshotPath(
|
|
113
113
|
appDirectory,
|
|
114
|
-
|
|
114
|
+
healthConfig?.snapshotObservation?.gateSnapshotPath,
|
|
115
115
|
),
|
|
116
116
|
gateSnapshotStore,
|
|
117
|
-
pollIntervalMs:
|
|
118
|
-
gateStaleAfterMs:
|
|
117
|
+
pollIntervalMs: healthConfig?.snapshotObservation?.pollIntervalMs,
|
|
118
|
+
gateStaleAfterMs: healthConfig?.snapshotObservation?.gateStaleAfterMs,
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
121
|
if (contractGateSnapshotObserver) {
|
package/src/telemetry/plugin.ts
CHANGED
|
@@ -135,14 +135,13 @@ export const injectTelemetryPlugin = (): ServerPlugin => ({
|
|
|
135
135
|
|
|
136
136
|
const {
|
|
137
137
|
healthMonitor,
|
|
138
|
-
canaryCompatibility,
|
|
139
138
|
gateSnapshotStorePromise,
|
|
140
139
|
runtimeFallbackSignalConfig,
|
|
141
140
|
runtimeStatusAuthConfig,
|
|
142
141
|
} = setupTelemetryHealthMonitoring({
|
|
143
142
|
registry,
|
|
144
143
|
appDirectory,
|
|
145
|
-
|
|
144
|
+
healthConfig: telemetryConfig.health,
|
|
146
145
|
});
|
|
147
146
|
|
|
148
147
|
if (runtimeFallbackSignalConfig) {
|
|
@@ -154,7 +153,6 @@ export const injectTelemetryPlugin = (): ServerPlugin => ({
|
|
|
154
153
|
createRuntimeStatusMiddleware({
|
|
155
154
|
registry,
|
|
156
155
|
healthMonitor,
|
|
157
|
-
canaryCompatibility,
|
|
158
156
|
runtimeFallbackSignalConfig,
|
|
159
157
|
runtimeStatusAuthConfig,
|
|
160
158
|
}),
|
|
@@ -192,7 +190,7 @@ export const injectTelemetryPlugin = (): ServerPlugin => ({
|
|
|
192
190
|
api,
|
|
193
191
|
registry,
|
|
194
192
|
telemetryConfig,
|
|
195
|
-
|
|
193
|
+
healthConfig: telemetryConfig.health,
|
|
196
194
|
healthMonitor,
|
|
197
195
|
gateSnapshotStorePromise,
|
|
198
196
|
appDirectory,
|
|
@@ -15,12 +15,10 @@ import type {
|
|
|
15
15
|
TelemetryHealthMonitor,
|
|
16
16
|
TelemetryRegistry,
|
|
17
17
|
} from '../telemetryCore';
|
|
18
|
-
import type { TelemetryCanaryCompatibility } from './canaryCompatibility';
|
|
19
18
|
|
|
20
19
|
type RuntimeStatusMiddlewareOptions = {
|
|
21
20
|
registry: TelemetryRegistry;
|
|
22
21
|
healthMonitor?: TelemetryHealthMonitor;
|
|
23
|
-
canaryCompatibility?: TelemetryCanaryCompatibility;
|
|
24
22
|
runtimeFallbackSignalConfig?: RuntimeFallbackSignalConfig;
|
|
25
23
|
runtimeStatusAuthConfig?: RuntimeFallbackSignalAuthConfig;
|
|
26
24
|
};
|
|
@@ -89,7 +87,6 @@ export const createRuntimeFallbackSignalMiddleware = (
|
|
|
89
87
|
export const createRuntimeStatusMiddleware = ({
|
|
90
88
|
registry,
|
|
91
89
|
healthMonitor,
|
|
92
|
-
canaryCompatibility,
|
|
93
90
|
runtimeFallbackSignalConfig,
|
|
94
91
|
runtimeStatusAuthConfig,
|
|
95
92
|
}: RuntimeStatusMiddlewareOptions) => ({
|
|
@@ -128,13 +125,6 @@ export const createRuntimeStatusMiddleware = ({
|
|
|
128
125
|
...healthSnapshot,
|
|
129
126
|
}
|
|
130
127
|
: { enabled: false },
|
|
131
|
-
canary:
|
|
132
|
-
healthSnapshot && canaryCompatibility
|
|
133
|
-
? {
|
|
134
|
-
enabled: true,
|
|
135
|
-
...canaryCompatibility.getStatusSnapshot(healthSnapshot),
|
|
136
|
-
}
|
|
137
|
-
: { enabled: false },
|
|
138
128
|
runtimeFallbackSignal: runtimeFallbackSignalConfig
|
|
139
129
|
? {
|
|
140
130
|
enabled: true,
|
package/src/telemetryCore.ts
CHANGED
|
@@ -7,9 +7,9 @@ export {
|
|
|
7
7
|
export {
|
|
8
8
|
createOtlpTelemetryExporter,
|
|
9
9
|
createVictoriaMetricsTelemetryExporter,
|
|
10
|
-
maybeWarnLegacyOtlpEndpoint,
|
|
11
10
|
type OtlpExporterOptions,
|
|
12
11
|
type VictoriaMetricsExporterOptions,
|
|
12
|
+
warnOnMetricsOtlpEndpoint,
|
|
13
13
|
} from './telemetry/exporters';
|
|
14
14
|
export {
|
|
15
15
|
type TelemetryContractGateStatus,
|
|
@@ -131,24 +131,6 @@ const withNodeEnv = <T>(nodeEnv: string | undefined, callback: () => T): T => {
|
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
-
const denialReasonCoverage: Record<CrossProjectPolicyViolationReason, true> = {
|
|
135
|
-
invalid_envelope: true,
|
|
136
|
-
invalid_operation_context_details: true,
|
|
137
|
-
missing_envelope: true,
|
|
138
|
-
missing_operation_context: true,
|
|
139
|
-
missing_operation_context_details: true,
|
|
140
|
-
missing_operation_schema_hash: true,
|
|
141
|
-
missing_operation_version: true,
|
|
142
|
-
missing_request_id: true,
|
|
143
|
-
namespace_not_allowed: true,
|
|
144
|
-
operation_context_details_request_id_mismatch: true,
|
|
145
|
-
operation_context_mismatch: true,
|
|
146
|
-
operation_schema_hash_mismatch: true,
|
|
147
|
-
operation_version_mismatch: true,
|
|
148
|
-
producer_identity_mismatch: true,
|
|
149
|
-
unknown_operation_contract: true,
|
|
150
|
-
};
|
|
151
|
-
|
|
152
134
|
const policyMatrix = [
|
|
153
135
|
{
|
|
154
136
|
name: 'allow: full valid context with verified namespace and contract',
|
|
@@ -452,25 +434,6 @@ const policyMatrix = [
|
|
|
452
434
|
] satisfies PolicyMatrixScenario[];
|
|
453
435
|
|
|
454
436
|
describe('cross-project policy matrix', () => {
|
|
455
|
-
test('covers every current denial reason', () => {
|
|
456
|
-
const expectedReasons = Object.keys(denialReasonCoverage).sort();
|
|
457
|
-
const coveredReasons = [
|
|
458
|
-
...new Set(
|
|
459
|
-
policyMatrix.flatMap(scenario =>
|
|
460
|
-
scenario.expected.kind === 'deny' ? [scenario.expected.reason] : [],
|
|
461
|
-
),
|
|
462
|
-
),
|
|
463
|
-
].sort();
|
|
464
|
-
|
|
465
|
-
expect(coveredReasons).toEqual(expectedReasons);
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
test('has unique scenario names', () => {
|
|
469
|
-
const names = policyMatrix.map(scenario => scenario.name);
|
|
470
|
-
|
|
471
|
-
expect(new Set(names).size).toBe(names.length);
|
|
472
|
-
});
|
|
473
|
-
|
|
474
437
|
for (const scenario of policyMatrix) {
|
|
475
438
|
test(scenario.name, () => {
|
|
476
439
|
const violation = withNodeEnv(scenario.nodeEnv, () =>
|