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

Method test_roundtrip

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

Source from the content-addressed store, hash-verified

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.
320# TYPE go_gc_duration_seconds summary
321go_gc_duration_seconds{quantile="0"} 0.013300656000000001
322go_gc_duration_seconds{quantile="0.25"} 0.013638736
323go_gc_duration_seconds{quantile="0.5"} 0.013759906
324go_gc_duration_seconds{quantile="0.75"} 0.013962066
325go_gc_duration_seconds{quantile="1"} 0.021383540000000003
326go_gc_duration_seconds_sum 56.12904785
327go_gc_duration_seconds_count 7476.0
328# HELP go_goroutines Number of goroutines that currently exist.
329# TYPE go_goroutines gauge
330go_goroutines 166.0
331# HELP prometheus_local_storage_indexing_batch_duration_milliseconds Quantiles for batch indexing duration in milliseconds.
332# TYPE prometheus_local_storage_indexing_batch_duration_milliseconds summary
333prometheus_local_storage_indexing_batch_duration_milliseconds{quantile="0.5"} NaN
334prometheus_local_storage_indexing_batch_duration_milliseconds{quantile="0.9"} NaN
335prometheus_local_storage_indexing_batch_duration_milliseconds{quantile="0.99"} NaN
336prometheus_local_storage_indexing_batch_duration_milliseconds_sum 871.5665949999999
337prometheus_local_storage_indexing_batch_duration_milliseconds_count 229.0
338# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
339# TYPE process_cpu_seconds_total counter
340process_cpu_seconds_total 29323.4
341# HELP process_virtual_memory_bytes Virtual memory size in bytes.
342# TYPE process_virtual_memory_bytes gauge
343process_virtual_memory_bytes 2.478268416e+09
344# HELP prometheus_build_info A metric with a constant '1' value labeled by version, revision, and branch from which Prometheus was built.
345# TYPE prometheus_build_info gauge
346prometheus_build_info{branch="HEAD",revision="ef176e5",version="0.16.0rc1"} 1.0
347# HELP prometheus_local_storage_chunk_ops_total The total number of chunk operations by their type.
348# TYPE prometheus_local_storage_chunk_ops_total counter
349prometheus_local_storage_chunk_ops_total{type="clone"} 28.0
350prometheus_local_storage_chunk_ops_total{type="create"} 997844.0
351prometheus_local_storage_chunk_ops_total{type="drop"} 1.345758e+06
352prometheus_local_storage_chunk_ops_total{type="load"} 1641.0
353prometheus_local_storage_chunk_ops_total{type="persist"} 981408.0
354prometheus_local_storage_chunk_ops_total{type="pin"} 32662.0
355prometheus_local_storage_chunk_ops_total{type="transcode"} 980180.0
356prometheus_local_storage_chunk_ops_total{type="unpin"} 32662.0
357# HELP "my.utf8.metric.#{}=" A fancy metric with dots.
358# TYPE "my.utf8.metric.#{}=" summary
359{"my.utf8.metric.#{}=",quantile="0"} 0.013300656000000001
360{"my.utf8.metric.#{}=",quantile="0.25"} 0.013638736
361{"my.utf8.metric.#{}=",quantile="0.5"} 0.013759906
362{"my.utf8.metric.#{}=",quantile="0.75"} 0.013962066
363{"my.utf8.metric.#{}=",quantile="1"} 0.021383540000000003
364{"my.utf8.metric.#{}=_sum"} 56.12904785
365{"my.utf8.metric.#{}=_count"} 7476.0
366"""
367 families = list(text_string_to_metric_families(text))
368
369 class TextCollector:
370 def collect(self):
371 return families
372
373 registry = CollectorRegistry()
374 registry.register(TextCollector())
375 self.assertEqual(text.encode('utf-8'), generate_latest(registry, ALLOWUTF8))

Callers

nothing calls this directly

Calls 5

registerMethod · 0.95
generate_latestFunction · 0.90
CollectorRegistryClass · 0.85
TextCollectorClass · 0.70

Tested by

no test coverage detected