mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 15:37:35 +08:00
Merge pull request #11 from httprunner/main
new pull request. 2022.1.13
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
# Release History
|
# Release History
|
||||||
|
|
||||||
|
## v0.5.1 (2022-01-13)
|
||||||
|
|
||||||
|
- feat: support specifying running cycles for load testing
|
||||||
|
- fix: ensure last stats reported when stop running
|
||||||
|
|
||||||
## v0.5.0 (2022-01-08)
|
## v0.5.0 (2022-01-08)
|
||||||
|
|
||||||
- feat: support creating and calling custom functions with [go plugin](https://pkg.go.dev/plugin)
|
- feat: support creating and calling custom functions with [go plugin](https://pkg.go.dev/plugin)
|
||||||
|
|||||||
@@ -197,6 +197,8 @@ func convertData(data map[string]interface{}) (output *dataOutput, err error) {
|
|||||||
return nil, fmt.Errorf("stats is not []interface{}")
|
return nil, fmt.Errorf("stats is not []interface{}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errors := data["errors"].(map[string]map[string]interface{})
|
||||||
|
|
||||||
transactions, ok := data["transactions"].(map[string]int64)
|
transactions, ok := data["transactions"].(map[string]int64)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("transactions is not map[string]int64")
|
return nil, fmt.Errorf("transactions is not map[string]int64")
|
||||||
@@ -223,6 +225,7 @@ func convertData(data map[string]interface{}) (output *dataOutput, err error) {
|
|||||||
TotalRPS: getCurrentRps(entryTotalOutput.NumRequests),
|
TotalRPS: getCurrentRps(entryTotalOutput.NumRequests),
|
||||||
TotalFailRatio: getTotalFailRatio(entryTotalOutput.NumRequests, entryTotalOutput.NumFailures),
|
TotalFailRatio: getTotalFailRatio(entryTotalOutput.NumRequests, entryTotalOutput.NumFailures),
|
||||||
Stats: make([]*statsEntryOutput, 0, len(stats)),
|
Stats: make([]*statsEntryOutput, 0, len(stats)),
|
||||||
|
Errors: errors,
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert stats
|
// convert stats
|
||||||
@@ -329,6 +332,24 @@ var (
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// summary for total
|
||||||
|
var (
|
||||||
|
summaryResponseTime = prometheus.NewSummaryVec(
|
||||||
|
prometheus.SummaryOpts{
|
||||||
|
Name: "response_time",
|
||||||
|
Help: "The summary of response time",
|
||||||
|
Objectives: map[float64]float64{
|
||||||
|
0.5: 0.01,
|
||||||
|
0.9: 0.01,
|
||||||
|
0.95: 0.005,
|
||||||
|
},
|
||||||
|
AgeBuckets: 1,
|
||||||
|
MaxAge: 100000 * time.Second,
|
||||||
|
},
|
||||||
|
[]string{"method", "name"},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
// gauges for total
|
// gauges for total
|
||||||
var (
|
var (
|
||||||
gaugeUsers = prometheus.NewGauge(
|
gaugeUsers = prometheus.NewGauge(
|
||||||
@@ -367,6 +388,13 @@ var (
|
|||||||
Help: "The accumulated number of failed transactions",
|
Help: "The accumulated number of failed transactions",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
gaugeErrors = prometheus.NewGaugeVec(
|
||||||
|
prometheus.GaugeOpts{
|
||||||
|
Name: "errors",
|
||||||
|
Help: "The errors of load testing",
|
||||||
|
},
|
||||||
|
[]string{"method", "name", "error"},
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewPrometheusPusherOutput returns a PrometheusPusherOutput.
|
// NewPrometheusPusherOutput returns a PrometheusPusherOutput.
|
||||||
@@ -397,6 +425,9 @@ func (o *PrometheusPusherOutput) OnStart() {
|
|||||||
gaugeAverageContentLength,
|
gaugeAverageContentLength,
|
||||||
gaugeCurrentRPS,
|
gaugeCurrentRPS,
|
||||||
gaugeCurrentFailPerSec,
|
gaugeCurrentFailPerSec,
|
||||||
|
gaugeErrors,
|
||||||
|
// summary for total
|
||||||
|
summaryResponseTime,
|
||||||
// gauges for total
|
// gauges for total
|
||||||
gaugeUsers,
|
gaugeUsers,
|
||||||
gaugeState,
|
gaugeState,
|
||||||
@@ -449,6 +480,21 @@ func (o *PrometheusPusherOutput) OnEvent(data map[string]interface{}) {
|
|||||||
gaugeAverageContentLength.WithLabelValues(method, name).Set(float64(stat.avgContentLength))
|
gaugeAverageContentLength.WithLabelValues(method, name).Set(float64(stat.avgContentLength))
|
||||||
gaugeCurrentRPS.WithLabelValues(method, name).Set(stat.currentRps)
|
gaugeCurrentRPS.WithLabelValues(method, name).Set(stat.currentRps)
|
||||||
gaugeCurrentFailPerSec.WithLabelValues(method, name).Set(float64(stat.currentFailPerSec))
|
gaugeCurrentFailPerSec.WithLabelValues(method, name).Set(float64(stat.currentFailPerSec))
|
||||||
|
for responseTime, count := range stat.ResponseTimes {
|
||||||
|
var i int64
|
||||||
|
for i = 0; i < count; i++ {
|
||||||
|
summaryResponseTime.WithLabelValues(method, name).Observe(float64(responseTime))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// errors
|
||||||
|
for _, requestError := range output.Errors {
|
||||||
|
gaugeErrors.WithLabelValues(
|
||||||
|
requestError["method"].(string),
|
||||||
|
requestError["name"].(string),
|
||||||
|
requestError["error"].(string),
|
||||||
|
).Set(float64(requestError["occurrences"].(int64)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := o.pusher.Push(); err != nil {
|
if err := o.pusher.Push(); err != nil {
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
package version
|
package version
|
||||||
|
|
||||||
const VERSION = "v0.5.0"
|
const VERSION = "v0.5.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user