ref: declare expected arguments explicitly instead of varargs - #20
Merged
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
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.
Update the signature so it contains all expected keys instead of relying on variadic arguments and proper name matching. This will make it easier for tools and humans to reason about the code and will not require reading docs to see what type is required for what.
It also changed the order of parameters. Before this change, it required the class to be the first parameter and the function name as second. While it might make sense from a hierarchical point of view, it does not in terms of requirements.
A class name can be optional (for functions) but it always requires a function name.
A pattern like
instrument(null, "foo")was ugly to read, instead havinginstrument("foo", Bla::class)is perfectly understandable.The only downside is that one has to write
attributes:now before adding span data that couldn't be added through variadic named arguments. For example:Once this PR is merged, it will be strongly encouraged to use named parameters as the list of allowed params will only grow, thus more breaking changes would happen.