Fast path for primitive attributes boosts OTel span creation up to 24%

DanielLockyer · x · 2026-11-18

Another merged OTel JS SDK perf PR (#7356) by Daniel Lockyer. Most span attribute values are plain strings/numbers/booleans, yet all went through the general path: isAnyValue() allocates a WeakSet (for circular-reference detection) on every call and runs for every value in cleanAttributes; maybeAddAttribute() also validated and copied values generically.

The change adds a fast path for primitive values that skips the WeakSet allocation and generic copying, yielding up to 24% more ops/s for span creation.

Original post →

More from Infra

Infra channel →