@@ -98,50 +98,50 @@ def test_summary_quantiles(self):
98
98
def test_simple_histogram (self ):
99
99
families = text_string_to_metric_families ("""# TYPE a histogram
100
100
# HELP a help
101
- a_bucket{le="1"} 0
101
+ a_bucket{le="1.0 "} 0
102
102
a_bucket{le="+Inf"} 3
103
103
a_count 3
104
104
a_sum 2
105
105
# EOF
106
106
""" )
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 ))
108
108
109
109
def test_histogram_exemplars (self ):
110
110
families = text_string_to_metric_families ("""# TYPE a histogram
111
111
# 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
114
114
a_bucket{le="+Inf"} 3 # {a="1234567890123456789012345678901234567890123456789012345678"} 4 123
115
115
# EOF
116
116
""" )
117
117
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 )),
120
120
hfm .add_sample ("a_bucket" , {"le" : "+Inf" }, 3.0 , None , Exemplar ({"a" : "1234567890123456789012345678901234567890123456789012345678" }, 4 , Timestamp (123 , 0 )))
121
121
self .assertEqual ([hfm ], list (families ))
122
122
123
123
def test_simple_gaugehistogram (self ):
124
124
families = text_string_to_metric_families ("""# TYPE a gaugehistogram
125
125
# HELP a help
126
- a_bucket{le="1"} 0
126
+ a_bucket{le="1.0 "} 0
127
127
a_bucket{le="+Inf"} 3
128
128
a_gcount 3
129
129
a_gsum 2
130
130
# EOF
131
131
""" )
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 ))
133
133
134
134
def test_gaugehistogram_exemplars (self ):
135
135
families = text_string_to_metric_families ("""# TYPE a gaugehistogram
136
136
# 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
139
139
a_bucket{le="+Inf"} 3 123 # {a="d"} 4 123
140
140
# EOF
141
141
""" )
142
142
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 )),
145
145
hfm .add_sample ("a_bucket" , {"le" : "+Inf" }, 3.0 , Timestamp (123 , 0 ), Exemplar ({"a" : "d" }, 4 , Timestamp (123 , 0 )))
146
146
self .assertEqual ([hfm ], list (families ))
147
147
@@ -383,11 +383,11 @@ def test_timestamps(self):
383
383
def test_roundtrip (self ):
384
384
text = """# HELP go_gc_duration_seconds A summary of the GC invocation durations.
385
385
# 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
387
387
go_gc_duration_seconds{quantile="0.25"} 0.013638736
388
388
go_gc_duration_seconds{quantile="0.5"} 0.013759906
389
389
go_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
391
391
go_gc_duration_seconds_sum 56.12904785
392
392
go_gc_duration_seconds_count 7476.0
393
393
# HELP go_goroutines Number of goroutines that currently exist.
@@ -405,20 +405,36 @@ def test_roundtrip(self):
405
405
process_cpu_seconds_total 29323.4
406
406
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
407
407
# TYPE process_virtual_memory_bytes gauge
408
- process_virtual_memory_bytes 2478268416.0
408
+ process_virtual_memory_bytes 2.478268416e+09
409
409
# HELP prometheus_build_info A metric with a constant '1' value labeled by version, revision, and branch from which Prometheus was built.
410
410
# TYPE prometheus_build_info gauge
411
411
prometheus_build_info{branch="HEAD",revision="ef176e5",version="0.16.0rc1"} 1.0
412
412
# HELP prometheus_local_storage_chunk_ops The total number of chunk operations by their type.
413
413
# TYPE prometheus_local_storage_chunk_ops counter
414
414
prometheus_local_storage_chunk_ops_total{type="clone"} 28.0
415
415
prometheus_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
417
417
prometheus_local_storage_chunk_ops_total{type="load"} 1641.0
418
418
prometheus_local_storage_chunk_ops_total{type="persist"} 981408.0
419
419
prometheus_local_storage_chunk_ops_total{type="pin"} 32662.0
420
420
prometheus_local_storage_chunk_ops_total{type="transcode"} 980180.0
421
421
prometheus_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
422
438
# EOF
423
439
"""
424
440
families = list (text_string_to_metric_families (text ))
@@ -522,6 +538,7 @@ def test_invalid_input(self):
522
538
('# TYPE a summary\n a{quantile="foo"} 0\n # EOF\n ' ),
523
539
('# TYPE a summary\n a{quantile="1.01"} 0\n # EOF\n ' ),
524
540
('# TYPE a summary\n a{quantile="NaN"} 0\n # EOF\n ' ),
541
+ ('# TYPE a summary\n a{quantile="1"} 0\n # EOF\n ' ),
525
542
('# TYPE a histogram\n a_bucket 0\n # EOF\n ' ),
526
543
('# TYPE a gaugehistogram\n a_bucket 0\n # EOF\n ' ),
527
544
('# TYPE a stateset\n a 0\n # EOF\n ' ),
@@ -549,6 +566,12 @@ def test_invalid_input(self):
549
566
('# TYPE a gaugehistogram\n a_gsum 1\n # EOF\n ' ),
550
567
('# TYPE a histogram\n a_count 1\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
551
568
('# 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 ' ),
552
575
('# TYPE a histogram\n a_bucket{le="2"} 0\n a_bucket{le="1"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
553
576
('# TYPE a histogram\n a_bucket{le="1"} 1\n a_bucket{le="2"} 1\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
554
577
# Bad grouping or ordering.
0 commit comments