mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 07:49:44 +08:00
fix: report metrics to prometheus
This commit is contained in:
@@ -5,11 +5,6 @@
|
||||
**go version**
|
||||
|
||||
- feat: support multi-machine collaborative distributed load testing
|
||||
|
||||
## v4.1.7 (2022-07-18)
|
||||
|
||||
**go version**
|
||||
|
||||
- feat: support indicating type and filename when uploading file
|
||||
- feat: support to infer MIME type of the file automatically
|
||||
- feat: support omitting websocket url if not necessary
|
||||
@@ -284,8 +279,7 @@
|
||||
- feat: implement `transaction` mechanism for load test
|
||||
- feat: continue running next step when failure occurs with `--continue-on-failure` flag, default to failfast
|
||||
- feat: report GA events with version
|
||||
- feat: run load test with the given limit and burst as rate limiter, use `--spawn-count`, `--spawn-rate`
|
||||
and `--request-increase-rate` flag
|
||||
- feat: run load test with the given limit and burst as rate limiter, use `--spawn-count`, `--spawn-rate` and `--request-increase-rate` flag
|
||||
- feat: report runner state to prometheus
|
||||
- refactor: fork [boomer] as submodule initially and made a lot of changes
|
||||
- change: update API models
|
||||
@@ -339,8 +333,7 @@
|
||||
|
||||
## 3.1.8 (2022-03-22)
|
||||
|
||||
- feat: add `--profile` flag for har2case to support overwrite headers/cookies with specified yaml/json configuration
|
||||
file
|
||||
- feat: add `--profile` flag for har2case to support overwrite headers/cookies with specified yaml/json configuration file
|
||||
- feat: support variable and function in response extract expression
|
||||
- fix: keep negative index in jmespath unchanged when converting pytest files, e.g. body.users[-1]
|
||||
- fix: variable should not start with digit
|
||||
@@ -658,31 +651,17 @@ reference: [v2-changelog]
|
||||
|
||||
|
||||
[hrp]: https://github.com/httprunner/hrp
|
||||
|
||||
[hashicorp/go-plugin]: https://github.com/hashicorp/go-plugin
|
||||
|
||||
[go plugin]: https://pkg.go.dev/plugin
|
||||
|
||||
[docs repo]: https://github.com/httprunner/httprunner.github.io
|
||||
|
||||
[zerolog]: https://github.com/rs/zerolog
|
||||
|
||||
[jmespath]: https://jmespath.org/
|
||||
|
||||
[mkdocs]: https://www.mkdocs.org/
|
||||
|
||||
[github-actions]: https://github.com/httprunner/hrp/actions
|
||||
|
||||
[boomer]: github.com/myzhan/boomer
|
||||
|
||||
[sentry sdk]: https://github.com/getsentry/sentry-go
|
||||
|
||||
[pushgateway]: https://github.com/prometheus/pushgateway
|
||||
|
||||
[locust]: https://locust.io/
|
||||
|
||||
[black]: https://github.com/psf/black
|
||||
|
||||
[loguru]: https://github.com/Delgan/loguru
|
||||
|
||||
[v2-changelog]: https://github.com/httprunner/httprunner/blob/v2/docs/CHANGELOG.md
|
||||
[v2-changelog]: https://github.com/httprunner/httprunner/blob/v2/docs/CHANGELOG.md
|
||||
@@ -475,7 +475,8 @@ type PrometheusPusherOutput struct {
|
||||
|
||||
// OnStart will register all prometheus metric collectors
|
||||
func (o *PrometheusPusherOutput) OnStart() {
|
||||
o.reset()
|
||||
// reset all prometheus metrics
|
||||
resetPrometheusMetrics()
|
||||
log.Info().Msg("register prometheus metric collectors")
|
||||
registry := prometheus.NewRegistry()
|
||||
registry.MustRegister(
|
||||
@@ -608,9 +609,9 @@ func (o *PrometheusPusherOutput) OnEvent(data map[string]interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
// reset will reset all metrics
|
||||
func (o *PrometheusPusherOutput) reset() {
|
||||
log.Info().Msg("reset metrics")
|
||||
// resetPrometheusMetrics will reset all metrics
|
||||
func resetPrometheusMetrics() {
|
||||
log.Info().Msg("reset all prometheus metrics")
|
||||
gaugeNumRequests.Reset()
|
||||
gaugeNumFailures.Reset()
|
||||
gaugeMedianResponseTime.Reset()
|
||||
|
||||
@@ -927,14 +927,15 @@ func (r *workerRunner) start() {
|
||||
|
||||
close(r.doneChan)
|
||||
|
||||
// notify master that worker is stopped
|
||||
r.onStopped()
|
||||
// wait until all stats are reported successfully
|
||||
<-r.reportedChan
|
||||
// report test result
|
||||
r.reportTestResult()
|
||||
// output teardown
|
||||
r.outputOnStop()
|
||||
|
||||
// notify master that worker is stopped
|
||||
r.onStopped()
|
||||
}()
|
||||
|
||||
// start stats report
|
||||
|
||||
@@ -8,10 +8,9 @@ import (
|
||||
|
||||
"github.com/httprunner/funplugin"
|
||||
"github.com/httprunner/funplugin/fungo"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user