-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(core): Streamline SpanJSON
type
#14693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
+81
−49
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size-limit report 📦
|
lforst
approved these changes
Dec 13, 2024
Lms24
approved these changes
Dec 13, 2024
c5b1f0c
to
50a66ff
Compare
50a66ff
to
7fba7db
Compare
AbhiPrasad
approved these changes
Dec 13, 2024
7fba7db
to
faa37de
Compare
faa37de
to
fb7efb9
Compare
mydea
added a commit
that referenced
this pull request
Dec 17, 2024
Loading
Loading status checks…
Since this was reworked in #14693 to always return something, we can safe some checks/fallbacks. This most likely does not change all the things, but focuses on the places that were easy to find/replace.
10 tasks
12 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously
spanToJSON
would returnPartial<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 returnsSpanJSON
. This means that in the fallback case, we returndata: {}
, 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
toSpanAttributes
, which is correct (it wasRecord<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 whatdata
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.