MCPcopy Index your code
hub / github.com/prometheus/client_python / get_sample_value

Method get_sample_value

prometheus_client/registry.py:133–144  ·  view source on GitHub ↗

Returns the sample value, or None if not found. This is inefficient, and intended only for use in unittests.

(self, name: str, labels: Optional[Dict[str, str]] = None)

Source from the content-addressed store, hash-verified

131 return m
132
133 def get_sample_value(self, name: str, labels: Optional[Dict[str, str]] = None) -> Optional[float]:
134 """Returns the sample value, or None if not found.
135
136 This is inefficient, and intended only for use in unittests.
137 """
138 if labels is None:
139 labels = {}
140 for metric in self.collect():
141 for s in metric.samples:
142 if s.name == name and s.labels == labels:
143 return s.value
144 return None
145
146
147class RestrictedRegistry:

Callers 15

test_workingMethod · 0.80
test_emptyMethod · 0.80
test_workingMethod · 0.80
test_namespaceMethod · 0.80
test_working_584Method · 0.80
test_working_fake_pidMethod · 0.80
test_counter_addsMethod · 0.80
test_summary_addsMethod · 0.80
test_histogram_addsMethod · 0.80
test_gauge_allMethod · 0.80
test_gauge_liveallMethod · 0.80

Calls 1

collectMethod · 0.95

Tested by 15

test_workingMethod · 0.64
test_emptyMethod · 0.64
test_workingMethod · 0.64
test_namespaceMethod · 0.64
test_working_584Method · 0.64
test_working_fake_pidMethod · 0.64
test_counter_addsMethod · 0.64
test_summary_addsMethod · 0.64
test_histogram_addsMethod · 0.64
test_gauge_allMethod · 0.64
test_gauge_liveallMethod · 0.64