-
Notifications
You must be signed in to change notification settings - Fork 1k
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
add core.KV(string, interface{}) #632
Conversation
Oh, the reason I wrote it as returning []KeyValue rather than a singular KeyValue: this way, we could choose to implement, instead of an unhandled non-stringer returning |
The other simplification I might propose is bringing back |
I'd like to propose some other ideas before we go this direction. You wrote:
We already have an abbreviation for this, The method
If a key will be used more than once inside a package, I think it's best to assign them to variables. Other APIs (e.g., OpenTracing Your proposal has the same memory-performance downside that I'm inclined to ask if we could rename things to improve matters enough that you wouldn't want this helper. We could rename the One more thing: I don't think you need the Well, we know my opinion. I'm inclined to add to the API to avoid memory allocations, which is part of the reason we have |
Another idea:
|
cc @paulosman who had the original concerns about verbosity |
#650 may obviate the need for this PR. |
I agree. I still worry about people needing to explicitly type rather than just throwing stuff in, but we can leave that for another time. Can we at least make sure KV takes Stringer rather than just String? I think that address 90% of my problem. |
This enables someone to run:
span.SetAttributes(core.KV("foo", bar)...)
otherwise, the syntax winds up being way too verbose to instantiate
span.SetAttributes(core.Key("foo").Type(bar))
, and is a regression vs. other instrumentation frameworks and against other languages that do the type inference.