mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-09 14:32:31 +08:00
fix: inaccurate to report data.
This commit is contained in:
@@ -140,7 +140,7 @@ func (b *HRPBoomer) convertBoomerTask(testcase *TestCase) *boomer.Task {
|
|||||||
if stepData.stepType == stepTypeTransaction {
|
if stepData.stepType == stepTypeTransaction {
|
||||||
// transaction
|
// transaction
|
||||||
// FIXME: support nested transactions
|
// 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)
|
b.RecordTransaction(stepData.name, transactionSuccess, stepData.elapsed, 0)
|
||||||
transactionSuccess = true // reset flag for next transaction
|
transactionSuccess = true // reset flag for next transaction
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
// summary for total
|
||||||
var (
|
var (
|
||||||
summaryResponseTime = prometheus.NewSummaryVec(
|
summaryResponseTime = prometheus.NewSummaryVec(
|
||||||
@@ -399,13 +410,6 @@ 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.
|
||||||
@@ -436,7 +440,8 @@ func (o *PrometheusPusherOutput) OnStart() {
|
|||||||
gaugeAverageContentLength,
|
gaugeAverageContentLength,
|
||||||
gaugeCurrentRPS,
|
gaugeCurrentRPS,
|
||||||
gaugeCurrentFailPerSec,
|
gaugeCurrentFailPerSec,
|
||||||
gaugeErrors,
|
// counter for total
|
||||||
|
counterErrors,
|
||||||
// summary for total
|
// summary for total
|
||||||
summaryResponseTime,
|
summaryResponseTime,
|
||||||
// gauges for total
|
// gauges for total
|
||||||
@@ -505,11 +510,11 @@ func (o *PrometheusPusherOutput) OnEvent(data map[string]interface{}) {
|
|||||||
|
|
||||||
// errors
|
// errors
|
||||||
for _, requestError := range output.Errors {
|
for _, requestError := range output.Errors {
|
||||||
gaugeErrors.WithLabelValues(
|
counterErrors.WithLabelValues(
|
||||||
requestError["method"].(string),
|
requestError["method"].(string),
|
||||||
requestError["name"].(string),
|
requestError["name"].(string),
|
||||||
requestError["error"].(string),
|
requestError["error"].(string),
|
||||||
).Set(float64(requestError["occurrences"].(int64)))
|
).Add(float64(requestError["occurrences"].(int64)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := o.pusher.Push(); err != nil {
|
if err := o.pusher.Push(); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user