@@ -79,7 +79,12 @@ function assertMetricCollection(
7979 { errors, resourceMetrics } : CollectionResult ,
8080 expected : Record <
8181 string ,
82- { count ?: number ; value ?: number ; attributes : Attributes } [ ]
82+ {
83+ count ?: number ;
84+ value ?: number ;
85+ buckets ?: Record < number , number > ;
86+ attributes : Attributes ;
87+ } [ ]
8388 >
8489) {
8590 assert . strictEqual ( errors . length , 0 ) ;
@@ -99,6 +104,18 @@ function assertMetricCollection(
99104 values . map ( v => v . count ) ,
100105 `${ name } datapoints do not have the same count`
101106 ) ;
107+ values . forEach ( ( { buckets } , i ) => {
108+ if ( buckets ) {
109+ const { boundaries, counts } = match . dataPoints [ i ] . value . buckets ;
110+ const actualBuckets = counts . reduce ( ( acc , n , j ) => {
111+ if ( n > 0 ) {
112+ acc [ boundaries [ j ] ] = n ;
113+ }
114+ return acc ;
115+ } , { } as Record < number , number > ) ;
116+ assert . deepStrictEqual ( actualBuckets , buckets ) ;
117+ }
118+ } ) ;
102119 } else {
103120 assert . deepStrictEqual (
104121 match . dataPoints . map ( d => d . value ) ,
@@ -1344,7 +1361,7 @@ describe('instrumentation-kafkajs', () => {
13441361 instrumentation [ '_recordClientDurationMetric' ] ( {
13451362 payload : {
13461363 broker : 'kafka.host:4789' ,
1347- duration : 242 ,
1364+ duration : 250 ,
13481365 apiName : 'some-operation' ,
13491366 apiKey : 123 ,
13501367 apiVersion : 1 ,
@@ -1360,7 +1377,7 @@ describe('instrumentation-kafkajs', () => {
13601377 [ METRIC_MESSAGING_CLIENT_OPERATION_DURATION ] : [
13611378 {
13621379 count : 1 ,
1363- value : 0.232 ,
1380+ buckets : { '0.25' : 1 } ,
13641381 attributes : {
13651382 [ ATTR_MESSAGING_SYSTEM ] : MESSAGING_SYSTEM_VALUE_KAFKA ,
13661383 [ ATTR_MESSAGING_OPERATION_NAME ] : 'some-operation' ,
0 commit comments