-
Notifications
You must be signed in to change notification settings - Fork 155
Conversation
Implements extract and inject methods of the Binary codec to be able to inject/extract span context to/from bytearray. Signed-off-by: George Leman <gleman@mailgun.com>
please make sure |
Signed-off-by: George Leman <gleman@mailgun.com>
Lint issues are now resolved |
Codecov Report
@@ Coverage Diff @@
## master #304 +/- ##
==========================================
- Coverage 95.40% 95.40% -0.01%
==========================================
Files 25 25
Lines 1937 1980 +43
Branches 266 273 +7
==========================================
+ Hits 1848 1889 +41
Misses 56 56
- Partials 33 35 +2
Continue to review full report at Codecov.
|
Weird, one of the tests failed, PTAL. I would've thought this change would be mostly language-version agnostic. Unit Tests / unit-tests (py 3.5 tornado >=4,<5) (pull_request)
|
Signed-off-by: George Leman <gleman@mailgun.com>
The problem is that python has deterministic dictionary order only from 3.7 version https://stackoverflow.com/a/14959001 . So, if we have more than 1 item in baggage, we can't determine how they are going to be dumped into byte array, therefore byte arrays don't align. I don't see how to find the way around it, but only to have 1 item in the baggage. |
Fair enough. Another failure is with Python 2.7:
I am not opposed to dropping 2.7 from CI since it's past EOL since 2020-01-01, but we'd need a different PR to remove it first before merging this one. |
Which problem is this PR solving?
Resolves #224
Short description of the changes
Implements extract and inject method of the Binary codec to be able to
inject/extract span context to/from bytearray.
This commit implements binary context injection/extraction the same way as in jaeger-client for go. Inject method dumps span context into bytearray carrier and packs it in big endian order as follow:
8 bytes uint64 for first 8 bytes of trace id, 8 bytes uint64 for last 8 bytes of trace id, 8 bytes uint64 for span id, 8 bytes uint64 for parent id, 1 byte uint8 for flags, 4 bytes unit32 for number of baggage items.
If baggage exists, its packs it as follows:
4 bytes unit32 for number of bytes in key-name, key-name bytes, 4 bytes unit32 for number of bytes in value, value-bytes.
Extract method follows the same pattern.
Binary codec is compatible with golang jaeger-client implementation.