You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 3, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: metrics/Gauge.md
+23-11Lines changed: 23 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,14 @@ The `Gauge` values can be negative. This document describes the key types and th
8
8
The value that is published for gauges is an instantaneous measurement of an `int64` or `double` value. This API is useful when you want to manually increase and decrease values as per service requirements.
9
9
10
10
The following general operations MUST be provided by the API:
11
-
* Defining a `name`, `description`, `unit`, `labelKeys` and `constantLabels` which are fixed labels that always apply to a gauge. This should give back the gauge object to get or create time series, remove time series and clear all time series.
11
+
* Defining a `name`, `description`, `unit`, `labelKeys`, `resource` and `constantLabels` which are fixed labels that always apply to a gauge. This should give back the gauge object to get or create time series, remove time series and clear all time series.
12
12
* `name`: a string describing the name of the metric, e.g. "vm_cpu_cycles" or "queue_size". Names MUST be unique within the library. It is recommended to use names compatible with the intended end usage.
13
13
* `description`: a string describing the metric, e.g."Virtual cycles executed on VM".
14
-
* `unit`: a string describing the unit used for the metric. Follows the format described by
14
+
* `unit`: a string describing the unit used for the metric (default set to "1"). Follows the format described by
15
15
[Unified Code for Units of Measure](http://unitsofmeasure.org/ucum.html).
16
16
* `labelKeys`: the list of the label keys to track different types of metric.
17
-
* `constantLabels`: the map of label keys and label values.
17
+
* `constantLabels`: the map of label keys and label values. The keys in `labelKeys` should not be the same as `constantLabels`'s keys.
18
+
* `resource`: the optional associated monitored resource information.
18
19
* Add a new time series with label values, which returns a `Point` (which is part of the `TimeSeries`). Each point represents an instantaneous measurement of a varying gauge value. Each Gauge Metric has one or more time series for a single metric.
19
20
* `labelValues`: the list of label values. The number of label values must be the same to that of the label keys.
20
21
* The `Point` class should provide functionalities to manually increment/decrement values. Example: `add(long amt)`, `set(long value)`.
LongPoint point = gauge.getOrCreateTimeSeries(labelValues);
35
42
36
43
void doSomeWork() {
@@ -44,16 +51,17 @@ It is recommended to keep a reference of a point for manual operations instead o
44
51
The value that is published for gauges is an instantaneous measurement of an `int64` or `double` value. This gauge is self sufficient once created, so users should never need to interact with it. The value of the gauge is observed from the `object` and a `callback function`. The callback function is invoked whenever metrics are collected, meaning the reported value is up-to-date. The implementation should keep a `WeakReference` to the object and it is the user's responsibility to manage the lifetime of the object.
45
52
46
53
The following general operations MUST be provided by the API:
47
-
* Defining a `name`, `description`, `unit`, `labelKeys` and `constantLabels` which are fixed labels that always apply to a gauge. This should give back gauge object to add new time series, remove time series and clear all time series.
54
+
* Defining a `name`, `description`, `unit`, `labelKeys`, `resource` and `constantLabels` which are fixed labels that always apply to a gauge. This should give back gauge object to add new time series, remove time series and clear all time series.
48
55
* `name`: a string describing the name of the metric, e.g. "vm_cpu_cycles". Names MUST be unique within the library. It is recommended to use names compatible with the intended end usage.
49
56
* `description`: a string describing the metric, e.g."Virtual cycles executed on VM".
50
-
* `unit`: a string describing the unit used for the metric. Follows the format described by
57
+
* `unit`: a string describing the unit used for the metric (default set to "1"). Follows the format described by
51
58
[Unified Code for Units of Measure](http://unitsofmeasure.org/ucum.html).
52
59
* `labelKeys`: the list of the label keys to track different types of metric.
53
-
* `constantLabels`: the map of label keys and label values.
60
+
* `constantLabels`: the map of label keys and label values. The keys in `labelKeys` should not be the same as `constantLabels`'s keys.
61
+
* `resource`: the optional associated monitored resource information.
54
62
* Add a new time series with label values, an `object` and a `callback function`. The number of label values must be the same to that of the label keys.
55
63
* `labelValues`: the list of label values. The number of label values must be the same to that of the label keys.
56
-
* `obj`: the state object from which the function derives a measurement.
64
+
* `object`: the state object from which the function derives a measurement.
57
65
* `function`: the callback function to be called.
58
66
* Remove a single time series from the gauge metric, if it is present.
0 commit comments