mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-27 21:54:15 +00:00
Added health metrics for application load and database load (#2257)
* Added health metrics for application load * Added health metrics for application load * Fix unit tests * Added more metrics * Added few comments * Added DatabaseLoad Scenario and address comments * Fix unit tests * fix unit tests * Fix unit tests * fix unit tests * fix the mock * Fix unit tests
This commit is contained in:
47
src/Metrics/ScenarioConfig.ts
Normal file
47
src/Metrics/ScenarioConfig.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import MetricScenario from "./MetricEvents";
|
||||
|
||||
// Common phases shared across all scenarios
|
||||
export enum CommonMetricPhase {
|
||||
Interactive = "Interactive",
|
||||
}
|
||||
|
||||
// Application-specific phases
|
||||
export enum ApplicationMetricPhase {
|
||||
ExplorerInitialized = "ExplorerInitialized",
|
||||
DatabasesFetched = "DatabasesFetched",
|
||||
DatabaseTreeRendered = "DatabaseTreeRendered",
|
||||
}
|
||||
|
||||
// Combined type for all metric phases
|
||||
export type MetricPhase = CommonMetricPhase | ApplicationMetricPhase;
|
||||
|
||||
export interface WebVitals {
|
||||
lcp?: number; // Largest Contentful Paint
|
||||
inp?: number; // Interaction to Next Paint
|
||||
cls?: number; // Cumulative Layout Shift
|
||||
fcp?: number; // First Contentful Paint
|
||||
ttfb?: number; // Time to First Byte
|
||||
}
|
||||
|
||||
export interface ScenarioConfig<TPhase extends string = MetricPhase> {
|
||||
requiredPhases: TPhase[];
|
||||
timeoutMs: number;
|
||||
validate?: (ctx: ScenarioContextSnapshot<TPhase>) => boolean; // Optional custom validation
|
||||
}
|
||||
|
||||
export interface PhaseTimings {
|
||||
endTimeISO: string; // When the phase completed
|
||||
durationMs: number; // Duration from scenario start to phase completion
|
||||
}
|
||||
|
||||
export interface ScenarioContextSnapshot<TPhase extends string = MetricPhase> {
|
||||
scenario: MetricScenario;
|
||||
startTimeISO: string; // Human-readable ISO timestamp
|
||||
endTimeISO: string; // Human-readable end timestamp
|
||||
durationMs: number; // Total scenario duration from start to end
|
||||
completed: TPhase[]; // Array for JSON serialization
|
||||
failedPhases?: TPhase[]; // Phases that failed
|
||||
timedOut: boolean;
|
||||
vitals?: WebVitals;
|
||||
phaseTimings?: Record<string, PhaseTimings>; // Start/end times for each phase
|
||||
}
|
||||
Reference in New Issue
Block a user