-
Notifications
You must be signed in to change notification settings - Fork 344
Do not use AbstractTag<T> for Span.setTag(), but the actual impls. #317
Do not use AbstractTag<T> for Span.setTag(), but the actual impls. #317
Conversation
This is done to not use an abstract class for our public API, so we take overloads of BooleanTag, IntTag and StringTag.
Hey, any opinion on this @yurishkuro @tylerbenson ? If it looks right, I will merge and this will be included in the RC1 else, we might probably roll it in the next RC ;) |
Why not use a typed interface? I'm not a fan of overloaded methods (even though it is consistent with the plain set methods). |
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’m ok with this. My understanding is this will perform better because the JIT can optimize the calls more efficiently.
You refer to something like this? // IntTag and the others would be inheriting this class.
public class TypedTag<T> extends AbstractTag<T> {
protected void set(Span span, T tagValue)
{
span.setTag(super.key, tagValue.toString());
}
} |
Hey @yurishkuro sorry, re-read your message today and figured you simply wanted the same, but through an interface ;) |
public <T> Span setTag(AbstractTag<T> key, T value) { | ||
return setObjectTag(key.getKey(), value); | ||
public <T> MockSpan setTag(Tag<T> tag, T value) { | ||
return setObjectTag(tag.getKey(), value); |
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.
If you add setValue to the interface you won't need to use object.
Hey @yurishkuro I added // An error will be reported if this Span is already finished.
private synchronized MockSpan setObjectTag(String key, Object value) {
finishedCheck("Adding tag {%s:%s} to already finished span", key, value); Let me know ;) |
I think it should do |
@yurishkuro Updated it to looks just like that ;) If you think that's fine, I will merge soon |
🚢 |
👍 |
This is done to not use an abstract class for our public API,
so we take overloads of BooleanTag, IntTag and StringTag.
Addresses a small detail mentioned in #314
@yurishkuro @tylerbenson