UNPKG

4.17 kBTypeScriptView Raw
1/**
2 * Copyright 2018, 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, TimeSeries, Timestamp } from '../export/types';
17import { Meter } from '../types';
18import * as types from './types';
19/**
20 * Gauge metric
21 */
22export declare class Gauge implements Meter {
23 readonly labelKeys: LabelKey[];
24 readonly constantLabels: Map<LabelKey, LabelValue>;
25 private readonly metricDescriptor;
26 private labelKeysLength;
27 private defaultLabelValues;
28 private registeredPoints;
29 private readonly constantLabelValues;
30 private static readonly LABEL_VALUE;
31 private static readonly LABEL_VALUES;
32 private static readonly ERROR_MESSAGE_INVALID_SIZE;
33 /**
34 * Constructs a new Gauge instance.
35 *
36 * @param name The name of the metric.
37 * @param description The description of the metric.
38 * @param unit The unit of the metric.
39 * @param type The type of metric.
40 * @param labelKeys The list of the label keys.
41 * @param constantLabels The map of constant labels for the Metric.
42 */
43 constructor(name: string, description: string, unit: string, type: MetricDescriptorType, labelKeys: LabelKey[], constantLabels: Map<LabelKey, LabelValue>);
44 /**
45 * Creates a TimeSeries and returns a Point if the specified
46 * labelValues is not already associated with this gauge, else returns an
47 * existing Point.
48 *
49 * It is recommended to keep a reference to the Point instead of always
50 * calling this method for manual operations.
51 *
52 * @param labelValues The list of the label values.
53 * @returns The value of single gauge.
54 */
55 getOrCreateTimeSeries(labelValues: LabelValue[]): types.Point;
56 /**
57 * Returns a Point for a gauge with all labels not set, or default
58 * labels.
59 *
60 * @returns The value of single gauge.
61 */
62 getDefaultTimeSeries(): types.Point;
63 /**
64 * Removes the TimeSeries from the gauge metric, if it is present. i.e.
65 * references to previous Point objects are invalid (not part of the
66 * metric).
67 *
68 * @param labelValues The list of label values.
69 */
70 removeTimeSeries(labelValues: LabelValue[]): void;
71 /**
72 * Removes all TimeSeries from the gauge metric. i.e. references to all
73 * previous Point objects are invalid (not part of the metric).
74 */
75 clear(): void;
76 /**
77 * Registers a TimeSeries and returns a Point if the specified
78 * labelValues is not already associated with this gauge, else returns an
79 * existing Point.
80 *
81 * @param labelValues The list of the label values.
82 * @returns The value of single gauge.
83 */
84 private registerTimeSeries;
85 /**
86 * Provides a Metric with one or more TimeSeries.
87 *
88 * @returns The Metric, or null if TimeSeries is not present in Metric.
89 */
90 getMetric(): Metric | null;
91}
92/**
93 * The value of a single point in the Gauge.TimeSeries.
94 */
95export declare class PointEntry implements types.Point {
96 private readonly labelValues;
97 private value;
98 constructor(labelValues: LabelValue[]);
99 /**
100 * Adds the given value to the current value. The values can be negative.
101 *
102 * @param amt The value to add.
103 */
104 add(amt: number): void;
105 /**
106 * Sets the given value.
107 *
108 * @param val The new value.
109 */
110 set(val: number): void;
111 /**
112 * Returns the TimeSeries with one or more Point.
113 *
114 * @param timestamp The time at which the gauge is recorded.
115 * @returns The TimeSeries.
116 */
117 getTimeSeries(timestamp: Timestamp): TimeSeries;
118}