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
Adds constructor parameter tables, method documentation, and runnable
real-world examples for Counter, Gauge, Histogram, Summary, Info, and
Enum. The _index.md quick-pick table now covers all six types. Also
fixes labels.md which was missing remove(), remove_by_labels(), and
clear() -- the metric pages were already linking to it for those methods.
Closes#1021
Signed-off-by: k1chik <107162115+k1chik@users.noreply.github.com>
|`unit`|`str`|`''`| Optional unit suffix appended to the metric name. |
37
+
|`registry`|`CollectorRegistry`|`REGISTRY`| Registry to register with. Pass `None` to skip registration, which is useful in tests where you create metrics without wanting them in the global registry. |
38
+
39
+
`namespace`, `subsystem`, and `name` are joined with underscores to form the full metric name:
Copy file name to clipboardExpand all lines: docs/content/instrumenting/enum.md
+86-2Lines changed: 86 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,95 @@ title: Enum
3
3
weight: 6
4
4
---
5
5
6
-
Enum tracks which of a set of states something is currently in.
6
+
Enum tracks which of a fixed set of states something is currently in. Only one state is active at a time. Use it for things like task state machines or lifecycle phases.
7
7
8
8
```python
9
9
from prometheus_client import Enum
10
10
e = Enum('my_task_state', 'Description of enum',
11
11
states=['starting', 'running', 'stopped'])
12
12
e.state('running')
13
-
```
13
+
```
14
+
15
+
Enum exposes one time series per state:
16
+
-`<name>{<name>="<state>"}` — 1 if this is the current state, 0 otherwise
17
+
18
+
The first listed state is the default.
19
+
20
+
Note: Enum metrics do not work in multiprocess mode.
|`documentation`|`str`| required | Help text shown in the `/metrics` output and Prometheus UI. |
32
+
|`labelnames`|`Iterable[str]`|`()`| Names of labels for this metric. See [Labels](../labels/). The metric name itself cannot be used as a label name. |
|`unit`|`str`|`''`| Not supported — raises `ValueError`. Enum metrics cannot have a unit. |
36
+
|`registry`|`CollectorRegistry`|`REGISTRY`| Registry to register with. Pass `None` to skip registration, which is useful in tests where you create metrics without wanting them in the global registry. |
37
+
|`states`|`List[str]`| required | The complete list of valid states. Must be non-empty. The first entry is the initial state. |
38
+
39
+
`namespace`, `subsystem`, and `name` are joined with underscores to form the full metric name:
0 commit comments