-
Notifications
You must be signed in to change notification settings - Fork 31
Add support for jaeger style uber-trace-id propagation #80
Conversation
See the discussion starting here: #67 (comment). |
Co-authored-by: Yoan Blanc <yoan@dosimple.ch>
I've accepted those two changes you suggested @greut, resolved the merge conflict with master, and signed the CLA (I assume the CLA is new as I don't remember it flagging up previously). |
there still seem to be conflicts, but more importantly it seems to miss tests? |
GitHub says there are no conflicts with the base branch? As for the tests, I mentioned in the original post of the PR that I'm not familiar with unit testing in Lua. If there's a quick guide you can point me to for how to run the test suite I'd be more than happy to write up some tests for the new functionality. |
try this: # install Pongo
git clone https://github.com/kong/kong-pongo
cd kong-pongo
make install
# adjust PATH if you have to here
cd ..
# clone plugin
git clone https://github.com/kong/kong-plugin-zipkin
cd kong-plugin-zipkin
# run tests
pongo run Additional info in the README.md. |
Unit tests added and a couple of issues fixed. As an aside, I noticed a couple of issues with parse_w3c_trace_context_headers (which I based the jaeger parse function on) while implementing unit tests for the jaeger headers functionality as they caused my unit tests to fail (the W3C tests pass coincidentally due to other factors). The first issue is that it returns 4 items on error, but only 3 when no error is returned.
vs
I suspect returning just nil 3 times and not also returning should_sample is the correct behaviour as that triggers the should sample logic. This is effectively the current behaviour anyway as the 4th item returned isn't referenced anywhere. kong-plugin-zipkin/kong/plugins/zipkin/handler.lua Lines 109 to 111 in 4825b09
If returning should_sample rather than nil (which would be false in most cases) is considered the right option instead, I can adjust the Jaeger parser to match that as well. The same function also doesn't return in one of the error cases, but is then caught by the version check just afterwards. I suspect this is just a case of a missing return line: kong-plugin-zipkin/kong/plugins/zipkin/tracing_headers.lua Lines 168 to 176 in b3a9807
Both are pretty trivial to fix, but I didn't want to clutter this PR with those changes too. |
@kikito mind having a look, since you did most of the maintenance on this repo iirc? |
Extending on the header_type config option, I've added support for jaeger-style uber-trace-id propagation. This implements #22.
I'm not overly familiar with unit testing in Lua however so I haven't made unit tests for the new functionality, but it has been tested manually and seems to work as intended including inter-op with downstream http services using the golang Jaeger library.
As an aside, I noticed setting header_type to eg w3c doesn't prevent the generation of b3 headers to the downstream service if no headers were found in the incoming request. It doesn't stop the configured header_type from being generated as well so not nothing breaks, but did seem a little odd?