Skip to content

Reintroduce prometheus spec

Bob Van Landuyt requested to merge bvl-reintroduce-prometheus-spec into master

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

Closes #281164 (closed)

Edited by Bob Van Landuyt

Merge request reports