You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously `spanToJSON` would return `Partial<SpanJSON>`. This meant
that you always had to guard all the stuff you picked from it - even
though in reality, we know that certain stuff will always be there.
To alleviate this, this PR changes this so that `spanToJSON` actually
returns `SpanJSON`. This means that in the fallback case, we return
`data: {}`, as well as a random (current) timestamp. Since we know that
in reality we will only have the two scenarios that we properly handle,
this is fine IMHO and makes usage of this everywhere else a little bit
less painful.
In a follow up, we can get rid of a bunch of `const data =
spanToJSON(span).data || {}` type code.
While at it, I also updated the type of `data` to `SpanAttributes`,
which is correct (it was `Record<string, any>` before). Since we only
allow span attributes to be set on this anyhow now, we can type this
better. This also uncovered a few places with slightly "incorrect" type
checks, I updated those too.
This change is on the v9 branch - I think it should not really be
breaking to a user in any way, as we simply return more data from
`spanToJSON`, and type what `data` is on there more tightly, so no
existing code relying on this should break. But to be safe, I figured we
may as well do that on v9 only.
0 commit comments