-
Notifications
You must be signed in to change notification settings - Fork 594
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
Meaningful message when span name is not a string #3955
Closed
Closed
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e84e823
span non string name issue solve
soumyadeepm04 401ff61
fixed linting issues
soumyadeepm04 b2737ce
fixed linting issues
soumyadeepm04 8db1003
added test cases
soumyadeepm04 75bffd7
raise typeerror when span has non string name
soumyadeepm04 6788c15
Merge branch 'main' into main
soumyadeepm04 05061af
Merge branch 'main' into main
emdneto a7ed812
Merge branch 'main' into main
emdneto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consider cases where converting the
name
to a string might fail?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot really think of any case where this could fail. Did you have any such cases in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good that we're logging something, but I'm not sure that we want to log a stack trace here. Is logging a stacktrace done elsewhere in this repo?
Regarding testing, I think we should test passing in a string, and test passing in a non-string, making sure both scenarios produce expected results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see logging a stacktrace being done anywhere in the repo. Would you like me to change it and if so, how would you like me to change it?
Sure, working on it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should just raise a TypeError. Anybody have thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like there's two thing we can do:
I personally am more for (1), this seems more like a misuse of an api in which every we expect name to be a string. Otherwise, we must do type checks every we use span name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raising an error here is against the OTel basic error handling principles i believe. Since
ReadableSpan.__init__
is called onSpan.end
a raised error will escape the API/SDK and fail the user's application.Converting to str is probably fine but should be handled with care since e.g. a custom
__str__
implementation might also raise an error.Another option might be to just replace the span name with some hardcoded "i'm not a str pls fix me" message so users would see in their backend that something isn't quite right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the specification quotes here #3955 (comment) and that we have the proper type on the method parameter I'll just leave the code as is. Hopefully in the future users would be able to catch these with a type checker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xrmx
Should we close the pr in this case? @mariojonke wdyt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes