-
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
Tag metrics from different stages #796
Comments
@na-- I had today the same idea when observing different ramp-up configurations and thinking how to analyze their test results. The API could look like: stages: [
{ duration: "30s", target: 200, tag: 'ramp-up' },
{ duration: "5m", target: 200, tag: 'baseline' },
{ duration: "30s", target: 0, tag: 'ramp-down' }
], Metrics/Data would be tagged as: |
Something like this would have to wait for #1007, but it shouldn't be too difficult... |
Cross-posting to note another use case for this feature, related to setting thresholds only for specific stages: #1136 (comment) |
@ppcano this is already implemented? |
@joseray, no, it's not yet implemented. You can watch this issue, since we'll close it when we implemet the feature. |
This issue would be useful, though I think it's best if we focus our energies on other similar ones that are more flexible. If we had #1320, i.e. be able to get the number of the current stage for And, depending on how we choose to implement #884, #1724 and #1321, we'd get much more flexible tagging as well... I'm not going to close this issue, but I'll tag it as |
Just leaving a note here that I spoke with a customer yd that wanted to be able to set thresholds on a specific stage (the steady-state after a ramp-up stage) and asked if this was possible. If this functionality existed it would be possible to also set up thresholds limited to a certain stage, such as a steady-state stage. Edit: I'll add also that a possible workaround to this could be separating stages via scenarios and setting up a threshold filtered by scenario name. Thanks @sniku for this suggestion. |
Few updates for this issue:
exec.vu.tags['stage'] = 'ramp-up'
|
We have merged #2172, so from the next upcoming release, a code like the following example could be used for tagging the running stage. import exec from 'k6/execution';
import {sleep} from 'k6';
export const options = {
stages: [
{ duration: '10s', target: 10 },
{ duration: '20s', target: 20 },
{ duration: '10s', target: 0 },
]
};
//export const options = {
//scenarios: {
//example: {
//executor: 'ramping-vus',
//stages: [
//{ duration: '10s', target: 10 },
//{ duration: '20s', target: 20 },
//{ duration: '10s', target: 0 },
//]
//}
//}
//};
export default function() {
let stage = getStage()
exec.vu.tags['stage'] = `stage#${String(stage)}`
// write your code doing some work here
// ...
//
// some work simulation
sleep(2)
}
function getStage() {
let stages = [];
if (options.hasOwnProperty('stages')) {
stages = options.stages;
}
if (options.hasOwnProperty('scenarios')) {
stages = options.scenarios[exec.scenario.name].stages;
}
let sum = 0;
let elapsed = (new Date() - exec.scenario.startTime) / 1000;
for (let i = 0; i < stages.length; i++) {
sum += parseInt(stages[i].duration)
if (elapsed < sum) {
return i
}
}
return stages.length-1
} |
In the future, we might still consider to implement the #796 original proposal as a final step, where it would add the stages: [
{ duration: "30s", target: 200, tags: { stage: 'ramp-up' } },
{ duration: "5m", target: 200, tags: { stage: 'baseline' } },
{ duration: "30s", target: 0, tags: { stage: 'ramp-down' } }
], However, analysing detail turns out that it has some caveats we should consider:
For these reasons, we decided to implement stage identification and tagging as an intermediate step by providing some helpers as part of the Proposal
jslib helper functions detailsCreate new helper functions in the getCurrentStageIndexIt returns an integer detecting the index from the function getCurrentStageIndex() Number { } tagWithCurrentStageIndexIt adds a function tagWithCurrentStageIndex() {
exec.vu.tags['stage'] = getCurrentStageIndex()
} tagWithCurrentStageProfileIt auto-detects and tags when a stage is a ramp-up, a ramp-down or a steady stage. The detection checks the target's value in the previous stage and returns:
|
k6 v0.38.0 is released! 🎉 It contains the previously announced functions. We added the The functions are based on the new k6/execution.test.options API so k6 |
After internal discussion, we decided to close this issue since the desired need could be achieved with #796 (comment) If we find out something should be improved, we could consider re-opening this issue. |
Reading through this issue, I liked the idea of automatically tagging the metrics from different stages, I think it could be useful when analyzing the results later.
Also, instead (or in addition) of those system tags, we might want to add the option of users to add their own
key=value
tags to the stages, like they currently can do whole test runs or with individual metrics. Though this option would probably have to be part of the new configuration mechanism that would be required for the arrival-rate based executorThe text was updated successfully, but these errors were encountered: