-
Notifications
You must be signed in to change notification settings - Fork 2
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
*: types refactor #40
Conversation
I think we need to do some refactors before introducing this feature. 1. Rethink
|
Gather() (latencies []float64, percentileLatencies map[float64]float64, failureList []error, bytes int64) |
This function should just return ResponseStats
(raw data) instead of percentile latencies.
The caller should take responsibility to make summary on raw data as it wants.
So, I think ResponseStats
should be like
// ResponseStats is the report about benchmark result.
type ResponseStats struct {
// Total represents total number of requests.
Total int
// List of failures
FailureList []error
// All the observed latencies
Latencies []float64
// total bytes read from apiserver
TotalReceivedBytes int64
}
// ResponseMetric is a measurement related to http response.
type ResponseMetric interface {
...
// Gather returns the summary.
Gather() ResponseStats
}
I remove the Duration
from ResponseStats
because metric collector doesn't know when it starts and when it ends.
So, the Duration
should be filled by Schedule
.
Line 20 in 636d5a4
func Schedule(ctx context.Context, spec *types.LoadProfileSpec, restCli []rest.Interface) (*types.ResponseStats, error) { |
The Schedule
should return their own type instead of ResponseStats
.
// in request pkg
type Result struct {
types.ResponseStats
// Duration means the time of benchmark.
Duration time.Duration
}
func Schedule(ctx context.Context, spec *types.LoadProfileSpec, restCli []rest.Interface) (*Result, error) {}
2. Introduce RunnerMetricReport
type for command output
For command output, it's client facing. It could be changed or updated frequently.
So, we should introduce new type RunnerMetricReport
for render purposes.
If there is no new raw metric, we don't need to touch ResponseStats
.
All the aggregated features can be handled by updated RunnerMetricReport
type.
// in api/types pkg
type RunnerMetricReport struct {
// Total represents total number of requests.
Total int
// List of failures
FailureList []error
// Duration means the time of benchmark.
Duration time.Duration
// All the observed latencies
Latencies []float64
// total bytes read from apiserver
TotalReceivedBytes int64
// PercentileLatencies represents the latency distribution in seconds.
PercentileLatencies [][2]float64 // [2]float64{percentile, value}
}
3. Introduce --format=json
and --raw-data
flags together
Change current format into json
. No need to maintain fmt.Fprintf()
method.
If --raw-data
is set, use json.NewEncoder()
to render. If we don't have --raw-data
, set Latencies
field to nil and render it into json.
What do you think?
2ca8414
to
169b003
Compare
modified response structs, removed percentileLatencies test cases
89f8282
to
e9cea86
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
Modified struct definitions and removed test case for PercentileLatencies