@@ -84,7 +84,7 @@ public class OpenTelemetryBuiltInMetricsTracerTest extends AbstractNettyMockServ
8484 Attributes .builder ().put (BuiltInMetricsConstant .DIRECT_PATH_USED_KEY , "false" ).build ();
8585 ;
8686
87- private static final long MIN_LATENCY = 0 ;
87+ private static final double MIN_LATENCY = 0 ;
8888
8989 private DatabaseClient client ;
9090
@@ -159,7 +159,7 @@ public void testMetricsSingleUseQuery() {
159159 assertFalse (resultSet .next ());
160160 }
161161
162- long elapsed = stopwatch .elapsed (TimeUnit .MILLISECONDS );
162+ double elapsed = stopwatch .elapsed (TimeUnit .MILLISECONDS );
163163 Attributes expectedAttributes =
164164 expectedCommonBaseAttributes .toBuilder ()
165165 .putAll (expectedCommonRequestAttributes )
@@ -170,13 +170,13 @@ public void testMetricsSingleUseQuery() {
170170 MetricData operationLatencyMetricData =
171171 getMetricData (metricReader , BuiltInMetricsConstant .OPERATION_LATENCIES_NAME );
172172 assertNotNull (operationLatencyMetricData );
173- long operationLatencyValue = getAggregatedValue (operationLatencyMetricData , expectedAttributes );
173+ double operationLatencyValue = getAggregatedValue (operationLatencyMetricData , expectedAttributes );
174174 assertThat (operationLatencyValue ).isIn (Range .closed (MIN_LATENCY , elapsed ));
175175
176176 MetricData attemptLatencyMetricData =
177177 getMetricData (metricReader , BuiltInMetricsConstant .ATTEMPT_LATENCIES_NAME );
178178 assertNotNull (attemptLatencyMetricData );
179- long attemptLatencyValue = getAggregatedValue (attemptLatencyMetricData , expectedAttributes );
179+ double attemptLatencyValue = getAggregatedValue (attemptLatencyMetricData , expectedAttributes );
180180 assertThat (attemptLatencyValue ).isIn (Range .closed (MIN_LATENCY , elapsed ));
181181
182182 MetricData operationCountMetricData =
@@ -191,7 +191,7 @@ public void testMetricsSingleUseQuery() {
191191
192192 MetricData gfeLatencyMetricData =
193193 getMetricData (metricReader , BuiltInMetricsConstant .GFE_LATENCIES_NAME );
194- long gfeLatencyValue = getAggregatedValue (gfeLatencyMetricData , expectedAttributes );
194+ double gfeLatencyValue = getAggregatedValue (gfeLatencyMetricData , expectedAttributes );
195195 assertEquals (fakeServerTiming .get (), gfeLatencyValue , 0 );
196196
197197 assertFalse (
@@ -229,7 +229,7 @@ public void testMetricsSingleUseQueryWithAfeEnabled() throws Exception {
229229 assertFalse (resultSet .next ());
230230 }
231231
232- long elapsed = stopwatch .elapsed (TimeUnit .MILLISECONDS );
232+ double elapsed = stopwatch .elapsed (TimeUnit .MILLISECONDS );
233233 Attributes expectedAttributes =
234234 expectedCommonBaseAttributes .toBuilder ()
235235 .putAll (expectedCommonRequestAttributes )
@@ -240,14 +240,14 @@ public void testMetricsSingleUseQueryWithAfeEnabled() throws Exception {
240240 MetricData operationLatencyMetricData =
241241 getMetricData (metricReader , BuiltInMetricsConstant .OPERATION_LATENCIES_NAME );
242242 assertNotNull (operationLatencyMetricData );
243- long operationLatencyValue =
243+ double operationLatencyValue =
244244 getAggregatedValue (operationLatencyMetricData , expectedAttributes );
245245 assertThat (operationLatencyValue ).isIn (Range .closed (MIN_LATENCY , elapsed ));
246246
247247 MetricData attemptLatencyMetricData =
248248 getMetricData (metricReader , BuiltInMetricsConstant .ATTEMPT_LATENCIES_NAME );
249249 assertNotNull (attemptLatencyMetricData );
250- long attemptLatencyValue = getAggregatedValue (attemptLatencyMetricData , expectedAttributes );
250+ double attemptLatencyValue = getAggregatedValue (attemptLatencyMetricData , expectedAttributes );
251251 assertThat (attemptLatencyValue ).isIn (Range .closed (MIN_LATENCY , elapsed ));
252252
253253 MetricData operationCountMetricData =
@@ -262,15 +262,15 @@ public void testMetricsSingleUseQueryWithAfeEnabled() throws Exception {
262262
263263 MetricData gfeLatencyMetricData =
264264 getMetricData (metricReader , BuiltInMetricsConstant .GFE_LATENCIES_NAME );
265- long gfeLatencyValue = getAggregatedValue (gfeLatencyMetricData , expectedAttributes );
265+ double gfeLatencyValue = getAggregatedValue (gfeLatencyMetricData , expectedAttributes );
266266 assertEquals (fakeServerTiming .get (), gfeLatencyValue , 0 );
267267
268268 assertFalse (
269269 checkIfMetricExists (metricReader , BuiltInMetricsConstant .GFE_CONNECTIVITY_ERROR_NAME ));
270270
271271 MetricData afeLatencyMetricData =
272272 getMetricData (metricReader , BuiltInMetricsConstant .AFE_LATENCIES_NAME );
273- long afeLatencyValue = getAggregatedValue (afeLatencyMetricData , expectedAttributes );
273+ double afeLatencyValue = getAggregatedValue (afeLatencyMetricData , expectedAttributes );
274274 assertEquals (fakeAFEServerTiming .get (), afeLatencyValue , 0 );
275275 assertFalse (
276276 checkIfMetricExists (metricReader , BuiltInMetricsConstant .AFE_CONNECTIVITY_ERROR_NAME ));
@@ -402,7 +402,7 @@ public void testNoNetworkConnection() {
402402
403403 // Attempt count should have a failed metric point for CreateSession.
404404 assertEquals (
405- 1 , getAggregatedValue (attemptCountMetricData , expectedAttributesCreateSessionFailed ));
405+ 1 , getAggregatedValue (attemptCountMetricData , expectedAttributesCreateSessionFailed ), 0 );
406406 }
407407
408408 @ Test
@@ -509,14 +509,14 @@ private boolean checkIfMetricExists(InMemoryMetricReader reader, String metricNa
509509 return false ;
510510 }
511511
512- private long getAggregatedValue (MetricData metricData , Attributes attributes ) {
512+ private float getAggregatedValue (MetricData metricData , Attributes attributes ) {
513513 switch (metricData .getType ()) {
514514 case HISTOGRAM :
515515 return metricData .getHistogramData ().getPoints ().stream ()
516516 .filter (pd -> pd .getAttributes ().equals (attributes ))
517- .map (data -> (long ) data .getSum () / data .getCount ())
517+ .map (data -> (float ) data .getSum () / data .getCount ())
518518 .findFirst ()
519- .orElse (0L );
519+ .orElse (0F );
520520 case LONG_SUM :
521521 return metricData .getLongSumData ().getPoints ().stream ()
522522 .filter (pd -> pd .getAttributes ().equals (attributes ))
0 commit comments