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

Method add_metric

prometheus_client/metrics_core.py:129–145  ·  view source on GitHub ↗

Add a metric to the metric family. Args: labels: A list of label values value: The value of the metric created: Optional unix timestamp the child was created at.

(self,
                   labels: Sequence[str],
                   value: float,
                   created: Optional[float] = None,
                   timestamp: Optional[Union[Timestamp, float]] = None,
                   exemplar: Optional[Exemplar] = None,
                   )

Source from the content-addressed store, hash-verified

127 self.add_metric([], value, created, exemplar=exemplar)
128
129 def add_metric(self,
130 labels: Sequence[str],
131 value: float,
132 created: Optional[float] = None,
133 timestamp: Optional[Union[Timestamp, float]] = None,
134 exemplar: Optional[Exemplar] = None,
135 ) -> None:
136 """Add a metric to the metric family.
137
138 Args:
139 labels: A list of label values
140 value: The value of the metric
141 created: Optional unix timestamp the child was created at.
142 """
143 self.samples.append(Sample(self.name + '_total', dict(zip(self._labelnames, labels)), value, timestamp, exemplar))
144 if created is not None:
145 self.samples.append(Sample(self.name + '_created', dict(zip(self._labelnames, labels)), created, timestamp))
146
147
148class GaugeMetricFamily(Metric):

Callers 15

collectMethod · 0.95
__init__Method · 0.95
test_spacesMethod · 0.95
test_commasMethod · 0.95
test_empty_labelMethod · 0.95
test_label_escapingMethod · 0.95
test_help_escapingMethod · 0.95
test_escapingMethod · 0.95
test_timestampsMethod · 0.95
test_counter_labelsMethod · 0.95

Calls 1

SampleClass · 0.85

Tested by 15

test_spacesMethod · 0.76
test_commasMethod · 0.76
test_empty_labelMethod · 0.76
test_label_escapingMethod · 0.76
test_help_escapingMethod · 0.76
test_escapingMethod · 0.76
test_timestampsMethod · 0.76
test_counter_labelsMethod · 0.76