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

Initial opentracing-java API #13

Merged
merged 7 commits into from
Mar 9, 2016
Merged

Initial opentracing-java API #13

merged 7 commits into from
Mar 9, 2016

Conversation

michaelsembwever
Copy link
Contributor

Last chance to review before all this work hits master.

This is a combination of #4 , #10 , #12 , #8 , and #9 coming into master.

The initial implementation behind this sits in #11

ping @adriancole @bensigelman @yurishkuro

Adrian Cole and others added 6 commits January 20, 2016 17:43
This is mostly a port from python, except for a couple notes.
* Adds an IllegalArgumentException to `fromXXX`, if the input is malformed.
* Adds `EncodedTraceContext` type as Java cannot return multiple results.

Any other changes are unintentional.

See https://github.com/opentracing/api-go/tree/master/opentracing
Remove TraceContextSource, as methods from it now belong in Tracer.
Remove Tracer.joinTrace(..) as Span.startChild(..) already does this.

ref:
 - opentracing/opentracing.io#42
 - #7
Simplify the API: removing TraceContext and TraceContextSource
…ge, payload)` method.

Rationale:
 This is the simplest solution, and an appropriate plumbing API, that solves the use-case of
info/error and parameterised message formatting.
 OpenTracing API may adopt a porcelain API for those info/error logging-style methods down the
road once the plumbing api has been battle tested a bit more.

reference: #9
 - Only span creation method is in Tracer.startSpan(..)
 - Add Tracer's inject(..) and join(..) methods

reference: #10

/** Takes two arguments:
* a Span instance, and
* a “carrier” object in which to inject that Span for cross-process propagation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the word "carrier" is very vague when in practical terms it is very often http headers or some other side-channel (like RPC envelope). might be best to make an example of a carrier.

"For example. tracer.inject(span, httpRequestHeaders);"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@codefromthecrypt
Copy link
Contributor

Looks like an accurate, minimal specification of OT as defined. :shipit: when ready

michaelsembwever added a commit that referenced this pull request Mar 3, 2016
michaelsembwever added a commit that referenced this pull request Mar 3, 2016
public interface Span {

/**
* Sets the end timestamp and records the span.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the start() debate, we do need some way to override the finish timestamp in order to do after-the-fact translation of span-like logs, etc. So, void finish(long timestamp)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the start() debate, we do need some way to override the finish
timestamp in order to do after-the-fact translation of span-like logs, etc.
So, void finish(long timestamp)?

Brave, which is based on duration not endTs, as this in the span-scoped
tracer:
/**

  • Completes the span, which took {@code duration} microseconds.
    */
    public void finishSpan(long duration)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am imagining – perhaps incorrectly – that the caller of the explicit-timestamp version has a raw timestamp rather than a duration on hand (i.e., that they are basically doing log processing / translation). FWIW, I think that tracing impls are better off tracking duration since it's not subject to clock-skew cruelty.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am imagining – perhaps incorrectly – that the caller of the explicit-timestamp version has a raw timestamp rather than a duration on hand (i.e., that they are basically doing log processing / translation). FWIW, I think that tracing impls are better off tracking duration since it's not subject to clock-skew cruelty.

This isn't just for log scraping. this is for any case when OpenTracing
isn't used to create events. Many events are structured and have both start
and endTs, but duration is often recorded separately for more precision.

The problem is that timestamps in java are measured in millis accuracy. To
accurately align nanos ticks with current time is non-trivial and rarely
implemented. duration practice is to measure with nanos ticks. That's the
rationale anyway, and why zipkin/brave has duration.

Anyway it is a different topic, in OT status quo, endTs sounds like the
right choice?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely don't feel strongly about finish-time vs duration... I'm making an educated guess about what's most convenient most of the time, but if others feel strongly, I do not :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm leaving the addition of finish(timestamp) as outside the scope of this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bhs
Copy link
Contributor

bhs commented Mar 4, 2016

I made a bunch of comments... anything that requires new code (as opposed to changes) I am fine doing in a follow-on; it would be helpful to have something in master at this point.

@michaelsembwever
Copy link
Contributor Author

All points addressed.
If no further objections will merge to master in 24hrs.

@bhs
Copy link
Contributor

bhs commented Mar 6, 2016

@michaelsembwever I would prefer that we drop the comments about the required carriers before merging into master; but since the required carriers are up in the air right now, we'll have to revisit them (the comments) soon anyway.

@bhs
Copy link
Contributor

bhs commented Mar 7, 2016

(LGTM!)

michaelsembwever added a commit that referenced this pull request Mar 9, 2016
@michaelsembwever michaelsembwever merged commit f60cfec into master Mar 9, 2016
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