-
Notifications
You must be signed in to change notification settings - Fork 344
Add a new Binary Format to allow for variable SpanContext size #95
Comments
personally, my preference is for streaming-friendly carriers, such as the standard io.Writer we used in Go: type Writer interface {
Write(p []byte) (n int, err error)
} The key difference here is that the |
Yes, I also prefer streaming-friendly buffers. The way the Format is specified currently: public final static Format<ByteBuffer> BINARY = new Builtin<ByteBuffer>(); uses a ByteBuffer which is not a streaming-friendly carrier. A The beauty of the go implementation is |
IIRC, there was a desire to make the Playing devil's advocate, there might be something to be said for giving the caller a clear signal (i.e., the ByteBuffer's capacity) about how much space the implementation gets to use, baggage or not. Inasmuch as the injected data ends up getting sent over the network, that's an assurance a caller might prefer to have. |
@bensigelman, the size of the |
@gkumar7 understood. Just so I understand, is this issue in response to an actual production need, or a theoretical concern? What do you think about having |
Yes, we would like to have this in production. For now, we are using an upper bound for the I agree |
What I'd really want to do is call this new format In lieu of that, maybe we call it Speaking only for myself, I would accept a PR that added this. Though I would want others with more Java expertise to weigh in about pitfalls and/or alternatives, too. |
Those are much better names, I am willing to submit a pull request for this. @adriancole, @michaelsembwever, @wu-sheng any comments? |
I think a PR for a |
I prefer |
The existing binary format would only exist for compatibility reasons. At the next major version I would argue that we swap it out entirely. |
+1 on this. |
Any update on this and the corresponding pull request? Thanks! |
We stumbled upon this same need but the solution we came up with was a bit different, sharing it in case it might be of interest: instead of adding a new format we changed the signature of inject in our tracer a little so that it returns an instance of the carrier type and added an overload that doesn't receive a carrier object, just returns it. This is how inject looks like at the moment for us (Scala code):
This plays nicely with cases in which the caller actually wants to append to a already allocated ByteBuffer and additionally gives the option to not care at all and let the Tracer decide internally how much to allocate and use the returned ByteBuffer. Additionally to that, this second signature also plays nice with HTTP toolkits with immutable models (such as Spray and Akka HTTP) since now the caller can just take the returned TextMap and create a new copy of the HttpRequest with the additional headers. All in all, it seems to me that this solution breaks less things, makes the API a bit more flexible and leaves all the "trouble" of caring about how big the ByteBuffer has to be to the tracer implementation, if there is any interest in contrasting these solutions before deciding what gets into OT I'll be glad to participate! |
Closing as #223 is merged. |
A
Binary
format is defined in opentracing-api which uses aByteBuffer
as a carrier.ByteBuffer
needs to be allocated with a predetermined size for theSpanContext
to be injected. This in turn requires a size calculation of baggage.Possible approaches:
TextMap
) and format (similar toBINARY
). Essentially, this would provide a wrapper forbyte[]
.BinaryInjectorImpl and BinaryExtractorImpl would be library implementation-specific (below is an example)
This allows the library to not have to calculate the size of the
SpanContext
as this size will depend on how the context is converted to bytes inconvertSpanContextToBytes
(ie using avro, etc).The text was updated successfully, but these errors were encountered: