Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Binary format implementation #613

Merged
merged 3 commits into from
May 3, 2019
Merged

Conversation

ColinSullivan1
Copy link
Contributor

Hello from the NATS team!

We're adding a reference architecture for using the OpenTracing API over Jaeger in NATS. We've completed a NATS Open Tracing golang implementation, found here, and want to provide a java implementation as it's one of our more popular client languages and has been specifically requested. I noticed there was no binary format support, so added some here. It is wire compatible with the Jaeger golang client binary format.

I'd be happy to discuss on a call, zoom, or google hangouts if that would help.

Signed-off-by: Colin Sullivan colin@synadia.com

Which problem is this PR solving?

  • There is no binary format support in the Java client

Short description of the changes

  • Added binary format support, with tests and descriptive comments. I've mirrored what the go client has done, and have verified compatibility.

Signed-off-by: Colin Sullivan <colin@synadia.com>
@codecov
Copy link

codecov bot commented Apr 18, 2019

Codecov Report

Merging #613 into master will increase coverage by 0.46%.
The diff coverage is 93.51%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #613      +/-   ##
============================================
+ Coverage     89.29%   89.76%   +0.46%     
- Complexity      543      563      +20     
============================================
  Files            68       69       +1     
  Lines          1953     2061     +108     
  Branches        253      261       +8     
============================================
+ Hits           1744     1850     +106     
- Misses          131      132       +1     
- Partials         78       79       +1
Impacted Files Coverage Δ Complexity Δ
...aegertracing/internal/propagation/BinaryCodec.java 100% <100%> (ø) 17 <17> (?)
...n/java/io/jaegertracing/internal/JaegerTracer.java 88.96% <100%> (+0.19%) 26 <0> (ø) ⬇️
...a/io/jaegertracing/internal/JaegerSpanContext.java 97.91% <100%> (+0.04%) 30 <1> (+1) ⬆️
.../src/main/java/io/jaegertracing/Configuration.java 93.18% <63.15%> (-2.33%) 44 <0> (ø)
...gertracing/internal/reporters/LoggingReporter.java 90.9% <0%> (+9.09%) 5% <0%> (+1%) ⬆️
...rtracing/internal/reporters/CompositeReporter.java 100% <0%> (+28.57%) 7% <0%> (+1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf202a4...0c90673. Read the comment docs.

Copy link
Collaborator

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Looks great! Apart from a couple of very minor things, this is ready to be merged.

// Java defaults to big endian (network order), but enforce it just
// in case the carrier set the wrong byte order before passing it in.
if (buf.order() != ByteOrder.BIG_ENDIAN) {
throw new IllegalStateException("Carrier byte order must be big endian.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity: did you run into this in practice? This check seems strangely too specific :-)

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 didn't in this case, although did notice that ByteBuffer supports specifying byte order. I figured it'd be an extremely difficult issue to debug if someone someday implemented a carrier that set it to little endian, so figured this might save someone some time in the future. ;)

long spanId = 5678L;

TestBinaryCarrier buffer = new TestBinaryCarrier();
JaegerSpanContext spanContext = new JaegerSpanContext(0, traceIdLow, spanId, 0, (byte)0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have boundary tests here? If so, it would be nice to have them for the binary codec as well.

Copy link
Contributor Author

@ColinSullivan1 ColinSullivan1 Apr 30, 2019

Choose a reason for hiding this comment

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

Do you mean boundaries as in max values for trace ids, spanIds, etc? I didn't see any elsewhere (may have missed them), but can add them to the binary codec if you'd like. Do you need them for the PR?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't worry about this test for now: if we get an ID which is bigger than the max value, it would also fail for other codecs. I was also a bit concerned about parsing failures (baggage keys without values, for instance) , but I believe this first implementation is already a great improvement.

@@ -27,6 +27,7 @@
import io.opentracing.propagation.TextMap;
import io.opentracing.propagation.TextMapAdapter;

import java.nio.ByteBuffer;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps a left-over from a local test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, it is, I'll remove it. Thanks!

Signed-off-by: Colin Sullivan <colin@synadia.com>
@ColinSullivan1
Copy link
Contributor Author

@jpkrohling Would you have guidance on the test, or is this good to go? Thanks!

Copy link
Collaborator

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

LGTM and will merge this afternoon (UTC) if there are no objections.

@ColinSullivan1
Copy link
Contributor Author

Sounds good - thanks @jpkrohling!

@jpkrohling jpkrohling merged commit 0b2d27c into jaegertracing:master May 3, 2019
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.

2 participants