Commit bafab35e authored by Matija Čupić's avatar Matija Čupić

Use Prometheus counter instead of redis

parent c00a17f6
......@@ -54,8 +54,11 @@ class CheckGcpProjectBillingWorker
"gitlab:gcp:session:#{token_key}"
end
def self.redis_billing_change_key
"gitlab:gcp:billing_enabled_changes"
def billing_changed_counter
@billing_changed_counter ||= Gitlab::Metrics.counter(
:gcp_billing_change_count,
"Counts the number of times a GCP project changed billing_enabled state from false to true"
)
end
def try_obtain_lease_for(token)
......@@ -73,8 +76,6 @@ class CheckGcpProjectBillingWorker
def update_billing_change_counter(previous_state, current_state)
return unless previous_state == 'false' && current_state
Gitlab::Redis::SharedState.with do |redis|
redis.incr(self.class.redis_billing_change_key)
end
billing_changed_counter.increment
end
end
......@@ -87,9 +87,7 @@ describe CheckGcpProjectBillingWorker do
end
it 'does not increment the billing change counter' do
Gitlab::Redis::SharedState.with do |redis|
expect(redis).not_to receive(:incr)
end
expect_any_instance_of(described_class).not_to receive(:billing_changed_counter)
subject
end
......@@ -101,9 +99,7 @@ describe CheckGcpProjectBillingWorker do
end
it 'increments the billing change counter' do
Gitlab::Redis::SharedState.with do |redis|
expect(redis).to receive(:incr)
end
expect_any_instance_of(described_class).to receive_message_chain(:billing_changed_counter, :increment)
subject
end
......@@ -117,9 +113,7 @@ describe CheckGcpProjectBillingWorker do
end
it 'does not increment the billing change counter' do
Gitlab::Redis::SharedState.with do |redis|
expect(redis).not_to receive(:incr)
end
expect_any_instance_of(described_class).not_to receive(:billing_changed_counter)
subject
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment