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

Method test_timestamps

tests/test_parser.py:302–316  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

300 self.assertEqualMetrics([metric_family], list(families))
301
302 def test_timestamps(self):
303 families = text_string_to_metric_families("""# TYPE a counter
304# HELP a help
305a{foo="bar"} 1\t000
306# TYPE b counter
307# HELP b help
308b 2 1234567890
309b 88 1234566000
310""")
311 a = CounterMetricFamily("a", "help", labels=["foo"])
312 a.add_metric(["bar"], 1, timestamp=0)
313 b = CounterMetricFamily("b", "help")
314 b.add_metric([], 2, timestamp=1234567.89)
315 b.add_metric([], 88, timestamp=1234566)
316 self.assertEqualMetrics([a, b], list(families))
317
318 def test_roundtrip(self):
319 text = """# HELP go_gc_duration_seconds A summary of the GC invocation durations.

Callers

nothing calls this directly

Calls 4

add_metricMethod · 0.95
assertEqualMetricsMethod · 0.95
CounterMetricFamilyClass · 0.90

Tested by

no test coverage detected