UNPKG

3.32 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 } from '../export/types';
17import * as types from '../types';
18import { AccessorInterface } from '../types';
19/**
20 * DerivedGauge metric
21 */
22export declare class DerivedGauge implements types.Meter {
23 readonly constantLabels: Map<LabelKey, LabelValue>;
24 private metricDescriptor;
25 private labelKeysLength;
26 private registeredPoints;
27 private extractor?;
28 private readonly constantLabelValues;
29 private static readonly LABEL_VALUE;
30 private static readonly LABEL_VALUES;
31 private static readonly OBJECT;
32 private static readonly ERROR_MESSAGE_INVALID_SIZE;
33 private static readonly ERROR_MESSAGE_DUPLICATE_TIME_SERIES;
34 private static readonly ERROR_MESSAGE_UNKNOWN_INTERFACE;
35 /**
36 * Constructs a new DerivedGauge instance.
37 *
38 * @param name The name of the metric.
39 * @param description The description of the metric.
40 * @param unit The unit of the metric.
41 * @param type The type of metric.
42 * @param labelKeys The list of the label keys.
43 * @param constantLabels The map of constant labels for the Metric.
44 */
45 constructor(name: string, description: string, unit: string, type: MetricDescriptorType, labelKeys: LabelKey[], constantLabels: Map<LabelKey, LabelValue>);
46 /**
47 * Creates a TimeSeries. The value of a single point in the TimeSeries is
48 * observed from a obj or a function. The ValueExtractor is invoked whenever
49 * metrics are collected, meaning the reported value is up-to-date.
50 *
51 * @param labelValues The list of the label values.
52 * @param objOrFn obj The obj to get the size or length or value from. If
53 * multiple options are available, the value (ToValueInterface) takes
54 * precedence first, followed by length and size. e.g value -> length ->
55 * size.
56 * fn is the function that will be called to get the current value
57 * of the gauge.
58 */
59 createTimeSeries(labelValues: LabelValue[], objOrFn: AccessorInterface): void;
60 /**
61 * Removes the TimeSeries from the gauge metric, if it is present. i.e.
62 * references to previous Point objects are invalid (not part of the
63 * metric).
64 *
65 * @param labelValues The list of label values.
66 */
67 removeTimeSeries(labelValues: LabelValue[]): void;
68 /**
69 * Removes all TimeSeries from the gauge metric. i.e. references to all
70 * previous Point objects are invalid (not part of the metric).
71 */
72 clear(): void;
73 /**
74 * Provides a Metric with one or more TimeSeries.
75 *
76 * @returns The Metric, or null if TimeSeries is not present in Metric.
77 */
78 getMetric(): Metric | null;
79}