Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Add support for W3C Trace Context #69

Closed
wants to merge 3 commits into from
Closed

Conversation

subvocal
Copy link
Contributor

Accepts W3C Trace Context header and prioritizes the W3C Trace Context when present.

Emits W3C Trace Context header whether it was present on the incoming request or not. Would like feedback on whether this behavior should be configurable.

Victor Soares and others added 3 commits February 16, 2020 22:35
Add tests.

Update header set to be lowercase.

Optimize the pattern matching of the header value.

Refactor parsing function for ease of reading.

Fix linting.
Copy link

@ecourreges-orange ecourreges-orange left a comment

Choose a reason for hiding this comment

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

LGTM, thanks Victor,
I am not a maintainer of this repo, but I think as far as the configurability,
it can be done later in another PR.
The only obvious drawback I see is the added network cost of around 100 bytes per proxied request,
I'll leave the maintainers be judge of that.

@kikito kikito mentioned this pull request Mar 9, 2020
@@ -136,6 +136,13 @@ if subsystem == "http" then
-- Want to send headers to upstream
local proxy_span = zipkin.proxy_span
local set_header = kong.service.request.set_header

-- Set the W3C Trace Context header
-- TODO: Should W3C traceparent header be set even it wasn't on the incoming request?
Copy link
Member

Choose a reason for hiding this comment

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

I asked myself a very similar question when implementing the b3 single header (#66).

In order to minimize the amount of configuration involved, I decided to take a salomonical approach: The plugin understands b3 single headers, but it only produces "regular" headers (such as x-b3-traceid).

It seemed an ok solution for the time but since we are adding a third kind of header I think we should control it via a new config file. A possible design would be:

options.header_types is a new config option with 3 possible values:

  • preserve: the plugin produces whatever format it receives on each request
  • b3-single: always use b3 single
  • b3: always use the "regular zipkin" headers, such as x-b3-traceid
  • w3c-trace-context: use the format proposed on this PR

When options.header_types is set to anything other than preserve, and the trace headers don't match (for example the config is b3-single but we receive a w3c-trace-context) then we should send both kinds of headers. We should also log a warning about the inconsistency.

If you want me to take over adding this, please let me know.

Copy link

Choose a reason for hiding this comment

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

@victorNewRelic, do you intend to continue with this patch?

@kikito
Copy link
Member

kikito commented Mar 31, 2020

@victorNewRelic @ecourreges-orange @seh

I've added the features I mentioned in #75, so I will be closing this PR in favor of that one. Thanks a lot!

@kikito kikito closed this Mar 31, 2020
@subvocal
Copy link
Contributor Author

@kikito - Great!! I'll test the new PR.

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.

4 participants