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

Method test_timestamp

tests/test_exposition.py:198–219  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

196 generate_latest(self.registry))
197
198 def test_timestamp(self):
199 class MyCollector:
200 def collect(self):
201 metric = Metric("ts", "help", 'untyped')
202 metric.add_sample("ts", {"foo": "a"}, 0, 123.456)
203 metric.add_sample("ts", {"foo": "b"}, 0, -123.456)
204 metric.add_sample("ts", {"foo": "c"}, 0, 123)
205 metric.add_sample("ts", {"foo": "d"}, 0, Timestamp(123, 456000000))
206 metric.add_sample("ts", {"foo": "e"}, 0, Timestamp(123, 456000))
207 metric.add_sample("ts", {"foo": "f"}, 0, Timestamp(123, 456))
208 yield metric
209
210 self.registry.register(MyCollector())
211 self.assertEqual(b"""# HELP ts help
212# TYPE ts untyped
213ts{foo="a"} 0.0 123456
214ts{foo="b"} 0.0 -123456
215ts{foo="c"} 0.0 123000
216ts{foo="d"} 0.0 123456
217ts{foo="e"} 0.0 123000
218ts{foo="f"} 0.0 123000
219""", generate_latest(self.registry))
220
221
222class TestPushGateway(unittest.TestCase):

Callers

nothing calls this directly

Calls 3

generate_latestFunction · 0.90
MyCollectorClass · 0.70
registerMethod · 0.45

Tested by

no test coverage detected