getsentry / getsentry/sentry-javascript

Unify attribute typing and serialization

Open
#18,164 2 comments 1 reaction 0 assignees View on GitHub
breaking breaking change javascript Meta: Breaking Task
Dominant language
TypeScript
Stars
8.7k
Forks
1.8k
Avg merge
1d 17h
Merged PRs (30d)
515

Description

Right now, we have various implementations and type declarations for attributes, serialization/conversion, etc. Given that spans (v2), metrics and logs all accept the same attributes, we should unify the respective declarations and the logic. This probably saves some bundle size for multi-product users.

Fully unifying attribute typing and serialization is a breaking change because:

* logs and metrics currently stringify array values
* stringification is not handled perfectly well and we could extract more information from obscure values:
* circular objects /h/t @s1gr1d for bringing up!)
* `undefined/null` values
* objects throwing in `toJSON` but having a `toString`
* => All of these cases can be improved but are breaking changes in terms of values

Actually removing duplicated logic between logs, metrics and span attributes is not part of this issue and should be addressed in [JS-1145](https://linear.app/getsentry/issue/JS-1145/apply-scope-attributes-to-logs), [JS-1147](https://linear.app/getsentry/issue/JS-1147/apply-scope-attributes-to-spans-v2), [JS-1146](https://linear.app/getsentry/issue/JS-1146/apply-scope-attributes-to-metrics) directly (i.e. before the next major).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.