MCPcopy Create free account
hub / github.com/prometheus/client_python / _get_names

Method _get_names

prometheus_client/registry.py:59–86  ·  view source on GitHub ↗

Get names of timeseries the collector produces and clashes with.

(self, collector)

Source from the content-addressed store, hash-verified

57 del self._collector_to_names[collector]
58
59 def _get_names(self, collector):
60 """Get names of timeseries the collector produces and clashes with."""
61 desc_func = None
62 # If there's a describe function, use it.
63 try:
64 desc_func = collector.describe
65 except AttributeError:
66 pass
67 # Otherwise, if auto describe is enabled use the collect function.
68 if not desc_func and self._auto_describe:
69 desc_func = collector.collect
70
71 if not desc_func:
72 return []
73
74 result = []
75 type_suffixes = {
76 'counter': ['_total', '_created'],
77 'summary': ['_sum', '_count', '_created'],
78 'histogram': ['_bucket', '_sum', '_count', '_created'],
79 'gaugehistogram': ['_bucket', '_gsum', '_gcount'],
80 'info': ['_info'],
81 }
82 for metric in desc_func():
83 result.append(metric.name)
84 for suffix in type_suffixes.get(metric.type, []):
85 result.append(metric.name + suffix)
86 return result
87
88 def collect(self) -> Iterable[Metric]:
89 """Yields metrics from the collectors in the registry."""

Callers 1

registerMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected