-
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
Emit iterations metric as part of netext.NetTrail #1203
Conversation
Resolves: #1203 (comment) Because the iterations metric is now emitted before the minIterationDuration sleep is done--possibly what should've been the correct behavior--it changes these test expectations. And since the previous test wasn't checking for more than one minIterationDuration loop, it makes sense to tweak the settings a bit to gather more data.
904c072
to
6df3a45
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 in general. As I mentioned in the inline comment, it would definitely be better if we refactor it, but we should probably do that in a separate PR, most likely in #1007 or after it.
Resolves: #1203 (comment) Because the iterations metric is now emitted before the minIterationDuration sleep is done--possibly what should've been the correct behavior--it changes these test expectations. And since the previous test wasn't checking for more than one minIterationDuration loop, it makes sense to tweak the settings a bit to gather more data.
6df3a45
to
d321c19
Compare
Codecov Report
@@ Coverage Diff @@
## master #1203 +/- ##
==========================================
+ Coverage 75.12% 75.29% +0.16%
==========================================
Files 147 147
Lines 10709 10709
==========================================
+ Hits 8045 8063 +18
+ Misses 2199 2181 -18
Partials 465 465
Continue to review full report at Codecov.
|
I fixed the test issues, but it involved some test refactoring, so let me know if everything makes sense there, or if additional tests are needed for this. |
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.
As I mentioned in the inline comment, I feel like we need a small test that confirms that iterations
aren't emitted for actually incomplete iterations.
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.
Ah, can you put the sleep(0.15);
after the testCounter.add(1);
- the reason it was done that way is that the original test actually tested that for incomplete iterations, metrics that were reached, like the testcounter
, will still be emitted, even though iterations
won't be. This was a problem before, so the test was explicitly added to test for it when we fixed it.
b127010
to
484cafd
Compare
Not a fan of this bandaid, but maybe it resolves the AppVeyor-exclusive failures. See #1203 (comment)
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;
A slight nit looking at the code
dest := new(...)
*dest = *source
can be simplified as
dest := *source
and using returning &dest
Although I am not very certain if it's not worse in the readability department ... so I don't know if it's good idea to change it given it's a line ;)
@mstoykov Also I'll leave it as is unless someone insists. :) |
stats/cloud/collector.go
Outdated
// Check if aggregation is enabled, | ||
if c.config.AggregationPeriod.Duration > 0 { | ||
newHTTPTrails = append(newHTTPTrails, sc) | ||
} else { | ||
newSamples = append(newSamples, NewSampleFromTrail(sc)) | ||
} | ||
case *netext.NetTrail: | ||
sc = replaceTagsNet(sc) |
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.
Wait, wat? 😄 We don't need to replace any tags for iter_li_all
/netext.NetTrail
. The only tag we need to replace is url
, and url
only applies to HTTP URLs
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.
:D Right, I wondered about that, but considered we're also tagging network samples with the same tags as HTTP samples to associate them with the same HTTP context.
So is the test added in TestCloudCollector
(https://github.com/loadimpact/k6/pull/1203/files#diff-11a7e92298be39c5269425095fb75dc9R283-R326) a fabricated scenario? Meaning NetTrail
would never be tagged with url
to begin with, right? Because that test was the reason for adding this replacement for NetTrail
as well, but it seems unnecessary, or at least should use more realistic tags.
Let me know, but either way, I'll remove this replacement.
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.
Looking at the test now, it should probably be in its own separate test, not a part of the already huge TestCloudCollector()
Meaning NetTrail would never be tagged with url to begin with, right?
Yes, at least not by k6. If users are masochists, they might run k6 with global per-test-run manually set tags like k6 run --tag name=blah --tag url=test script.js
, but we don't care about that. As a system tag, k6 only appends url
to HTTP requests and websocket connections and name
only for HTTP requests.
So yes, please remove the replacement and refactor the test.
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.
OK. Agreed on the separate test. I was lazy and wanted to reuse the existing setup boilerplate in TestCloudCollector
, and since it has a nice generic name and already tests HTTP samples, I figured it was a good place for it. :)
But sure, I'll see if I can add a smaller one for this metric change only.
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.
Done, see f032c5f.
It might be a good idea to add tests for Executor.Run
(to ensure we're not sending the metric anymore) and for Dialer.GetTrail
, but I didn't think it was strictly required, and being lazy again... But let me know if there should be more tests.
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.
See the inline comment - not sure where the tag replacement for netext.NetTrail
came from, but it shouldn't happen. The only issue we have is with different url
, same name
HTTP metrics. The iteration metric doesn't even have an url
tag or a name
tag.
Resolves: #1203 (comment) Because the iterations metric is now emitted before the minIterationDuration sleep is done--possibly what should've been the correct behavior--it changes these test expectations. And since the previous test wasn't checking for more than one minIterationDuration loop, it makes sense to tweak the settings a bit to gather more data.
b6650a5
to
43d818c
Compare
Resolves: #1203 (comment) Because the iterations metric is now emitted before the minIterationDuration sleep is done--possibly what should've been the correct behavior--it changes these test expectations. And since the previous test wasn't checking for more than one minIterationDuration loop, it makes sense to tweak the settings a bit to gather more data.
43d818c
to
7c1a49e
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.
Besides the minor nit in the test LGTM
Resolves: #1203 (comment) Because the iterations metric is now emitted before the minIterationDuration sleep is done--possibly what should've been the correct behavior--it changes these test expectations. And since the previous test wasn't checking for more than one minIterationDuration loop, it makes sense to tweak the settings a bit to gather more data.
7c1a49e
to
9cd26e4
Compare
This removes emission of
metrics.Iterations
as a standalone metric, and instead bundles it as part ofnetext.NetTrail
, and only fordefault
functions.This is done to reduce the amount of individual metrics, and thus traffic, sent to backends, and has minor user-facing impact mentioned in #1189.
Closes: #1189