Skip to content
Snippets Groups Projects
Verified Commit bafab35e authored by Matija Čupić's avatar Matija Čupić
Browse files

Use Prometheus counter instead of redis

parent c00a17f6
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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)
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment