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