-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experimental tracing module (1/3): implement trace ids generation and propagation #2853
Conversation
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.
Hey,
thanks for it 🙇 I left a few comments.
d0ef025
to
1b4a7a9
Compare
Codecov Report
@@ Coverage Diff @@
## master #2853 +/- ##
==========================================
- Coverage 76.87% 76.70% -0.17%
==========================================
Files 217 224 +7
Lines 16619 16843 +224
==========================================
+ Hits 12776 12920 +144
- Misses 3039 3091 +52
- Partials 804 832 +28
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
9df375a
to
beeacb4
Compare
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.
LGTM 👍
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.
I'm not sure we should merge to master directly here, should we merge to a long-lived intermediate branch for aggregating the entire feature?
I considered it indeed, especially as there are two other PRs have to be merged if this first sequence makes it on time for release. I'll create one preemptively, and if other reviewers agree, I would rebase the current PR train on it 👍🏻 |
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.
LGTM!
I am glad we have smaller PRs.
In general it seems to me like 90% of this PR can be not under the js package. This likely will be useful in the future so that other js modules or parts of the system can use the tracing code.
This though likely should be done in a separate PR(s) as I don't want to add more things to be discussed for this PR chain.
Also I would've likely not introduced and registered the module in this PR but done it later.
Given that it seems like we agree to merge the other 2 PRs in this one and then merge this one - this is really not a problem that needs to be fixed. But is something I would like to note.
beeacb4
to
8b5b35c
Compare
Thanks a lot for your input @mstoykov; much appreciated. After giving it some thought, I agree with you; a lot of the code here could live in another, more reusable place in the repository. I took note and will try it in a future PR during our cooldown phase. I'm unsure where a valid alternative place for that code would be. Did you have something in mind? 💭 Maybe |
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.
The current code LGTM
Although we do not expose any of user-facing logic at this point, we register the "k6/experimental/tracing" module in k6 to prepare for further implementation of public APIs
6e1c51b
to
3889364
Compare
This commit defines a Client type which exposes an API similar to the HTTP module, and allows users to perform HTTP requests embedding a trace-context, and attaching their trace_id as an output metadata to their HTTP-related samples. It uses the HTTP module's request function under the hood, and wraps it with some "hook" logic to ensure the expected headers are present, and that the expected output metadata are emitted. The tracing client exposes an option-set allowing to use the three available propagation format. Other options such as sampling, and baggage are present for forward-compatibility, but will be implemented at a later point in time.
This commit exposes the Client constructor publicly as part of the k6/experimental/tracing module. From this point forward users will be able to instantiate the Client, and perform instrumented HTTP requests using it. This commit also adds a bunch of integration tests covering the expected behavior of the module's API.
Co-authored-by: Ivan <2103732+codebien@users.noreply.github.com>
Co-authored-by: Ivan <2103732+codebien@users.noreply.github.com>
…trumentHTTP Experimental tracing module (3/3): define and expose a `instrumentHTTP` function
Experimental tracing module (2/3): define and expose a `tracing.Client`
@oleiade can we get #2855 (comment) before merging this PR? |
@codebien considering it was brought up as a non-blocking request, I was planning to implement it in the PR implementing sampling (as I will have to modify the tests in the process anyways). If that's okay with you, I'd prefer to merge as is 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.
LGTM
About
To keep Pull Requests as small as possible and reduce the review burden, this PR is the first in a chain of 3 implementing the decided API design for the experimental tracing module.
This first PR exposes the
k6/experimental/tracing
module to k6 scripts but does not include any public APIs. Instead, it implements the trace id generation and propagation logic according to the W3C trace contexts specification.The code introduced in this PR will be used in further PRs by the
Client
implementation to produce a trace id to attach to a given request and emit as part of the output's data points metadata, as well as producing the trace context headers in the supported formats (W3C, B3, and Jaeger).Much of this PR's code and logic is essentially inherited and refactored from the xk6-distributed-tracing project.
Looking forward to your review 🙇🏻
References
Next: #2854