Documentation ¶
Index ¶
- func Add(id int, r *Result)
- func AddRequest(id int, r string)
- func ClearOrAddMetrics(Id int)
- func GetMetrics() map[int]*Metrics
- type Buckets
- type ByteMetrics
- type Closer
- type Decoder
- type DecoderFactory
- type Encoder
- type Histogram
- type LatencyMetrics
- type Metrics
- type Report
- type Reporter
- type Result
- type Results
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddRequest ¶
func ClearOrAddMetrics ¶
func ClearOrAddMetrics(Id int)
func GetMetrics ¶
Types ¶
type Buckets ¶
Buckets represents an Histogram's latency buckets.
func (*Buckets) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type ByteMetrics ¶
type ByteMetrics struct { // Total is the total number of flowing bytes in an attack. Total uint64 `json:"total"` // Mean is the mean number of flowing bytes per hit. Mean float64 `json:"mean"` }
ByteMetrics holds computed byte flow metrics.
type Closer ¶
type Closer interface {
// Close permantently closes a Report, running any necessary book keeping.
Close()
}
Closer wraps the optional Report Close method.
type Decoder ¶
A Decoder decodes a Result and returns an error in case of failure.
func DecoderFor ¶
DecoderFor automatically detects the encoding of the first few bytes in the given io.Reader and then returns the corresponding Decoder or nil in case of failing to detect a supported encoding.
func NewCSVDecoder ¶
NewCSVDecoder returns a Decoder that decodes CSV encoded Results.
func NewDecoder ¶
NewDecoder returns a new gob Decoder for the given io.Reader.
func NewJSONDecoder ¶
NewJSONDecoder returns a Decoder that decodes JSON encoded Results.
func NewRoundRobinDecoder ¶
NewRoundRobinDecoder returns a new Decoder that round robins across the given Decoders on every invocation or decoding error.
type DecoderFactory ¶
A DecoderFactory constructs a new Decoder from a given io.Reader.
type Encoder ¶
An Encoder encodes a Result and returns an error in case of failure.
func NewCSVEncoder ¶
NewCSVEncoder returns an Encoder that dumps the given *Result as a CSV record. The columns are: UNIX timestamp in ns since epoch, HTTP status code, request latency in ns, bytes out, bytes in, response body, and lastly the error.
func NewEncoder ¶
NewEncoder returns a new Result encoder closure for the given io.Writer
func NewJSONEncoder ¶
NewJSONEncoder returns an Encoder that dumps the given *Results as a JSON object.
type Histogram ¶
Histogram is a bucketed latency Histogram.
func (*Histogram) Add ¶
Add implements the Add method of the Report interface by finding the right Bucket for the given Result latency and increasing its count by one as well as the total count.
func (*Histogram) MarshalJSON ¶
MarshalJSON returns a JSON encoding of the buckets and their counts.
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"` // P90 is the 90th percentile request latency. P90 time.Duration `json:"90th"` // 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"` // Min is the minimum observed request latency. Min time.Duration `json:"min"` // contains filtered or unexported fields }
LatencyMetrics holds computed request latency metrics.
func (*LatencyMetrics) Add ¶
func (l *LatencyMetrics) Add(latency time.Duration)
Add adds the given latency to the latency metrics.
type Metrics ¶
type Metrics struct { // Latencies holds computed request latency metrics. Latencies LatencyMetrics `json:"latencies"` // Histogram, only if requested Histogram *Histogram `json:"buckets,omitempty"` // BytesIn holds computed incoming byte metrics. BytesIn ByteMetrics `json:"bytes_in"` // BytesOut holds computed outgoing byte metrics. BytesOut ByteMetrics `json:"bytes_out"` // Earliest 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 sent requests per second. Rate float64 `json:"rate"` // Throughput is the rate of successful requests per second. Throughput float64 `json:"throughput"` // 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"` Slowest [5]Result `json:"slowest"` // contains filtered or unexported fields }
Metrics holds metrics computed out of a slice of Results which are used in some of the Reporters
func (*Metrics) Add ¶
Add implements the Add method of the Report interface by adding the given Result to Metrics.
func (*Metrics) AddRequest ¶
func (*Metrics) AddToSlowest ¶
type Report ¶
type Report interface { // Add adds a given *Result to a Report. Add(*Result) }
A Report represents the state a Reporter uses to write out its reports.
type Reporter ¶
A Reporter function writes out reports to the given io.Writer or returns an error in case of failure.
func NewHDRHistogramPlotReporter ¶
NewHDRHistogramPlotReporter returns a Reporter that writes out latency metrics in a format plottable by http://hdrhistogram.github.io/HdrHistogram/plotFiles.html.
func NewHistogramReporter ¶
NewHistogramReporter returns a Reporter that writes out a Histogram as aligned, formatted text.
func NewJSONReporter ¶
NewJSONReporter returns a Reporter that writes out Metrics as JSON.
func NewTextReporter ¶
NewTextReporter returns a Reporter that writes out Metrics as aligned, formatted text.
type Result ¶
type Result struct { Attack string `json:"attack"` Seq uint64 `json:"seq"` Code string `json:"code"` Timestamp time.Time `json:"timestamp"` Latency time.Duration `json:"latency"` BytesOut uint64 `json:"bytes_out"` BytesIn uint64 `json:"bytes_in"` Error string `json:"error"` Body []byte `json:"body"` Method string `json:"method"` URL string `json:"url"` Headers http.Header `json:"headers"` Status int `json:"status"` }
Result contains the results of a single Target hit.
type Results ¶
type Results []Result
Results is a slice of Result type elements.
func (*Results) Add ¶
Add implements the Add method of the Report interface by appending the given Result to the slice.