Documentation
¶
Index ¶
- Variables
- func GetEnv(key, absentValue string) string
- func PrintCSVReport(r *RunReport, filename string)
- func PrintReport(r *RunReport)
- func PrintSummary(r *RunReport)
- func Printf(format string, args ...interface{})
- func ReadFile(name, absentValue string) string
- type AfterRunner
- type Attack
- type BeforeRunner
- type Config
- type DoResult
- type LatencyMetrics
- type Metrics
- type RunReport
Constants ¶
This section is empty.
Variables ¶
var RequesLabelSeparator = ","
RequesLabelSeparator is what it says
Functions ¶
func PrintCSVReport ¶ added in v1.9.1
PrintCSVReport writes the metrics in CSV format
func PrintReport ¶
func PrintReport(r *RunReport)
PrintReport writes report - JSON report to a file - CSV report to a file - stdout depending on the configuration.
func PrintSummary ¶
func PrintSummary(r *RunReport)
PrintSummary logs a subset of the report for each metric label
Types ¶
type AfterRunner ¶ added in v1.4.1
AfterRunner can be implemented by an Attacker and its method is called after a test or run. The report is passed to compute the Failed field and/or store values in Output.
type Attack ¶
type Attack interface {
// Setup should establish the connection to the service
// It may want to access the config of the runner.
Setup(c Config) error
// Do performs one request and is executed in a separate goroutine.
// The context is used to cancel the request on timeout.
Do(ctx context.Context) DoResult
// Teardown can be used to close the connection to the service
Teardown() error
// Clone should return a fresh new Attack
// Make sure the new Attack has values for shared struct fields initialized at Setup.
Clone() Attack
}
Attack must be implemented by a service client.
type BeforeRunner ¶ added in v1.4.1
BeforeRunner can be implemented by an Attacker and its method is called before a test or run.
type Config ¶
type Config struct {
RPS int `json:"rps"`
AttackTimeSec int `json:"attackTimeSec"`
RampupTimeSec int `json:"rampupTimeSec"`
RampupStrategy string `json:"rampupStrategy"`
MaxAttackers int `json:"maxAttackers"`
OutputFilename string `json:"outputFilename,omitempty"`
CSVOutputFilename string `json:"csvOutputFilename,omitempty"`
Verbose bool `json:"verbose"` // for output activity
Debug bool `json:"debug"` // for inspecting requests and response, useable by attack
Metadata map[string]string `json:"metadata,omitempty"`
DoTimeoutSec int `json:"doTimeoutSec"`
}
Config holds settings for a Runner.
func ConfigFromFile ¶
ConfigFromFile loads a Config for use in a runner.
func ConfigFromFlags ¶
func ConfigFromFlags() Config
ConfigFromFlags creates a Config for use in a runner.
type DoResult ¶
type DoResult struct {
// Label identifying the request that was send which is only used for reporting the metrics.
// Use the RequesLabelSeparator to have multiple labels.
RequestLabel string
// The error that happened when sending the request or receiving the response.
Error error
// The HTTP status code.
StatusCode int
// Number of bytes transferred when sending the request.
BytesIn int64
// Number of bytes transferred when receiving the response.
BytesOut int64
}
DoResult is the return value of a Do call on an Attack.
func (DoResult) WithLabels ¶ added in v1.9.1
WithLabels return a copy with multiple Request labels set.
type LatencyMetrics ¶
type LatencyMetrics struct {
// Total is the total latency sum of all requests in an attack.
Total time.Duration `json:"total"`
// Mean is the mean request latency.
Mean time.Duration `json:"mean"`
// P50 is the 50th percentile request latency.
P50 time.Duration `json:"50th"`
// P95 is the 95th percentile request latency.
P95 time.Duration `json:"95th"`
// P99 is the 99th percentile request latency.
P99 time.Duration `json:"99th"`
// Max is the maximum observed request latency.
Max time.Duration `json:"max"`
}
LatencyMetrics holds computed request latency metrics.
type Metrics ¶
type Metrics struct {
// Latencies holds computed request latency metrics.
Latencies LatencyMetrics `json:"latencies"`
// First is the earliest timestamp in a Result set.
Earliest time.Time `json:"earliest"`
// Latest is the latest timestamp in a Result set.
Latest time.Time `json:"latest"`
// End is the latest timestamp in a Result set plus its latency.
End time.Time `json:"end"`
// Duration is the duration of the attack.
Duration time.Duration `json:"duration"`
// Wait is the extra time waiting for responses from targets.
Wait time.Duration `json:"wait"`
// Requests is the total number of requests executed.
Requests uint64 `json:"requests"`
// Rate is the rate of requests per second.
Rate float64 `json:"rate"`
// Success is the percentage of non-error responses.
Success float64 `json:"success"`
// StatusCodes is a histogram of the responses' status codes.
StatusCodes map[string]int `json:"status_codes"`
// Errors is a set of unique errors returned by the targets during the attack.
Errors []string `json:"errors"`
// BytesIn
BytesIn uint64 `json:"bytes_in"`
// BytesOut
BytesOut uint64 `json:"bytes_out"`
// contains filtered or unexported fields
}
Metrics holds metrics computed out of a slice of Results which are used in some of the Reporters
type RunReport ¶
type RunReport struct {
StartedAt time.Time `json:"startedAt"`
FinishedAt time.Time `json:"finishedAt"`
Configuration Config `json:"configuration"`
// RunError is set when a Run could not be called or executed.
RunError string `json:"runError"`
Metrics map[string]*Metrics `json:"metrics"`
// Failed can be set by your load test program to indicate that the results are not acceptable.
Failed bool `json:"failed"`
// Output is used to publish any custom output in the report.
Output map[string]interface{} `json:"output"`
}
RunReport is a composition of configuration, measurements and custom output from a load run.
func NewErrorReport ¶
NewErrorReport returns a report when a Run could not be called or executed.

