UNPKG

3.31 kBTypeScriptView Raw
1/**
2 * Copyright 2019, OpenCensus Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { LabelKey, LabelValue, Metric, MetricDescriptorType, Timestamp } from '../export/types';
17import { Meter } from '../types';
18import { AccessorInterface } from '../types';
19/**
20 * DerivedCumulative metric is used to record aggregated metrics that
21 * represents a single numerical value accumulated over a time interval.
22 */
23export declare class DerivedCumulative implements Meter {
24 readonly constantLabels: Map<LabelKey, LabelValue>;
25 private metricDescriptor;
26 private labelKeysLength;
27 private registeredPoints;
28 private extractor?;
29 private readonly constantLabelValues;
30 private startTime;
31 /**
32 * Constructs a new DerivedCumulative instance.
33 *
34 * @param name The name of the metric.
35 * @param description The description of the metric.
36 * @param unit The unit of the metric.
37 * @param type The type of metric.
38 * @param labelKeys The list of the label keys.
39 * @param constantLabels The map of constant labels for the Metric.
40 * @param startTime The time when the cumulative metric start measuring the
41 * value.
42 */
43 constructor(name: string, description: string, unit: string, type: MetricDescriptorType, labelKeys: LabelKey[], constantLabels: Map<LabelKey, LabelValue>, startTime: Timestamp);
44 /**
45 * Creates a TimeSeries. The value of a single point in the TimeSeries is
46 * observed from an object or function. The ValueExtractor is invoked whenever
47 * metrics are collected, meaning the reported value is up-to-date.
48 *
49 * @param labelValues The list of the label values.
50 * @param objOrFn obj The obj to get the size or length or value from. If
51 * multiple options are available, the value (ToValueInterface) takes
52 * precedence first, followed by length and size. e.g value -> length ->
53 * size.
54 * fn is the function that will be called to get the current value
55 * of the cumulative.
56 */
57 createTimeSeries(labelValues: LabelValue[], objOrFn: AccessorInterface): void;
58 /**
59 * Removes the TimeSeries from the cumulative metric, if it is present. i.e.
60 * references to previous Point objects are invalid (not part of the
61 * metric).
62 *
63 * @param labelValues The list of label values.
64 */
65 removeTimeSeries(labelValues: LabelValue[]): void;
66 /**
67 * Removes all TimeSeries from the cumulative metric. i.e. references to all
68 * previous Point objects are invalid (not part of the metric).
69 */
70 clear(): void;
71 /**
72 * Provides a Metric with one or more TimeSeries.
73 *
74 * @returns The Metric, or null if TimeSeries is not present in Metric.
75 */
76 getMetric(): Metric | null;
77}