-
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 (2/3): define and expose a tracing.Client
#2854
Experimental tracing module (2/3): define and expose a tracing.Client
#2854
Conversation
Codecov Report
@@ Coverage Diff @@
## experimental/tracing-module-propagators #2854 +/- ##
==========================================================================
Coverage ? 76.68%
==========================================================================
Files ? 222
Lines ? 16796
Branches ? 0
==========================================================================
Hits ? 12880
Misses ? 3086
Partials ? 830
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. |
Heads-up @olegbespalov, I removed you from reviewers to ensure consistency in the PR-chain. This PR is indeed part of a chain, and the bot has automatically selected @imiric and @codebien for the first and last one. I aligned the reviewers for this one as I believe it will make the review easier for reviewers if they review the three of them. If you wish to review this module, and have time for it, feel free to add yourself back or ping me to do; I'll gladly do so 🙇🏻 👍🏻 |
@oleiade can you change the base branch to |
@codebien done ✅ thanks for pointing it out 🙇🏻 |
1b4a7a9
to
e3463aa
Compare
9dbd43f
to
f6f06f5
Compare
9df375a
to
beeacb4
Compare
f6f06f5
to
e6452eb
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.
Looks good in general but I have a bunch of comments
var ( | ||
isW3C = i.Propagator == W3CPropagatorName | ||
isB3 = i.Propagator == B3PropagatorName | ||
isJaeger = i.Propagator == JaegerPropagatorName | ||
) | ||
if !isW3C && !isB3 && !isJaeger { |
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.
Is there a reason we just don't do the equal comparision directly in the if
sttatement?
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.
It's a style recommendation I discovered in the Google style guide, which, I find, helps with readability, as the if
statement ends up much shorter and reads almost like a sentence. I'm not hung onto this though, if you have a strong opinion against that, I'm happy to drop 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.
@oleiade Added a few comments.
It should already be possible to introduce an integration test here, so I would add it. WDYT?
e6452eb
to
ae5537e
Compare
beeacb4
to
8b5b35c
Compare
936303a
to
ba46f51
Compare
@codebien I've rebased the PR chain on the latest state of |
5f006aa
to
0821167
Compare
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.
0821167
to
4b0fa98
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.
Left a nitpick about style with common.Throw, but LGTM even with it
assert.NotNil(t, gotParams) | ||
gotHeaders := gotParams.Get("headers").ToObject(rt) | ||
assert.NotNil(t, gotHeaders) | ||
gotTraceParent := gotHeaders.Get(traceparentHeaderName) | ||
assert.NotNil(t, gotTraceParent) | ||
assert.Equal(t, testTraceID, gotTraceParent.String()) |
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.
nit: In general I prefer to user require
as it will stop the execution directly which helps in two ways:
- I won't get a wall of text when i break somethign listing 20 things that went wrong, when the first thing that went wrong is likely to tell me what I neeed to know to fix it.
- In this particular case
assert.NotNil
failing means that hte test will panic with nil exception. Arguably you can mix assert and require, but I have rarely been in a case taht this makes sense 🤷
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.
In general, I try to use require
when it's a requirement for the test, as in: "this is required even to perform the test in the first place", and use assert
for stuff that's tested. I guess I approach it in a rather semantic way, "this is required to perform the test", and "this asserts the behavior of the tested code is correct".
It's also how I understood it to be used in the tests I've been exposed.
Do you have a strong opinion on this, or would it be fine if I keep it like this? I'm okay with either way.
Co-authored-by: Ivan <2103732+codebien@users.noreply.github.com>
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.
Blocking so we remember to rebase the fixups before merging
Won't this just be "squashing" it in the previours PR ? |
Indeed, I would expect to squash this in the 1/3 PR, which would obfuscate the fixups. If you have a strong opinion on this I'm happy to rebase them anyways though 👍🏻 |
Co-authored-by: Ivan <2103732+codebien@users.noreply.github.com>
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.
Indeed, I would expect to squash this in the 1/3 PR
I thought we would keep the history, if we are going to squash then okay for me.
…trumentHTTP Experimental tracing module (3/3): define and expose a `instrumentHTTP` function
About
To keep Pull Requests as small as possible and reduce the review burden, this PR is the second in a chain of three implementing the decided API design for the experimental tracing module.
This second PR builds upon #2853 and adds a
Client
type tok6/experimental/tracing
. This type mimics the relevant part of the HTTP module to allow users to perform HTTP requests embedding a trace context while also attaching the produced trace id as output metadata on the HTTP-related samples. In the larger context of the module's goal, theClient
should hold the underlying logic for theinstrumentHTTP
function that's to come in the third PR. Still, it also allows users to selectively trace requests and reconfigure their tracing configuration on the fly if they wish.To achieve that, it is built upon the HTTP module's request function, which wraps with hooking logic to ensure the expected headers are produced and present and emit the output metadata.
The
Client
is configured using an options object that lets the user select the propagation format they use. Other options, such as sampling rate, and baggage, have been added for forward compatibility and convenience but will lead to "not implemented" errors if used.Example of it in action
In order to observe this example in action, I recommend to run it with the
--http-debug
too. That way you'll be able to observe theTraceparent
header being added (note that when using theb3
orjaeger
propagators, the header is named differently.Review
The commits have been organized to be progressive, and make sense as a sequence; thus, you should review them in order.
References
Previous PR: #2853