@@ -7,7 +7,7 @@ package io.opentelemetry.contrib.jmxmetrics
77import static io.opentelemetry.api.common.AttributeKey.stringKey
88import static io.opentelemetry.sdk.metrics.data.MetricDataType.DOUBLE_SUM
99import static io.opentelemetry.sdk.metrics.data.MetricDataType.LONG_SUM
10- import static io.opentelemetry.sdk.metrics.data.MetricDataType.SUMMARY
10+ import static io.opentelemetry.sdk.metrics.data.MetricDataType.HISTOGRAM
1111
1212import io.opentelemetry.api.common.Attributes
1313import io.opentelemetry.api.metrics.GlobalMeterProvider
@@ -46,8 +46,8 @@ class OtelHelperSynchronousMetricTest extends Specification{
4646 def s1 = p1. startEpochNanos
4747 def s2 = p2. startEpochNanos
4848 if (s1 == s2) {
49- if (md1. type == SUMMARY ) {
50- return p1. percentileValues [0 ]. value <=> p2. percentileValues [0 ]. value
49+ if (md1. type == HISTOGRAM ) {
50+ return p1. counts [0 ] <=> p2. counts [0 ]
5151 }
5252 return p1. value <=> p2. value
5353 }
@@ -404,57 +404,45 @@ class OtelHelperSynchronousMetricTest extends Specification{
404404 def third = metrics[2 ]
405405 def fourth = metrics[3 ]
406406
407- assert first. name == ' double-value-recorder'
408- assert first. description == ' a double value-recorder '
409- assert first. unit == ' ms '
410- assert first. type == SUMMARY
407+ assert first. name == ' yet-another- double-value-recorder'
408+ assert first. description == ' '
409+ assert first. unit == ' 1 '
410+ assert first. type == HISTOGRAM
411411 assert first. data. points. size() == 1
412412 assert first. data. points[0 ]. count == 1
413- assert first. data. points[0 ]. sum == -234.567
414- assert first. data. points[0 ]. percentileValues[0 ]. percentile == 0
415- assert first. data. points[0 ]. percentileValues[0 ]. value == -234.567
416- assert first. data. points[0 ]. percentileValues[1 ]. percentile == 100
417- assert first. data. points[0 ]. percentileValues[1 ]. value == -234.567
418- assert first. data. points[0 ]. attributes == Attributes . of(stringKey(' key' ), ' value' )
419-
420- assert second. name == ' my-double-value-recorder'
421- assert second. description == ' another double value-recorder'
422- assert second. unit == ' µs'
423- assert second. type == SUMMARY
413+ assert first. data. points[0 ]. sum == 456.789
414+ assert first. data. points[0 ]. counts[7 ] == 1
415+ assert first. data. points[0 ]. attributes == Attributes . of(stringKey(' yetAnotherKey' ), ' yetAnotherValue' )
416+
417+ assert second. name == ' another-double-value-recorder'
418+ assert second. description == ' double value-recorder'
419+ assert second. unit == ' 1'
420+ assert second. type == HISTOGRAM
424421 assert second. data. points. size() == 1
425422 assert second. data. points[0 ]. count == 1
426- assert second. data. points[0 ]. sum == -123.456
427- assert second. data. points[0 ]. percentileValues[0 ]. percentile == 0
428- assert second. data. points[0 ]. percentileValues[0 ]. value == -123.456
429- assert second. data. points[0 ]. percentileValues[1 ]. percentile == 100
430- assert second. data. points[0 ]. percentileValues[1 ]. value == -123.456
431- assert second. data. points[0 ]. attributes == Attributes . of(stringKey(' myKey' ), ' myValue' )
432-
433- assert third. name == ' another-double-value-recorder'
434- assert third. description == ' double value-recorder'
435- assert third. unit == ' 1'
436- assert third. type == SUMMARY
423+ assert second. data. points[0 ]. sum == 345.678
424+ assert second. data. points[0 ]. counts[7 ] == 1
425+ assert second. data. points[0 ]. attributes == Attributes . of(stringKey(' anotherKey' ), ' anotherValue' )
426+
427+ assert third. name == ' double-value-recorder'
428+ assert third. description == ' a double value-recorder'
429+ assert third. unit == ' ms'
430+ assert third. type == HISTOGRAM
437431 assert third. data. points. size() == 1
438432 assert third. data. points[0 ]. count == 1
439- assert third. data. points[0 ]. sum == 345.678
440- assert third. data. points[0 ]. percentileValues[0 ]. percentile == 0
441- assert third. data. points[0 ]. percentileValues[0 ]. value == 345.678
442- assert third. data. points[0 ]. percentileValues[1 ]. percentile == 100
443- assert third. data. points[0 ]. percentileValues[1 ]. value == 345.678
444- assert third. data. points[0 ]. attributes == Attributes . of(stringKey(' anotherKey' ), ' anotherValue' )
445-
446- assert fourth. name == ' yet-another-double-value-recorder'
447- assert fourth. description == ' '
448- assert fourth. unit == ' 1'
449- assert fourth. type == SUMMARY
433+ assert third. data. points[0 ]. sum == -234.567
434+ assert third. data. points[0 ]. counts[0 ] == 1
435+ assert third. data. points[0 ]. attributes == Attributes . of(stringKey(' key' ), ' value' )
436+
437+ assert fourth. name == ' my-double-value-recorder'
438+ assert fourth. description == ' another double value-recorder'
439+ assert fourth. unit == ' µs'
440+ assert fourth. type == HISTOGRAM
450441 assert fourth. data. points. size() == 1
451442 assert fourth. data. points[0 ]. count == 1
452- assert fourth. data. points[0 ]. sum == 456.789
453- assert fourth. data. points[0 ]. percentileValues[0 ]. percentile == 0
454- assert fourth. data. points[0 ]. percentileValues[0 ]. value == 456.789
455- assert fourth. data. points[0 ]. percentileValues[1 ]. percentile == 100
456- assert fourth. data. points[0 ]. percentileValues[1 ]. value == 456.789
457- assert fourth. data. points[0 ]. attributes == Attributes . of(stringKey(' yetAnotherKey' ), ' yetAnotherValue' )
443+ assert fourth. data. points[0 ]. sum == -123.456
444+ assert fourth. data. points[0 ]. counts[0 ] == 1
445+ assert fourth. data. points[0 ]. attributes == Attributes . of(stringKey(' myKey' ), ' myValue' )
458446 }
459447
460448 def " double value recorder memoization" () {
@@ -474,14 +462,12 @@ class OtelHelperSynchronousMetricTest extends Specification{
474462 assert metric. name == ' dvr'
475463 assert metric. description == ' double value'
476464 assert metric. unit == ' 1'
477- assert metric. type == SUMMARY
465+ assert metric. type == HISTOGRAM
478466 assert metric. data. points. size() == 1
479467 assert metric. data. points[0 ]. count == 2
480468 assert metric. data. points[0 ]. sum == 0
481- assert metric. data. points[0 ]. percentileValues[0 ]. percentile == 0
482- assert metric. data. points[0 ]. percentileValues[0 ]. value == -10.1
483- assert metric. data. points[0 ]. percentileValues[1 ]. percentile == 100
484- assert metric. data. points[0 ]. percentileValues[1 ]. value == 10.1
469+ assert metric. data. points[0 ]. counts[0 ] == 1
470+ assert metric. data. points[0 ]. counts[1 ] == 0
485471 assert metric. data. points[0 ]. attributes == Attributes . of(stringKey(' key' ), ' value' )
486472 }
487473
@@ -510,57 +496,45 @@ class OtelHelperSynchronousMetricTest extends Specification{
510496 def third = metrics[2 ]
511497 def fourth = metrics[3 ]
512498
513- assert first. name == ' long-value-recorder'
514- assert first. description == ' a long value-recorder '
515- assert first. unit == ' ms '
516- assert first. type == SUMMARY
499+ assert first. name == ' yet-another- long-value-recorder'
500+ assert first. description == ' '
501+ assert first. unit == ' 1 '
502+ assert first. type == HISTOGRAM
517503 assert first. data. points. size() == 1
518504 assert first. data. points[0 ]. count == 1
519- assert first. data. points[0 ]. sum == -234
520- assert first. data. points[0 ]. percentileValues[0 ]. percentile == 0
521- assert first. data. points[0 ]. percentileValues[0 ]. value == -234
522- assert first. data. points[0 ]. percentileValues[1 ]. percentile == 100
523- assert first. data. points[0 ]. percentileValues[1 ]. value == -234
524- assert first. data. points[0 ]. attributes == Attributes . of(stringKey(' key' ), ' value' )
525-
526- assert second. name == ' my-long-value-recorder'
527- assert second. description == ' another long value-recorder'
528- assert second. unit == ' µs'
529- assert second. type == SUMMARY
505+ assert first. data. points[0 ]. sum == 456
506+ assert first. data. points[0 ]. counts[7 ] == 1
507+ assert first. data. points[0 ]. attributes == Attributes . of(stringKey(' yetAnotherKey' ), ' yetAnotherValue' )
508+
509+ assert second. name == ' another-long-value-recorder'
510+ assert second. description == ' long value-recorder'
511+ assert second. unit == ' 1'
512+ assert second. type == HISTOGRAM
530513 assert second. data. points. size() == 1
531514 assert second. data. points[0 ]. count == 1
532- assert second. data. points[0 ]. sum == -123
533- assert second. data. points[0 ]. percentileValues[0 ]. percentile == 0
534- assert second. data. points[0 ]. percentileValues[0 ]. value == -123
535- assert second. data. points[0 ]. percentileValues[1 ]. percentile == 100
536- assert second. data. points[0 ]. percentileValues[1 ]. value == -123
537- assert second. data. points[0 ]. attributes == Attributes . of(stringKey(' myKey' ), ' myValue' )
538-
539- assert third. name == ' another-long-value-recorder'
540- assert third. description == ' long value-recorder'
541- assert third. unit == ' 1'
542- assert third. type == SUMMARY
515+ assert second. data. points[0 ]. sum == 345
516+ assert second. data. points[0 ]. counts[7 ] == 1
517+ assert second. data. points[0 ]. attributes == Attributes . of(stringKey(' anotherKey' ), ' anotherValue' )
518+
519+ assert third. name == ' long-value-recorder'
520+ assert third. description == ' a long value-recorder'
521+ assert third. unit == ' ms'
522+ assert third. type == HISTOGRAM
543523 assert third. data. points. size() == 1
544524 assert third. data. points[0 ]. count == 1
545- assert third. data. points[0 ]. sum == 345
546- assert third. data. points[0 ]. percentileValues[0 ]. percentile == 0
547- assert third. data. points[0 ]. percentileValues[0 ]. value == 345
548- assert third. data. points[0 ]. percentileValues[1 ]. percentile == 100
549- assert third. data. points[0 ]. percentileValues[1 ]. value == 345
550- assert third. data. points[0 ]. attributes == Attributes . of(stringKey(' anotherKey' ), ' anotherValue' )
551-
552- assert fourth. name == ' yet-another-long-value-recorder'
553- assert fourth. description == ' '
554- assert fourth. unit == ' 1'
555- assert fourth. type == SUMMARY
525+ assert third. data. points[0 ]. sum == -234
526+ assert third. data. points[0 ]. counts[0 ] == 1
527+ assert third. data. points[0 ]. attributes == Attributes . of(stringKey(' key' ), ' value' )
528+
529+ assert fourth. name == ' my-long-value-recorder'
530+ assert fourth. description == ' another long value-recorder'
531+ assert fourth. unit == ' µs'
532+ assert fourth. type == HISTOGRAM
556533 assert fourth. data. points. size() == 1
557534 assert fourth. data. points[0 ]. count == 1
558- assert fourth. data. points[0 ]. sum == 456
559- assert fourth. data. points[0 ]. percentileValues[0 ]. percentile == 0
560- assert fourth. data. points[0 ]. percentileValues[0 ]. value == 456
561- assert fourth. data. points[0 ]. percentileValues[1 ]. percentile == 100
562- assert fourth. data. points[0 ]. percentileValues[1 ]. value == 456
563- assert fourth. data. points[0 ]. attributes == Attributes . of(stringKey(' yetAnotherKey' ), ' yetAnotherValue' )
535+ assert fourth. data. points[0 ]. sum == -123
536+ assert fourth. data. points[0 ]. counts[0 ] == 1
537+ assert fourth. data. points[0 ]. attributes == Attributes . of(stringKey(' myKey' ), ' myValue' )
564538 }
565539
566540 def " long value recorder memoization" () {
@@ -580,14 +554,12 @@ class OtelHelperSynchronousMetricTest extends Specification{
580554 assert metric. name == ' lvr'
581555 assert metric. description == ' long value'
582556 assert metric. unit == ' 1'
583- assert metric. type == SUMMARY
557+ assert metric. type == HISTOGRAM
584558 assert metric. data. points. size() == 1
585559 assert metric. data. points[0 ]. count == 2
586560 assert metric. data. points[0 ]. sum == 0
587- assert metric. data. points[0 ]. percentileValues[0 ]. percentile == 0
588- assert metric. data. points[0 ]. percentileValues[0 ]. value == -10
589- assert metric. data. points[0 ]. percentileValues[1 ]. percentile == 100
590- assert metric. data. points[0 ]. percentileValues[1 ]. value == 10
561+ assert metric. data. points[0 ]. counts[0 ] == 1
562+ assert metric. data. points[0 ]. counts[1 ] == 1
591563 assert metric. data. points[0 ]. attributes == Attributes . of(stringKey(' key' ), ' value' )
592564 }
593565
0 commit comments