From 2d94e9f75d0959032522232daf38720094fcdff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E8=81=AA?= Date: Thu, 20 Jan 2022 15:02:35 +0800 Subject: [PATCH] fix: inaccurate to report data. --- boomer.go | 2 +- internal/boomer/output.go | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/boomer.go b/boomer.go index 49410898..8ec0ff67 100644 --- a/boomer.go +++ b/boomer.go @@ -140,7 +140,7 @@ func (b *HRPBoomer) convertBoomerTask(testcase *TestCase) *boomer.Task { if stepData.stepType == stepTypeTransaction { // transaction // FIXME: support nested transactions - if stepData.elapsed != 0 { // only record when transaction ends + if step.ToStruct().Transaction.Type == transactionEnd { // only record when transaction ends b.RecordTransaction(stepData.name, transactionSuccess, stepData.elapsed, 0) transactionSuccess = true // reset flag for next transaction } diff --git a/internal/boomer/output.go b/internal/boomer/output.go index 70ab8b06..2f05149d 100644 --- a/internal/boomer/output.go +++ b/internal/boomer/output.go @@ -337,6 +337,17 @@ var ( ) ) +// counter for total +var ( + counterErrors = prometheus.NewCounterVec( + prometheus.CounterOpts{ + Name: "errors", + Help: "The errors of load testing", + }, + []string{"method", "name", "error"}, + ) +) + // summary for total var ( summaryResponseTime = prometheus.NewSummaryVec( @@ -399,13 +410,6 @@ 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. @@ -436,7 +440,8 @@ func (o *PrometheusPusherOutput) OnStart() { gaugeAverageContentLength, gaugeCurrentRPS, gaugeCurrentFailPerSec, - gaugeErrors, + // counter for total + counterErrors, // summary for total summaryResponseTime, // gauges for total @@ -505,11 +510,11 @@ func (o *PrometheusPusherOutput) OnEvent(data map[string]interface{}) { // errors for _, requestError := range output.Errors { - gaugeErrors.WithLabelValues( + counterErrors.WithLabelValues( requestError["method"].(string), requestError["name"].(string), requestError["error"].(string), - ).Set(float64(requestError["occurrences"].(int64))) + ).Add(float64(requestError["occurrences"].(int64))) } if err := o.pusher.Push(); err != nil {