Skip to content

Commit ddb64b7

Browse files
committed
perf(otlp): avoid redundant attribute transforms
Build the known top-level and status OTLP values directly instead of copying and re-transforming the base attributes.
1 parent 27e8299 commit ddb64b7

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,21 @@ class OtlpStatsTransformer extends OtlpTransformerBase {
153153
#addDistribution (distributions, sketch, startNano, endNano, baseAttributes, baseKey, topLevel, statusCode) {
154154
if (!sketch || sketch.count === 0) return
155155

156-
const attributes = {
157-
...baseAttributes,
158-
'datadog.span.top_level': topLevel,
159-
'status.code': statusCode,
160-
}
161156
const key = `${baseKey},${topLevel},${statusCode}`
162157
const existing = distributions.get(key)
163158
if (existing) {
164159
existing.sketch.merge(sketch)
165160
} else {
161+
const attributes = this.transformAttributes(baseAttributes)
162+
attributes.push(
163+
{ key: 'datadog.span.top_level', value: { boolValue: topLevel } },
164+
{ key: 'status.code', value: { stringValue: statusCode } }
165+
)
166166
distributions.set(key, {
167167
sketch,
168168
startNano,
169169
endNano,
170-
attributes: this.transformAttributes(attributes),
170+
attributes,
171171
})
172172
}
173173
}

0 commit comments

Comments
 (0)