@@ -98,50 +98,50 @@ def test_summary_quantiles(self):
9898 def test_simple_histogram (self ):
9999 families = text_string_to_metric_families ("""# TYPE a histogram
100100# HELP a help
101- a_bucket{le="1"} 0
101+ a_bucket{le="1.0 "} 0
102102a_bucket{le="+Inf"} 3
103103a_count 3
104104a_sum 2
105105# EOF
106106""" )
107- self .assertEqual ([HistogramMetricFamily ("a" , "help" , sum_value = 2 , buckets = [("1" , 0.0 ), ("+Inf" , 3.0 )])], list (families ))
107+ self .assertEqual ([HistogramMetricFamily ("a" , "help" , sum_value = 2 , buckets = [("1.0 " , 0.0 ), ("+Inf" , 3.0 )])], list (families ))
108108
109109 def test_histogram_exemplars (self ):
110110 families = text_string_to_metric_families ("""# TYPE a histogram
111111# HELP a help
112- a_bucket{le="1"} 0 # {a="b"} 0.5
113- a_bucket{le="2"} 2 # {a="c"} 0.5
112+ a_bucket{le="1.0 "} 0 # {a="b"} 0.5
113+ a_bucket{le="2.0 "} 2 # {a="c"} 0.5
114114a_bucket{le="+Inf"} 3 # {a="1234567890123456789012345678901234567890123456789012345678"} 4 123
115115# EOF
116116""" )
117117 hfm = HistogramMetricFamily ("a" , "help" )
118- hfm .add_sample ("a_bucket" , {"le" : "1" }, 0.0 , None , Exemplar ({"a" : "b" }, 0.5 ))
119- hfm .add_sample ("a_bucket" , {"le" : "2" }, 2.0 , None , Exemplar ({"a" : "c" }, 0.5 )),
118+ hfm .add_sample ("a_bucket" , {"le" : "1.0 " }, 0.0 , None , Exemplar ({"a" : "b" }, 0.5 ))
119+ hfm .add_sample ("a_bucket" , {"le" : "2.0 " }, 2.0 , None , Exemplar ({"a" : "c" }, 0.5 )),
120120 hfm .add_sample ("a_bucket" , {"le" : "+Inf" }, 3.0 , None , Exemplar ({"a" : "1234567890123456789012345678901234567890123456789012345678" }, 4 , Timestamp (123 , 0 )))
121121 self .assertEqual ([hfm ], list (families ))
122122
123123 def test_simple_gaugehistogram (self ):
124124 families = text_string_to_metric_families ("""# TYPE a gaugehistogram
125125# HELP a help
126- a_bucket{le="1"} 0
126+ a_bucket{le="1.0 "} 0
127127a_bucket{le="+Inf"} 3
128128a_gcount 3
129129a_gsum 2
130130# EOF
131131""" )
132- self .assertEqual ([GaugeHistogramMetricFamily ("a" , "help" , gsum_value = 2 , buckets = [("1" , 0.0 ), ("+Inf" , 3.0 )])], list (families ))
132+ self .assertEqual ([GaugeHistogramMetricFamily ("a" , "help" , gsum_value = 2 , buckets = [("1.0 " , 0.0 ), ("+Inf" , 3.0 )])], list (families ))
133133
134134 def test_gaugehistogram_exemplars (self ):
135135 families = text_string_to_metric_families ("""# TYPE a gaugehistogram
136136# HELP a help
137- a_bucket{le="1"} 0 123 # {a="b"} 0.5
138- a_bucket{le="2"} 2 123 # {a="c"} 0.5
137+ a_bucket{le="1.0 "} 0 123 # {a="b"} 0.5
138+ a_bucket{le="2.0 "} 2 123 # {a="c"} 0.5
139139a_bucket{le="+Inf"} 3 123 # {a="d"} 4 123
140140# EOF
141141""" )
142142 hfm = GaugeHistogramMetricFamily ("a" , "help" )
143- hfm .add_sample ("a_bucket" , {"le" : "1" }, 0.0 , Timestamp (123 , 0 ), Exemplar ({"a" : "b" }, 0.5 ))
144- hfm .add_sample ("a_bucket" , {"le" : "2" }, 2.0 , Timestamp (123 , 0 ), Exemplar ({"a" : "c" }, 0.5 )),
143+ hfm .add_sample ("a_bucket" , {"le" : "1.0 " }, 0.0 , Timestamp (123 , 0 ), Exemplar ({"a" : "b" }, 0.5 ))
144+ hfm .add_sample ("a_bucket" , {"le" : "2.0 " }, 2.0 , Timestamp (123 , 0 ), Exemplar ({"a" : "c" }, 0.5 )),
145145 hfm .add_sample ("a_bucket" , {"le" : "+Inf" }, 3.0 , Timestamp (123 , 0 ), Exemplar ({"a" : "d" }, 4 , Timestamp (123 , 0 )))
146146 self .assertEqual ([hfm ], list (families ))
147147
@@ -383,11 +383,11 @@ def test_timestamps(self):
383383 def test_roundtrip (self ):
384384 text = """# HELP go_gc_duration_seconds A summary of the GC invocation durations.
385385# TYPE go_gc_duration_seconds summary
386- go_gc_duration_seconds{quantile="0"} 0.013300656000000001
386+ go_gc_duration_seconds{quantile="0.0 "} 0.013300656000000001
387387go_gc_duration_seconds{quantile="0.25"} 0.013638736
388388go_gc_duration_seconds{quantile="0.5"} 0.013759906
389389go_gc_duration_seconds{quantile="0.75"} 0.013962066
390- go_gc_duration_seconds{quantile="1"} 0.021383540000000003
390+ go_gc_duration_seconds{quantile="1.0 "} 0.021383540000000003
391391go_gc_duration_seconds_sum 56.12904785
392392go_gc_duration_seconds_count 7476.0
393393# HELP go_goroutines Number of goroutines that currently exist.
@@ -405,20 +405,36 @@ def test_roundtrip(self):
405405process_cpu_seconds_total 29323.4
406406# HELP process_virtual_memory_bytes Virtual memory size in bytes.
407407# TYPE process_virtual_memory_bytes gauge
408- process_virtual_memory_bytes 2478268416.0
408+ process_virtual_memory_bytes 2.478268416e+09
409409# HELP prometheus_build_info A metric with a constant '1' value labeled by version, revision, and branch from which Prometheus was built.
410410# TYPE prometheus_build_info gauge
411411prometheus_build_info{branch="HEAD",revision="ef176e5",version="0.16.0rc1"} 1.0
412412# HELP prometheus_local_storage_chunk_ops The total number of chunk operations by their type.
413413# TYPE prometheus_local_storage_chunk_ops counter
414414prometheus_local_storage_chunk_ops_total{type="clone"} 28.0
415415prometheus_local_storage_chunk_ops_total{type="create"} 997844.0
416- prometheus_local_storage_chunk_ops_total{type="drop"} 1345758.0
416+ prometheus_local_storage_chunk_ops_total{type="drop"} 1.345758e+06
417417prometheus_local_storage_chunk_ops_total{type="load"} 1641.0
418418prometheus_local_storage_chunk_ops_total{type="persist"} 981408.0
419419prometheus_local_storage_chunk_ops_total{type="pin"} 32662.0
420420prometheus_local_storage_chunk_ops_total{type="transcode"} 980180.0
421421prometheus_local_storage_chunk_ops_total{type="unpin"} 32662.0
422+ # HELP foo histogram Testing histogram buckets
423+ # TYPE foo histogram
424+ foo_bucket{le="0.0"} 0.0
425+ foo_bucket{le="1e-05"} 0.0
426+ foo_bucket{le="0.0001"} 0.0
427+ foo_bucket{le="0.1"} 8.0
428+ foo_bucket{le="1.0"} 10.0
429+ foo_bucket{le="10.0"} 17.0
430+ foo_bucket{le="100000.0"} 17.0
431+ foo_bucket{le="1e+06"} 17.0
432+ foo_bucket{le="1.55555555555552e+06"} 17.0
433+ foo_bucket{le="1e+23"} 17.0
434+ foo_bucket{le="+Inf"} 17.0
435+ foo_count 17.0
436+ foo_sum 324789.3
437+ foo_created 1.520430000123e+09
422438# EOF
423439"""
424440 families = list (text_string_to_metric_families (text ))
@@ -522,6 +538,7 @@ def test_invalid_input(self):
522538 ('# TYPE a summary\n a{quantile="foo"} 0\n # EOF\n ' ),
523539 ('# TYPE a summary\n a{quantile="1.01"} 0\n # EOF\n ' ),
524540 ('# TYPE a summary\n a{quantile="NaN"} 0\n # EOF\n ' ),
541+ ('# TYPE a summary\n a{quantile="1"} 0\n # EOF\n ' ),
525542 ('# TYPE a histogram\n a_bucket 0\n # EOF\n ' ),
526543 ('# TYPE a gaugehistogram\n a_bucket 0\n # EOF\n ' ),
527544 ('# TYPE a stateset\n a 0\n # EOF\n ' ),
@@ -549,6 +566,12 @@ def test_invalid_input(self):
549566 ('# TYPE a gaugehistogram\n a_gsum 1\n # EOF\n ' ),
550567 ('# TYPE a histogram\n a_count 1\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
551568 ('# TYPE a histogram\n a_bucket{le="+Inf"} 0\n a_count 1\n # EOF\n ' ),
569+ ('# TYPE a histogram\n a_bucket{le="1"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
570+ ('# TYPE a histogram\n a_bucket{le="9.999999999999999e+22"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
571+ ('# TYPE a histogram\n a_bucket{le="1.5555555555555201e+06"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
572+ ('# TYPE a histogram\n a_bucket{le="1e-04"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
573+ ('# TYPE a histogram\n a_bucket{le="1e+05"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
574+ ('# TYPE a histogram\n a_bucket{le="+INF"} 0\n # EOF\n ' ),
552575 ('# TYPE a histogram\n a_bucket{le="2"} 0\n a_bucket{le="1"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
553576 ('# TYPE a histogram\n a_bucket{le="1"} 1\n a_bucket{le="2"} 1\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
554577 # Bad grouping or ordering.
0 commit comments