-
Notifications
You must be signed in to change notification settings - Fork 344
Implement Trace Identifiers. #280
Implement Trace Identifiers. #280
Conversation
I would bikeshed for |
I like the longer name, certainly less intrusive for existing implementations. |
As a consumer of the API, I prefer
+1, especially because we have not reached 1.0 yet. |
I would vote for |
If we are ok to break things, I would go for |
@hypnoce get/set is a Java bean convention for properties - and is used in the current Java API, e.g. getBaggageItem, setOperationName, etc. |
@objectiser Indeed it's a specification of Java Beans. They serve a specific purpose. Nevertheless, this convention is not consitently respected in the API
From what I could see throughout the API, I beleive when there is a setter then the Java bean convention is used. If there is only a getter, the method has the same name as the property. Also, it seems that java is moving out of getters and setters for data objects : http://cr.openjdk.java.net/~briangoetz/amber/datum.html |
@wu-sheng @adriancole @felixbarny Something to say on this? ;) |
Also pinging @tylerbenson as the author of DataDog's implementation ;) |
Datadog's implementation has the following methods: long getTraceId()
long getSpanId() So the return type will conflict either way. Considering the interface already has |
I would also vote to not use |
I forgot to mention that before... I actually prefer sticking with |
I'm fine with either of the method names, but would prefer Glad to see this change coming! |
Trying to re-take this discussion: it looks we are slightly more towards Something to add anybody? Something to add @yurishkuro ? ;) Else, I will update the PR (including |
Hey all, Have updated the trace/span identifiers to match the described requirements. Let me know ;) |
Hey @carlosalberto
The |
@carlosalberto I'm confused... I thought we decided on |
@tylerbenson Hey Tyler Sorry for the PR without a previous explanation - so after discussing it on the Cross-Language call last Friday, based the fear of both breaking tracers and to signal users that retrieving such Ids may incur in object allocation, we decided to go this way. Of course, this is not set in stone, so we can have a few iterations and pondering on this item ;) Let us know. |
@hypnoce Yes, and also to signal potencial allocation when converting the ids in whatever format they have natively to |
After opentracing/specification#125 I'm wondering if we could have this one merged (to the |
* | ||
* Globally unique. Every span in a trace shares this ID. | ||
* | ||
* The empty string is a valid return value, while null is not. |
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.
Do we need to clarify what an empty string represents? i.e. no active trace instance.
Also do we need other text that indicates the return value of toTraceId and toSpanId are either both empty strings (no active trace) or both have ids? For example, I don't think it would be valid to have an empty trace id but a value returned from span id?
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.
Oh, that's a good point. IMHO it would make sense to mention that the empty string ought to represent missing Trace Identifiers info (and, if this gets approved, make also the note about Span ID & Trace ID working together).
Sounds like a good plan?
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.
iirc the original idea was to allow empty string to tracers that are unable to provide a single trace id (e.g. "do not support them", or more likely "this span has many trace IDs").
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 would recommend we keep the rules simple, and just say that either method may return an empty string, meaning that the method is not supported for that span.
I doubt implementations will provide one but not the other, but there's no need to make it a rule.
* | ||
* The empty string is a valid return value, while null is not. | ||
* | ||
* @return the trace ID for this context. |
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.
Could you please also add something like , or empty if the trace ID does not exist
?
Hey all, Went ahead and clarified in the docs the meaning of an empty Let me know if this is good to merge |
@@ -80,6 +80,5 @@ public Span startManual() { | |||
return NoopSpanImpl.INSTANCE; | |||
} | |||
|
|||
@Override |
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.
why is this removed?
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.
Damn, my bad.
public long traceId() { return traceId; } | ||
public long spanId() { return spanId; } | ||
|
||
|
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.
nit: should remove this line
@pavolloffay @objectiser Small fixes done ;) |
Hey all! Shall we merge this PR? |
Hi all, I have a small question regarding the format of the strings returned : do they have to obey the w3c format (hex strings) ? Or it's implementation detail ? Thanks |
@hypnoce there is no restriction. Basically, this should return the “ToString()” equivalent of whatever your tracer’s native ID’s are. I would like to add w3c specific methods later, but that spec is more complex than just ID’s and it’s not really adopted yet. These accessors are meant to work with any tracing system which supports OT. |
@tedsuo thanks for the update |
Hey all, Unless there's somebody against it, I will be merging this PR in the next days (it has already been approved by a pair of members of the community, and it has received proper tuning ;) |
* | ||
* Globally unique. Every span in a trace shares this ID. | ||
* | ||
* An empty String will be returned if there is no method implementation |
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.
"no method implementation" reads weird. So is "no trace id present".
Maybe we can simply say "empty string may be returned if the tracer does not support this functionality" and give examples of noop tracer and metrics decorator.
/** | ||
* Return the ID of the trace. | ||
* | ||
* Globally unique. Every span in a trace shares this ID. |
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.
Globally unique is incorrect. It is impossible to guarantee (random clashes are acceptable), so we should not state is as a requirement, or we should use SHOULD.
I would only say that it SHOULD be the same for all spans in a single trace.
* Unique within a trace. Each span within a trace contains a different ID. | ||
* | ||
* An empty String will be returned if there is no method implementation | ||
* or there is no span ID present. null is an invalid value return 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.
Similar comments about wording
/** | ||
* Return the ID of the associated Span. | ||
* | ||
* Unique within a trace. Each span within a trace contains a different ID. |
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.
SHOULD, not is.
@yurishkuro Done. Thanks again for the latest feedback. Let me know if this is good to go - else, let me know so I can tune docs a little bit more ;) |
* | ||
* Observe there is no restriction regarding the format of the returned value, as this | ||
* should simply be the equivalent of calling toString() on the native ID object | ||
* used by the tracer. |
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.
This wording is problematic. It says "should ... ToString" which in many cases is the wrong thing to do, e.g. for int64 IDs. If we want to make a recommendation, it would be that the string format SHOULD match the representation of the IDs in http headers.
The javadoc here should ideally be repeating word for word the specification.
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.
Oh, good point and good example. So I feel that we should remove this clarification then (if later we add something in the specification itself, we can add it here). Would that make sense to you?
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.
Yes, can remove it altogether
@yurishkuro Last edit is done. If this is ok, I will go ahead and merge later today ;) |
🚢 |
Merged :) |
* Deprecate the StringTag.set() overload taking a StringTag. (#262) * Implement Trace Identifiers. (#280) * Bump JaCoCo to use a Java 10 friendly version (#306) * Remove finish span on close (#301) * Deprecate finishSpanOnClose on activation. * Add ScopeManager.activeSpan() and Tracer.activateSpan(). * Clarify the API changes and deprecations. * Add an error reporting sample to opentracing-testbed. * Simple layer on top of ByteBuffer for BINARY format. (#276) * Add generic typed setTag/withTag (#311) * Allow injecting into maps of type Map<String,Object> (#310) * Add simple registerIfAbsent to global tracer (#289) * Split Inject and Extract Builtin interfaces (#316) * Deprecate ScopeManager.active() (#326) * Make Tracer extends Closable. (#329) * Do not make isRegistered() synchronized. (#333) * Deprecate AutoFinishScopeManager (#335)
This is done to implement Trace Identifiers, as covered in the RFC:
https://github.com/opentracing/specification/blob/master/rfc/trace_identifiers.md
Probably the most important question is whether we should have
traceId()
andspanId()
instead oftracerIdentifier()
andspanIdentifier()
respectively - probably the important bit here is that it could (as mentioned in the past) break Tracer implementations(At this moment, doing this renaming would break
MockTracer
, as the current methods would have to be renamed to something likelongTraceId()
andlongSpanId()
. I'm definitely up for actually breaking it, but I wanted to get some feedback before ;) )@yurishkuro @tedsuo @CodingFabian @wu-sheng