Reintroduce prometheus spec
What does this MR do?
This fixes the order dependant failure we saw in #281164 (closed)
Command to reproduce (this fails on master when removing the :quarantine
tag)
bundle exec rspec spec/initializers/lograge_spec.rb spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb
This was caused by the spec/initializers/lograge_spec.rb
, which is a request-spec in disguise, making requests and therefore recording and memoizing the metrics in our middleware under test in spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb
.
Which would mean we would keep looking at the old metrics the registry
in that we kept track of in Prometheus::Client::Registry#metrics
after it was reset using Gitlab::Metrics.reset_registry
.
This wouldn't cause any issues in production, because the metrics are never reset. But in specs, we do count on those being reset in between runs.
This is safe to do, because the registry itself is memoized on
Gitlab::Metrics
.
Getting the specific metric is an initialization the first time around, but after a registry is memoized, it's just a read from a hash.
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Closes #281164 (closed)