-
Notifications
You must be signed in to change notification settings - Fork 343
An RFC for SpanContext, References, as well as changes to carriers #32
Conversation
* @see io.opentracing.Tracer#inject(SpanContext, Format, Object) | ||
* @see io.opentracing.Tracer#extract(Format, Object) | ||
*/ | ||
public class BuiltinFormats<R, W> implements Format<R, W> { |
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.
@yurishkuro I went with BuiltinFormats
instead of Formats
-- seemed to better emphasize that non-builtin extensions were feasible.
* undefined behavior. | ||
*/ | ||
void finish(); | ||
/** |
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.
(indenting was off throughout this file)
|
||
/** | ||
* BuiltinFormats encapsulates the inject()/extract() carrier formats that all Tracer implementations must support. | ||
* |
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.
probably worth it to add docs for these generic params.. like..
* @param <R> foo used by {@link foo#bar} to bar things
* @param <W> baz used by {@link baz#qux} to qux things
Without the Format stuff from #31 i'm +1 on merging. With the Format stuff it's currently a -1 from me, unless further discussion helps me see the light. |
private Type type; | ||
private SpanContext referee; | ||
|
||
public enum Type { |
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 am ok with this being an enum, as a list of build-in reference types, but the type
field in the Reference
class needs to be of a comparable type, not this enum. Otherwise this is not extensible without OT API release.
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.
we talked about this briefly off github -- I've gone with Comparable
where reference types are needed and am using Strings for the builtin ones.
Meta-comment: I'm going to try and split the (controversial) |
The big picture in this commit: - Get rid of the contentious stuff around Format for this PR - Just define reference *types*; no need for a Reference class given Java's SpanBuilder approach - Add an HttpHeader* carrier so we can discuss that properly - Cleanups
Thanks so much for the comments, all, PTAL. |
my non-binding opinion is that the type complexity of Complex apis in java usually breed libraries that hide their complexity. If we want to avoid some side-project called OpenTracing-Lite, I'd suggest highly that we simplify as much as possible the front-door of this api. |
*/ | ||
SpanBuilder withParent(Span parent); | ||
SpanBuilder addReference(Comparable referenceType, SpanContext referencedContext); |
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 using Comparable, we should provide rationale for the choice, for example, why ordering matters. It is distracting otherwise.
A guess is that we are expecting an implementation to have multiple parents and need to know the parent vs adopted vs step-parent? I suppose we are expecting the implementation to retain the order?
Another note, Comparable has a type parameter <T>
which would lead to this method having a compiler warning.
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.
Yeah, I'll just change to Object
. I was responding to an earlier comment about the downside of using the (now obliterated) Reference.Type
enum, as enums by definition are not externally extensible. I don't think the use case for a global ordering nearly compelling enough... we really just want equality comparisons.
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.
*/ | ||
SpanBuilder withParent(Span parent); | ||
SpanBuilder addReference(Object referenceType, SpanContext referencedContext); |
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 understand reference types need to be extensible, but is there a need to make them arbitrary types? Why not String
?
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 all we need is equals()
, I guess I would ask why String?
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 we had a Symbol
type in Java, it would be that. Failing that, isn't it better that we at least pick something that can be switch
'ed on and has value semantics?
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.
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 is a String now.
@adriancole @michaelsembwever @yurishkuro @tinkerware Since the (controversial) I'm presently fixing the rest of the (github) repo to work along with these changes... it does require some surgery here and there but most of the diff will be uncontroversial. It's also far less important since OT callers don't depend on any of the impl helpers directly, of course. Setting expectations: I'd like to merge this PR in 24-36h or so unless substantial new issues are raised. |
*/ | ||
<T> void inject(Span span, T carrier); | ||
<C> void inject(SpanContext spanContext, C carrier); |
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.
What's the point to the C
type parameter when it does not constrain anything? If we are saying that a more elaborate format API is later work, we can just leave the carrier type Object
for now, though it seems to me that there could at least be a marker interface for carriers.
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 agree, this C
makes it look like there's more to the carrier
type than just an Object
. +1 to drop it.
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 was inherited from the code at master...
Aside from making the documentation more explicit (@param <C> ...
), I can't provide any particular justification. I think this is code @michaelsembwever wrote, so I might be missing part of the rationale. (The documentation aspect is not trivial, though...)
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.
It helps implementations. See AbstractTracer for example.
It also creates a stub to explain Carrier types.
No biggie either way for me.
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 seems okay to me, assuming that carrier/format API is not in its final form. |
|
||
Span http = tracer.buildSpan("HandleHTTPRequest") | ||
.withParent(feed) | ||
.asChildOf(parentSpan.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.
@bensigelman similar to Node/Python, we can overload this to asChildOf(parentSpan)
lgtm |
👍 |
* @return the value of the baggage item identified by the given key, or null if no such item could be found | ||
*/ | ||
String getBaggageItem(String key); | ||
} |
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.
In go a method to iterate through all baggage items were introduced. Should you have it here as well ?
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 like this to happen in a followup... there are some subtleties that you brought up re immutability that I think are relevant here (namely, if we know that SpanContexts are immutable, the interface can be zero-copy and return an iterator and be threadsafe... otherwise I'd rather do something like what we did in Go and have the SpanContext impl invoke a callback repeatedly).
(ed: I misremembered and thought tinkerware had brought up the immutability issue -- it was @dawallin!)
Much of the opentracing-impl stuff is dated to when we separated tracer state and baggage. I've removed some of it and I think an argument could be made to get rid of the rest, here, too; or maybe turn it into basictracer-java or similar.
Make AbstractSpan abstract again (i.e., let subclasses handle context()).
a72e548
to
ff2d9ff
Compare
Okay -- I changed a bunch of stuff and fixed the build and tests in the rest of this repo (including NoopTracer, which is probably the only part anyone actually uses at this point). |
* | ||
* @return the SpanContext that encapsulates Span state that should propagate across process boundaries. | ||
*/ | ||
SpanContext getContext(); |
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 changed this to getContext()
since this is Java :)
(I'd internalized Go's no-get getter convention, I guess)
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.
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.
(and if there are no further concerns, I will merge this sometime tomorrow) |
0e5a342
to
623db61
Compare
@adriancole I dropped the |
Okay, as promised, I'm merging this now. Thanks for all of the feedback. #31 and opentracing/opentracing.io#106 are still open and could impact this API going forward. |
Apparently IntelliJ decided to "intelligently" (sic) move some files to the wrong directories, resulting in some noise here. This change re-introduces much of the type-enforcement lost during #32
I would love feedback about the API here... once we converge, we can decide what to do about the rest of this (github) repo (the impl helpers, etc).
Please look at #31 and opentracing/opentracing.io#99 for background and motivation.
I'll add a few PR comments inline as well.