Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Do not use AbstractTag<T> for Span.setTag(), but the actual impls. #317

Merged

Conversation

carlosalberto
Copy link
Collaborator

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

This is done to not use an abstract class for our public API,
so we take overloads of BooleanTag, IntTag and StringTag.
@coveralls
Copy link

coveralls commented Oct 24, 2018

Coverage Status

Coverage decreased (-0.2%) to 76.483% when pulling 7e8cbe8 on carlosalberto:span_settag_with_types into b6f6324 on opentracing:v0.32.0.

@carlosalberto
Copy link
Collaborator Author

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 ;)

@yurishkuro
Copy link
Member

Why not use a typed interface? I'm not a fan of overloaded methods (even though it is consistent with the plain set methods).

Copy link

@tylerbenson tylerbenson left a 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.

@carlosalberto
Copy link
Collaborator Author

@yurishkuro

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());
    }
}

@carlosalberto
Copy link
Collaborator Author

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);
Copy link
Member

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.

@carlosalberto
Copy link
Collaborator Author

Hey @yurishkuro

I added Tag.set() and updated AbstractTag as well - but left the call to MockTracer.setObjectTag() as this extra checks that no tags are added after a Span was finished, and would love to keep it around:

    // 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 ;)

@yurishkuro
Copy link
Member

I think it should do tag.set(span, value) instead. This way the correct typed set() method will be called by the tag itself, and those methods would call setObjectTag

@carlosalberto
Copy link
Collaborator Author

@yurishkuro Updated it to looks just like that ;) If you think that's fine, I will merge soon

@yurishkuro
Copy link
Member

🚢

@carlosalberto carlosalberto merged commit 9b6ca36 into opentracing:v0.32.0 Oct 31, 2018
@carlosalberto
Copy link
Collaborator Author

👍

@carlosalberto carlosalberto deleted the span_settag_with_types branch March 7, 2019 01:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants