@@ -20,7 +20,7 @@ public void should_increment_by_default_value() {
2020
2121 CollectedMetric expected =
2222 new CollectedMetric (
23- "test_counter" , "testing" , MetricType .COUNTER , List .of (sample (1L )));
23+ "test_counter" , "testing" , MetricType .COUNTER , List .of (sample (1.0 )));
2424
2525 assertThat (metrics ).containsExactly (expected );
2626 }
@@ -40,7 +40,7 @@ public void should_increment_with_custom_value_and_labels() {
4040 "labeled_counter" ,
4141 "with labels" ,
4242 MetricType .COUNTER ,
43- List .of (sample (Map .of ("foo" , "bar" ), 5L )));
43+ List .of (sample (Map .of ("foo" , "bar" ), 5.0 )));
4444
4545 assertThat (metrics ).containsExactly (expected );
4646 }
@@ -61,7 +61,7 @@ public void should_support_gauge_inc_dec_and_set() {
6161 "test_gauge" ,
6262 "gauge test" ,
6363 MetricType .GAUGE ,
64- List .of (sample (Map .of ("env" , "prod" ), 10L )));
64+ List .of (sample (Map .of ("env" , "prod" ), 10.0 )));
6565
6666 assertThat (metrics ).containsExactly (expected );
6767 }
@@ -81,7 +81,7 @@ public void should_store_different_label_combinations_separately() {
8181 assertThat (result .getName ()).isEqualTo ("multi_label" );
8282 assertThat (result .getSamples ())
8383 .containsExactlyInAnyOrder (
84- sample (Map .of ("a" , "x" ), 1L ), sample (Map .of ("b" , "y" ), 2L ), sample (3L ));
84+ sample (Map .of ("a" , "x" ), 1.0 ), sample (Map .of ("b" , "y" ), 2.0 ), sample (3.0 ));
8585 }
8686
8787 @ Test
@@ -99,9 +99,9 @@ public void should_track_gauge_values_separately_per_label_set() {
9999 assertThat (result .getName ()).isEqualTo ("multi_env_gauge" );
100100 assertThat (result .getSamples ())
101101 .containsExactlyInAnyOrder (
102- sample (Map .of ("env" , "prod" ), 5L ),
103- sample (Map .of ("env" , "dev" ), -2L ),
104- sample (Map .of ("env" , "test" ), 10L ));
102+ sample (Map .of ("env" , "prod" ), 5.0 ),
103+ sample (Map .of ("env" , "dev" ), -2.0 ),
104+ sample (Map .of ("env" , "test" ), 10.0 ));
105105 }
106106
107107 @ Test
@@ -114,7 +114,7 @@ public void should_return_zero_value_when_empty() {
114114
115115 CollectedMetric expected =
116116 new CollectedMetric (
117- "noop_counter" , "noop" , MetricType .COUNTER , List .of (sample (0L )));
117+ "noop_counter" , "noop" , MetricType .COUNTER , List .of (sample (0.0 )));
118118
119119 assertThat (metrics ).containsExactly (expected );
120120 }
@@ -128,12 +128,14 @@ public void should_return_zero_value_after_flushing() {
128128 List <CollectedMetric > firstBatch = registry .collect ();
129129
130130 CollectedMetric expectedBatch1 =
131- new CollectedMetric ("flush_test" , "flush" , MetricType .COUNTER , List .of (sample (1L )));
131+ new CollectedMetric (
132+ "flush_test" , "flush" , MetricType .COUNTER , List .of (sample (1.0 )));
132133 assertThat (firstBatch ).containsExactly (expectedBatch1 );
133134
134135 List <CollectedMetric > secondBatch = registry .collect ();
135136 CollectedMetric expectedBatch2 =
136- new CollectedMetric ("flush_test" , "flush" , MetricType .COUNTER , List .of (sample (0L )));
137+ new CollectedMetric (
138+ "flush_test" , "flush" , MetricType .COUNTER , List .of (sample (0.0 )));
137139 assertThat (secondBatch ).containsExactly (expectedBatch2 );
138140 }
139141
@@ -148,14 +150,14 @@ public void should_restore_collected_metrics() {
148150 List <CollectedMetric > flushed = registry .collect ();
149151
150152 List <CollectedMetric > afterFlush = registry .collect ();
151- assertThat (afterFlush .get (0 ).getSamples ()).containsExactly (sample (0L ));
153+ assertThat (afterFlush .get (0 ).getSamples ()).containsExactly (sample (0.0 ));
152154
153155 registry .restore (flushed );
154156
155157 List <CollectedMetric > restored = registry .collect ();
156158 assertThat (restored .get (0 ).getSamples ())
157159 .containsExactlyInAnyOrder (
158- sample (Map .of ("tag" , "a" ), 5L ), sample (Map .of ("tag" , "b" ), 2L ));
160+ sample (Map .of ("tag" , "a" ), 5.0 ), sample (Map .of ("tag" , "b" ), 2.0 ));
159161 }
160162
161163 @ Test
@@ -293,11 +295,11 @@ private HistogramBucket bucket(double le, long count) {
293295 return new HistogramBucket (le , count );
294296 }
295297
296- private NumericMetricSample sample (long value ) {
298+ private NumericMetricSample sample (double value ) {
297299 return sample (Collections .emptyMap (), value );
298300 }
299301
300- private NumericMetricSample sample (Map <String , String > labels , long value ) {
302+ private NumericMetricSample sample (Map <String , String > labels , double value ) {
301303 return new NumericMetricSample (labels , value );
302304 }
303305}
0 commit comments