Skip to content
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

Add additional graphs to the HTML report #394

Merged
merged 23 commits into from
Dec 13, 2021

Conversation

slashrsm
Copy link
Collaborator

@slashrsm slashrsm commented Nov 24, 2021

Closes #246.

Graphs

  • Errors per second
  • Average response time per second
  • Active users per second
  • Active tasks per second

Screenshots

Errors

Screenshot 2021-11-24 at 16-07-12 Goose Attack Report

Response time

Screenshot 2021-11-24 at 19 01 35

Active users

Screenshot 2021-11-24 at 19 25 52

@slashrsm slashrsm force-pushed the 246_additional_graphs branch from e06ea92 to 8821e12 Compare November 24, 2021 17:32
@slashrsm slashrsm marked this pull request as ready for review November 24, 2021 19:43
Copy link
Member

@jeremyandrews jeremyandrews left a comment

Choose a reason for hiding this comment

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

This is wonderful to see! I'm looking forward to getting this merged once my comments are addressed. There also seems to be a bug in the generation of the graph during startup, when startup is >=20 seconds (more or less):
image

I also would prefer to see the graphs mixed in with the relevant data, and graph first data next. So, show the requests per second graph, then show the requests break down, etc.

src/metrics.rs Show resolved Hide resolved
src/metrics.rs Outdated Show resolved Hide resolved
src/metrics.rs Outdated Show resolved Hide resolved
src/metrics.rs Show resolved Hide resolved
src/metrics.rs Outdated Show resolved Hide resolved
src/metrics.rs Outdated Show resolved Hide resolved
src/metrics.rs Outdated Show resolved Hide resolved
src/metrics.rs Outdated
for set in self.task_sets.iter() {
tasks += set.tasks.len();
}
self.metrics.record_users_tasks_per_second(tasks as u32);
Copy link
Member

Choose a reason for hiding this comment

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

Why do we calculate this before merging in the received statistics? Shouldn't we merge statistics and then count?

Copy link
Member

Choose a reason for hiding this comment

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

Also, why does this happen here, instead of in the same place as where we record the other metrics for the graphs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why do we calculate this before merging in the received statistics? Shouldn't we merge statistics and then count?

I don't think this would change anything. This is simply counting tasks and users at this point and I don't think other stats would influence that.

Also, why does this happen here, instead of in the same place as where we record the other metrics for the graphs?

Because number of tasks do not need to be recorded for every request that we are collecting stats for; we need to do it just once.

Copy link
Member

Choose a reason for hiding this comment

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

This still feels like an illogical place to perform this function, especially if we don't actually care whether or not we receive the metrics (the purpose of this function).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. Moved it to GooseAttack::sync_metrics(). Will that work?

src/metrics.rs Outdated Show resolved Hide resolved
src/metrics.rs Outdated Show resolved Hide resolved
@slashrsm slashrsm force-pushed the 246_additional_graphs branch from e948168 to 5e96220 Compare December 6, 2021 21:31
src/metrics.rs Outdated Show resolved Hide resolved
@slashrsm slashrsm force-pushed the 246_additional_graphs branch from 02cee74 to 66e5e53 Compare December 7, 2021 19:19
@slashrsm slashrsm force-pushed the 246_additional_graphs branch from b157f45 to fa52a52 Compare December 7, 2021 21:07
src/metrics.rs Outdated Show resolved Hide resolved
@slashrsm slashrsm force-pushed the 246_additional_graphs branch from fa52a52 to d944a5d Compare December 8, 2021 21:26
src/metrics.rs Outdated Show resolved Hide resolved
src/metrics.rs Outdated
Comment on lines 2235 to 2255
expand_per_second_metric_array(&mut self.users_per_second, second, 0);
let last_user_count = match self.users_per_second.last() {
Some(last) => *last,
None => 0,
};
expand_per_second_metric_array(&mut self.users_per_second, second, last_user_count);
self.users_per_second[second] = self.users;

expand_per_second_metric_array(&mut self.tasks_per_second, second, 0);
let last_task_count = match self.tasks_per_second.last() {
Some(last) => *last,
None => 0,
};
expand_per_second_metric_array(&mut self.tasks_per_second, second, last_task_count);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Users and tasks metric are not tied to a specific request so we still need to rely on Utc:now(). But this is OK since we will hit this immediately after a new user was spawned so the data should be accurate. The only thing we need to make sure is to carry the last count over the seconds we missed while the thread was sleeping to avoid gaps on the graph.

Copy link
Member

Choose a reason for hiding this comment

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

Tasks metrics has thread_user.started.elapsed().as_millis(), which is what is in the logs and is already accurate, why can't we use that?

Copy link
Member

Choose a reason for hiding this comment

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

And for users, why can't we also use thread_user.started?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I used GooseTaskMetric.elapsed, which also required me to move this code into receive_metric() again. But this time it is in the place where task metrics are received, so I think that it makes more sense.

src/metrics.rs Outdated Show resolved Hide resolved
src/goose.rs Outdated Show resolved Hide resolved
@slashrsm slashrsm force-pushed the 246_additional_graphs branch from 22fb7ac to 70500a0 Compare December 9, 2021 09:50
Copy link
Member

@jeremyandrews jeremyandrews left a comment

Choose a reason for hiding this comment

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

This is fantastic! A couple small nits (in particular a style change that creates a lot of noise) then it's ready to merge. Very useful addition, thanks again!

CHANGELOG.md Outdated Show resolved Hide resolved
src/metrics.rs Outdated Show resolved Hide resolved
src/metrics.rs Outdated Show resolved Hide resolved
src/metrics.rs Show resolved Hide resolved
src/report.rs Outdated

/// Helper function to build HTML charts powered by the
/// [ECharts](https://echarts.apache.org) library.
#[allow(clippy::too_many_arguments)]
Copy link
Member

Choose a reason for hiding this comment

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

I always aim to restructure how I call the function instead of selectively ignoring Clippy. Perhaps we can create an object to pass in, for example?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense. Done.

I ended up moving the function that generates markup onto the struct as well. This looks much nicer to me now.

src/metrics.rs Outdated Show resolved Hide resolved
@slashrsm slashrsm force-pushed the 246_additional_graphs branch from 9a45ab3 to 9a2f685 Compare December 12, 2021 10:48
@@ -2308,6 +2399,9 @@ impl GooseAttack {
}
}

// Record current users for users per second graph in HTML report.
self.metrics.record_users_per_second();
Copy link
Member

Choose a reason for hiding this comment

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

I still think this should be moved down to after we receive metrics, as otherwise we may not record a user until later than we should? It can be addressed in a follow, or let's talk through why this isn't relevant.

Copy link
Member

@jeremyandrews jeremyandrews left a comment

Choose a reason for hiding this comment

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

One small issue I'd like to talk through and address in a followup if it makes sense after we talk it through. Yay, merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add charts to HTML report
2 participants