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

Class InfoMetricFamily

prometheus_client/metrics_core.py:335–372  ·  view source on GitHub ↗

A single info and its samples. For use by custom collectors.

Source from the content-addressed store, hash-verified

333
334
335class InfoMetricFamily(Metric):
336 """A single info and its samples.
337
338 For use by custom collectors.
339 """
340
341 def __init__(self,
342 name: str,
343 documentation: str,
344 value: Optional[Dict[str, str]] = None,
345 labels: Optional[Sequence[str]] = None,
346 ):
347 Metric.__init__(self, name, documentation, 'info')
348 if labels is not None and value is not None:
349 raise ValueError('Can only specify at most one of value and labels.')
350 if labels is None:
351 labels = []
352 self._labelnames = tuple(labels)
353 if value is not None:
354 self.add_metric([], value)
355
356 def add_metric(self,
357 labels: Sequence[str],
358 value: Dict[str, str],
359 timestamp: Optional[Union[Timestamp, float]] = None,
360 ) -> None:
361 """Add a metric to the metric family.
362
363 Args:
364 labels: A list of label values
365 value: A dict of labels
366 """
367 self.samples.append(Sample(
368 self.name + '_info',
369 dict(dict(zip(self._labelnames, labels)), **value),
370 1,
371 timestamp,
372 ))
373
374
375class StateSetMetricFamily(Metric):

Callers 4

test_infoMethod · 0.90
test_info_labelsMethod · 0.90
test_simple_infoMethod · 0.90
test_info_timestampsMethod · 0.90

Calls

no outgoing calls

Tested by 4

test_infoMethod · 0.72
test_info_labelsMethod · 0.72
test_simple_infoMethod · 0.72
test_info_timestampsMethod · 0.72