metrics.d.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. declare type MetricType = 'timer' | 'synthetic';
  2. export declare type MetricValue = number | undefined;
  3. export declare const METRIC_TYPE_TIMER = "timer";
  4. export declare const METRIC_TYPE_SYNTHETIC = "synthetic";
  5. export declare abstract class MetricInstance {
  6. abstract getValue(): MetricValue;
  7. }
  8. export declare class TimerMetricInstance extends MetricInstance {
  9. startTimeMs: number;
  10. endTimeMs: number;
  11. metricTag: string;
  12. /**
  13. * Creates a new TimerMetricInstance
  14. * @param metricTag used for logging to identify the metric
  15. */
  16. constructor(metricTag: string);
  17. getValue(): MetricValue;
  18. start(): void;
  19. stop(): void;
  20. }
  21. export declare class SyntheticMetricInstance extends MetricInstance {
  22. private value;
  23. setValue(value: number): void;
  24. getValue(): number;
  25. }
  26. export declare abstract class Metric {
  27. name: string;
  28. context: string;
  29. metricType: MetricType;
  30. protected instances: Array<MetricInstance>;
  31. clear(): void;
  32. getValues(): number[];
  33. getTotal(): number;
  34. constructor(name: string, metricType: MetricType, context: string);
  35. }
  36. export declare class TimerMetric extends Metric {
  37. createInstance(): TimerMetricInstance;
  38. }
  39. export declare class SyntheticMetric extends Metric {
  40. createInstance(): SyntheticMetricInstance;
  41. }
  42. export declare class MetricsCollector {
  43. static NETWORK_TIME: TimerMetric;
  44. static CPU_TIME: SyntheticMetric;
  45. static getAllMetrics(): any[];
  46. }
  47. export {};