From c486771c32f9639286de8fdd1b9d006931736e5d Mon Sep 17 00:00:00 2001 From: jacexh Date: Mon, 20 Jun 2022 09:31:17 +0000 Subject: [PATCH] convert some metrics type --- CHANGELOG.md | 4 ++++ example/benchmark/main.go | 22 ---------------------- example/localrunner/main.go | 3 +-- example/slave/main.go | 4 ++-- metric.go | 4 ++-- 5 files changed, 9 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba87b4f1..77bea3b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # ChangeLog +## v2.4.5 + +- Convert the type of `ultron_attacker_failures_total` and `ultron_attacker_requests_total` to [Counter](https://prometheus.io/docs/concepts/metric_types/#counter) + ## v2.4.2 - now you can change name, level, etc. of log file via an external config file: `./config.yml` diff --git a/example/benchmark/main.go b/example/benchmark/main.go index 279c9ba3..d6eb94b4 100644 --- a/example/benchmark/main.go +++ b/example/benchmark/main.go @@ -41,26 +41,4 @@ func main() { } select {} - - // for { - // if plan.Status() == ultron.StatusFinished { - // <-time.After(1 * time.Second) - // break - // } - // runtime.Gosched() - // } - - // plan = ultron.NewPlan("benchmark-test-2") - // plan.AddStages( - // &ultron.V1StageConfig{ConcurrentUsers: 150, Duration: 60 * time.Second, RampUpPeriod: 10}, - // ) - // runner.StartPlan(plan) - - // for { - // if plan.Status() == ultron.StatusFinished { - // <-time.After(1 * time.Second) - // break - // } - // runtime.Gosched() - // } } diff --git a/example/localrunner/main.go b/example/localrunner/main.go index 09b05675..3e48d950 100644 --- a/example/localrunner/main.go +++ b/example/localrunner/main.go @@ -37,6 +37,5 @@ func main() { } // open http://localhost:2017 - block := make(chan struct{}, 1) - <-block + select {} } diff --git a/example/slave/main.go b/example/slave/main.go index 942beae7..1934ec95 100644 --- a/example/slave/main.go +++ b/example/slave/main.go @@ -21,6 +21,6 @@ func main() { if err := slave.Connect("127.0.0.1:2021", grpc.WithInsecure()); err != nil { panic(err) } - block := make(chan struct{}, 1) - <-block + + select {} } diff --git a/metric.go b/metric.go index 13402b66..6d899888 100644 --- a/metric.go +++ b/metric.go @@ -69,8 +69,8 @@ func (m *metric) Collect(ch chan<- prometheus.Metric) { } for _, report := range report.Reports { - ch <- prometheus.MustNewConstMetric(descTotalRequests, prometheus.GaugeValue, float64(report.Requests), report.Name, plan) - ch <- prometheus.MustNewConstMetric(descTotalFailures, prometheus.GaugeValue, float64(report.Failures), report.Name, plan) + ch <- prometheus.MustNewConstMetric(descTotalRequests, prometheus.CounterValue, float64(report.Requests), report.Name, plan) + ch <- prometheus.MustNewConstMetric(descTotalFailures, prometheus.CounterValue, float64(report.Failures), report.Name, plan) ch <- prometheus.MustNewConstMetric(descMinResponseTime, prometheus.GaugeValue, float64(report.Min.Milliseconds()), report.Name, plan) ch <- prometheus.MustNewConstMetric(descMaxResponseTime, prometheus.GaugeValue, float64(report.Max.Milliseconds()), report.Name, plan) ch <- prometheus.MustNewConstMetric(descAvgResponseTime, prometheus.GaugeValue, float64(report.Average.Milliseconds()), report.Name, plan)