Skip to content

Mock Prometheus Middleware in unit tests #2419

Answered by aldas
Jasstkn asked this question in Q&A
Discussion options

You must be logged in to vote

This is because middleware.NewPrometheus() registers metrics into global register here https://github.com/labstack/echo-contrib/blob/b6855c2b7d9745b7db2498623e89cae526b41f57/prometheus/prometheus.go#L381

Prometheus middleware own tests unregister these metrics like that at the end of test https://github.com/labstack/echo-contrib/blob/b6855c2b7d9745b7db2498623e89cae526b41f57/prometheus/prometheus_test.go#L15

p.s. Prometheus middleware repository is located here https://github.com/labstack/echo-contrib and issues/PR should be sent there.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Jasstkn
Comment options

Answer selected by Jasstkn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants