From 6f2080003e19354ac0fefc45b1e6be6ed801f299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E8=81=AA?= Date: Thu, 13 Jan 2022 17:41:27 +0800 Subject: [PATCH 1/2] feat: add error log and summary of response time to prometheus. --- internal/boomer/output.go | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/internal/boomer/output.go b/internal/boomer/output.go index ac8c7538..5c7c7542 100644 --- a/internal/boomer/output.go +++ b/internal/boomer/output.go @@ -197,6 +197,8 @@ func convertData(data map[string]interface{}) (output *dataOutput, err error) { return nil, fmt.Errorf("stats is not []interface{}") } + errors := data["errors"].(map[string]map[string]interface{}) + transactions, ok := data["transactions"].(map[string]int64) if !ok { 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), TotalFailRatio: getTotalFailRatio(entryTotalOutput.NumRequests, entryTotalOutput.NumFailures), Stats: make([]*statsEntryOutput, 0, len(stats)), + Errors: errors, } // 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 var ( gaugeUsers = prometheus.NewGauge( @@ -367,6 +388,13 @@ var ( 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. @@ -397,6 +425,9 @@ func (o *PrometheusPusherOutput) OnStart() { gaugeAverageContentLength, gaugeCurrentRPS, gaugeCurrentFailPerSec, + gaugeErrors, + // summary for total + summaryResponseTime, // gauges for total gaugeUsers, gaugeState, @@ -449,6 +480,21 @@ func (o *PrometheusPusherOutput) OnEvent(data map[string]interface{}) { gaugeAverageContentLength.WithLabelValues(method, name).Set(float64(stat.avgContentLength)) gaugeCurrentRPS.WithLabelValues(method, name).Set(stat.currentRps) 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 { From 3e8391054fe752a330e969dcc0196dbc15f8d7fa Mon Sep 17 00:00:00 2001 From: debugtalk Date: Thu, 13 Jan 2022 18:40:24 +0800 Subject: [PATCH 2/2] bump version to v0.5.1 --- docs/CHANGELOG.md | 5 +++++ internal/version/init.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e7c708e6..ab72d19f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,10 @@ # 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) - feat: support creating and calling custom functions with [go plugin](https://pkg.go.dev/plugin) diff --git a/internal/version/init.go b/internal/version/init.go index 8b4b8520..53bdb1fa 100644 --- a/internal/version/init.go +++ b/internal/version/init.go @@ -1,3 +1,3 @@ package version -const VERSION = "v0.5.0" +const VERSION = "v0.5.1"