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

Method add_sample

prometheus_client/metrics_core.py:35–39  ·  view source on GitHub ↗

Add a sample to the metric. Internal-only, do not use.

(self, name: str, labels: Dict[str, str], value: float, timestamp: Optional[Union[Timestamp, float]] = None, exemplar: Optional[Exemplar] = None, native_histogram: Optional[NativeHistogram] = None)

Source from the content-addressed store, hash-verified

33 self.samples: List[Sample] = []
34
35 def add_sample(self, name: str, labels: Dict[str, str], value: float, timestamp: Optional[Union[Timestamp, float]] = None, exemplar: Optional[Exemplar] = None, native_histogram: Optional[NativeHistogram] = None) -> None:
36 """Add a sample to the metric.
37
38 Internal-only, do not use."""
39 self.samples.append(Sample(name, labels, value, timestamp, exemplar, native_histogram))
40
41 def __eq__(self, other: object) -> bool:
42 return (isinstance(other, Metric)

Callers 15

_read_metricsMethod · 0.95
_target_info_metricMethod · 0.95
collectMethod · 0.95
test_no_metadataMethod · 0.95
collectMethod · 0.95
test_no_metadataMethod · 0.95
collectMethod · 0.80
test_native_histogramMethod · 0.80

Calls 1

SampleClass · 0.85

Tested by 15

collectMethod · 0.76
test_no_metadataMethod · 0.76
collectMethod · 0.76
test_no_metadataMethod · 0.76
test_native_histogramMethod · 0.64
test_nh_longer_spansMethod · 0.64