Add safe span attribute helper

SU
13d ago
+85-1

Summary

  • add setSpanAttributesSafe for filtering and setting valid OpenTelemetry span attributes
  • export the helper from the package entry point
  • add coverage for supported scalar/array values and dropped invalid values

Validation

  • git diff --check
  • Unable to run pnpm test, pnpm typecheck, or pnpm build because pnpm and installed dependencies are unavailable in the sandbox.

Summary by cubic

Adds setSpanAttributesSafe, a helper that only sets valid OpenTelemetry span attributes and returns the count of attributes set. Valid values are strings, numbers, booleans, and homogeneous arrays of those; empty keys and anything else are dropped. Exports the helper from the package entry point and adds tests covering valid and invalid values.