Swap Object.entries for Object.keys to cut allocations in OTel cleanAttributes

DanielLockyer · x · 2026-11-18

Daniel Lockyer's third OTel JS perf PR (#7353): cleanAttributes runs on span start attributes, every addEvent, addLink, and log record. It used to iterate with Object.entries(), which allocates an array of [key, value] pair arrays on every call, with cost scaling by attribute count.

Switching to Object.keys() plus key lookups visits exactly the same keys in the same order (behavior unchanged) while eliminating the intermediate array allocations. Benchmarked on Node.js v26.13.1. Together the three PRs meaningfully cut OTel JS SDK observability overhead.

Related event: OpenTelemetry Node.js SDK Gets 2.4x Speedup from Loop Optimization(2 posts)→

Original post →

More from Infra

Infra channel →