-
Notifications
You must be signed in to change notification settings - Fork 232
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
Span#set_attribute with strings & symbols #22
Comments
As the person who opened that issue, I'll add a few comments here. The OpenTracing Issue is worth reading. I really want to be able to use symbols in methods like |
We discussed this at the SIG meeting and I wanted to summarize what we talked about. With the flexibility of accepting strings or symbols for attribute keys / values comes some complications:
A tracer could work around these issues by maintaining a symbol to frozen string cache to reduce string allocations and establishing a rule that keys with equivalent string-symbol representations will be treated the same ( The most performant and simple solution would be for the API to only accept strings, and for users to use frozen strings. In order to take advantage of this, users will have to careful to freeze their strings, and handle symbol to string conversion themselves. There is a tradeoff between the flexibility of using strings and symbols in terms of simplicity and performance. @luvtechno suggested that we could start by only accepting strings and it would be possible to relax the API to accept symbols in the future, if we decided we wanted to go that direction. |
Implemented suggestion (remove Symbol support) in #45 |
Span#set_attribute currently accepts both symbols and strings for both keys and values.
We had a similar discussion here: opentracing/opentracing-ruby#35 and went with only strings. Currently we can still decide what's the best approach.
The problem with allowing both strings and symbols as attribute keys has two main problems:
span[:foo] = "bar"; span["foo"] = "baz"
. who wins?The text was updated successfully, but these errors were encountered: