UNPKG

1.81 kBTypeScriptView Raw
1import { IMetric } from '../metric-types';
2/**
3 * Return the JSON structure which represents these metrics in a graph.
4 *
5 * Depending on the metric type (stat or expression), one `Metric` object
6 * can render to multiple time series.
7 *
8 * - Top-level metrics will be rendered visibly, additionally added metrics will
9 * be rendered invisibly.
10 * - IDs used in math expressions need to be either globally unique, or refer to the same
11 * metric object.
12 *
13 * This will be called by GraphWidget, no need for clients to call this.
14 */
15export declare function allMetricsGraphJson(left: IMetric[], right: IMetric[]): any[];
16/**
17 * A single metric in a MetricSet
18 */
19export interface MetricEntry<A> {
20 /**
21 * The metric object
22 */
23 readonly metric: IMetric;
24 /**
25 * The tag, added if the object is a primary metric
26 */
27 tag?: A;
28 /**
29 * ID for this metric object
30 */
31 id?: string;
32}
33/**
34 * Contain a set of metrics, expanding math expressions
35 *
36 * "Primary" metrics (added via a top-level call) can be tagged with an additional value.
37 */
38export declare class MetricSet<A> {
39 private readonly metrics;
40 private readonly metricById;
41 private readonly metricByKey;
42 /**
43 * Add the given set of metrics to this set
44 */
45 addTopLevel(tag: A, ...metrics: IMetric[]): void;
46 /**
47 * Access all the accumulated timeseries entries
48 */
49 get entries(): ReadonlyArray<MetricEntry<A>>;
50 /**
51 * Add a metric into the set
52 *
53 * The id may not be the same as a previous metric added, unless it's the same metric.
54 *
55 * It can be made visible, in which case the new "metric" object replaces the old
56 * one (and the new ones "renderingPropertieS" will be honored instead of the old
57 * one's).
58 */
59 private addOne;
60}