@@ -97,22 +97,23 @@ class OtlpStatsTransformer extends OtlpTransformerBase {
9797
9898 for ( const aggStats of bucket . values ( ) ) {
9999 const baseAttributes = this . #buildAttributes( aggStats . aggKey )
100+ const baseKey = stableStringify ( baseAttributes )
100101
101102 this . #addDistribution(
102103 distributions , aggStats . topLevelOkDistribution , startNano , endNano ,
103- baseAttributes , true , STATUS_CODE_OK
104+ baseAttributes , baseKey , true , STATUS_CODE_OK
104105 )
105106 this . #addDistribution(
106107 distributions , aggStats . topLevelErrorDistribution , startNano , endNano ,
107- baseAttributes , true , STATUS_CODE_ERROR
108+ baseAttributes , baseKey , true , STATUS_CODE_ERROR
108109 )
109110 this . #addDistribution(
110111 distributions , aggStats . nonTopLevelOkDistribution , startNano , endNano ,
111- baseAttributes , false , STATUS_CODE_OK
112+ baseAttributes , baseKey , false , STATUS_CODE_OK
112113 )
113114 this . #addDistribution(
114115 distributions , aggStats . nonTopLevelErrorDistribution , startNano , endNano ,
115- baseAttributes , false , STATUS_CODE_ERROR
116+ baseAttributes , baseKey , false , STATUS_CODE_ERROR
116117 )
117118 }
118119
@@ -144,19 +145,20 @@ class OtlpStatsTransformer extends OtlpTransformerBase {
144145 * @param {string | number } startNano
145146 * @param {string | number } endNano
146147 * @param {import('@opentelemetry/api').Attributes } baseAttributes
148+ * @param {string } baseKey
147149 * @param {boolean } topLevel
148150 * @param {string } statusCode
149151 * @returns {void }
150152 */
151- #addDistribution ( distributions , sketch , startNano , endNano , baseAttributes , topLevel , statusCode ) {
153+ #addDistribution ( distributions , sketch , startNano , endNano , baseAttributes , baseKey , topLevel , statusCode ) {
152154 if ( ! sketch || sketch . count === 0 ) return
153155
154156 const attributes = {
155157 ...baseAttributes ,
156158 'datadog.span.top_level' : topLevel ,
157159 'status.code' : statusCode ,
158160 }
159- const key = stableStringify ( attributes )
161+ const key = ` ${ baseKey } , ${ topLevel } , ${ statusCode } `
160162 const existing = distributions . get ( key )
161163 if ( existing ) {
162164 existing . sketch . merge ( sketch )
0 commit comments