@bonginkan/maria
Version:
MARIA OS v5.9.5 – Self-Evolving Organizational Intelligence OS | Speed Improvement Phase 3: LLM Optimization + Command Refactoring | Performance Measurement + Run Evidence System | Zero ESLint/TypeScript Errors | 人とAIが役割を持ち、学び、進化し続けるための仕事のOS | GraphRAG ×
83 lines (82 loc) • 2.64 kB
TypeScript
import { EventEmitter } from "node:events";
export type MetricType = "counter" | "gauge" | "histogram" | "summary";
export interface MetricDefinition {
name: string;
type: MetricType;
help: string;
labels?: string[];
buckets?: number[];
percentiles?: number[];
aggregation?: "_sum" | "avg" | "max" | "min" | "last";
}
export interface CustomMetricValue {
value: number;
labels?: Record<string, string>;
timestamp?: number;
}
export interface MetricSnapshot {
name: string;
type: MetricType;
values: CustomMetricValue[];
statistics?: {
count: number;
_sum: number;
mean: number;
min: number;
max: number;
p50?: number;
p95?: number;
p99?: number;
};
}
export declare class CustomMetricsFramework extends EventEmitter {
private metrics;
private definitions;
private snapshots;
private aggregators;
private flushInterval;
private flushTimer?;
private maxSnapshotSize;
constructor(config?: {
flushInterval?: number;
maxSnapshotSize?: number;
});
private initializeAggregators;
private startFlushTimer;
registerMetric(definition: MetricDefinition): void;
recordValue(metricName: string, value: CustomMetricValue): void;
increment(metricName: string, amount?: number, labels?: Record<string, string>): void;
gauge(metricName: string, value: number, labels?: Record<string, string>): void;
observe(metricName: string, value: number, labels?: Record<string, string>): void;
getSnapshot(metricName: string): MetricSnapshot | undefined;
private calculateStatistics;
private percentile;
aggregate(metricName: string, windowMs?: number): number | undefined;
query(options: {
metric?: string;
labels?: Record<string, string>;
startTime?: number;
endTime?: number;
aggregation?: string;
}): CustomMetricValue[];
createDerivedMetric(options: {
name: string;
help: string;
sourceMetrics: string[];
calculation: (values: Record<string, number>) => number;
type?: MetricType;
}): void;
registerAlert(options: {
metric: string;
condition: (value: number) => boolean;
message: string;
severity?: "info" | "warning" | "error" | "critical";
cooldown?: number;
}): void;
export(format?: "json" | "prometheus" | "csv"): string;
private exportPrometheus;
private exportCSV;
private flush;
dispose(): void;
}
export declare function getCustomMetricsFramework(): CustomMetricsFramework;