-
Notifications
You must be signed in to change notification settings - Fork 344
Variable size ByteBuffer implementation #99
Conversation
@gkumar7 sorry for the insane delay, I am looking at pending issues/PRs briefly. This branch has a merge conflict right now which is problematic... can you address? |
@bhs Thanks for the response! Seems like there were a few conflicting changes while this review was out, fixed now. |
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 WDYT?
@@ -79,6 +79,16 @@ private Builtin(String name) { | |||
public final static Format<ByteBuffer> BINARY = new Builtin<ByteBuffer>("BINARY"); | |||
|
|||
/** | |||
* The BINARY_HOLDER format allows for variable binary encoding of SpanContext state for Tracer.inject and |
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: "... variable-length binary ..."
|
||
/** | ||
* If no initial ByteBuffer was allocated for the BinaryHolder, the payload becomes the wrapped ByteBuffer. | ||
* Otherwise, the payload is placed in existent ByteBuffer. |
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: "existing"
* | ||
* @param payload a ByteBuffer. | ||
*/ | ||
public void addPayload(ByteBuffer payload) { |
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 addPayload
and getCarrier
? shouldn't the names be symmetric?
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.
Good point, fixed.
@bhs I don't have strong feeling about it. I never particularly liked the ByteBuffer-based API, I would rather use java.io streams. |
java.io.streams would be an interesting approach, although a bit tricky as there are both input and output streams. I do not think one Format specification will be able to handle both cases |
@gkumar7 that's why my original proposal for Format was not |
Ah, that makes sense. @bhs could we merge these changes for now so people have a workaround to the |
@gkumar7 I'd want to be careful, because merging this has implications, it becomes a requirement for all existing tracers to support this new carrier. |
Yes, very true, but I would argue that tracers should support a The |
@gkumar7 FYI, I have been thinking about this some more, apologies for the insanely high latency. I would like to merge this change, but not until we're close to cutting a new major release for OT-Java... maybe we can get rid of the other binary format altogether at that point (since we're introducing breaking changes anyway). I created a milestone for a 1.0 release, btw: https://github.com/opentracing/opentracing-java/milestone/1 |
@bhs Sounds good, I will keep this pr open until then. Thanks! |
@gkumar7 @yurishkuro I propose this change should get rolled into I'm wondering if anyone supports the current |
+1 to update |
+1 |
|
||
@Test | ||
public void testBinaryHolderWithSufficientCapacity() { | ||
System.out.println("binary holder with sufficient capacity"); |
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.
When/if we get this PR merged, we should get rid of these println
lines ;)
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.
As you might have noticed this pull request was hanging around for about 9 months. The opentracing-java
code has changed quite a bit since then. Initially, the structure of the test code in opentracing-impl
(this module has been removed) had test classes with a println
at the beginning of each method. Even I was not sure of the reason for this, but included similar lines in this pull request to remain consistent with the rest of the codebase.
So my impression, after going through the comments and #95, is that people need some kind of binary format now. So what about:
That way, we could have people use their code using the required binary format, and later on offer to a stream-based binary format. Opinions? |
@carlosalberto I'm not seeing the benefits of such approach, it just creates an API churn. The holder class is already new/breaking API, why not just define an equivalent of Go's io.Reader/io.Writer now and make it the only BINARY format? Those are very small interfaces. The holder class can be an adapter for them. |
I agree, let's go with a streaming BINARY format. Since this will be a breaking change, let's get it in on v31. |
@carlosalberto I added comment to #223 . |
@carlosalberto, thanks for creating a new pull request (although it would have been nice to make changes to the existing one). Regardless, I would agree with @malafeev that some example usage would be helpful. |
Closing as #223 is merged. |
This patch includes an implementation of a variable-size
BinaryHolder
to abstract away size calculation for aByteBuffer
. TheBinaryHolder
is flexible enough to be used as a replacement for theBinary
format. For more information, see #95.@bensigelman, @yurishkuro, @wu-sheng, @mabn, @michaelsembwever could you please review?