Commit ff9ff29d authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch '323189-rescue-all-exceptions-when-tracking-events-using-redis-hll' into 'master'

Rescue all exceptions when tracking events using Redis HLL

See merge request gitlab-org/gitlab!55825
parents b8dffa3b fea0d8f2
......@@ -132,6 +132,10 @@ module Gitlab
return unless feature_enabled?(event)
Gitlab::Redis::HLL.add(key: redis_key(event, time, context), value: values, expiry: expiry(event))
rescue => e
# Ignore any exceptions unless is dev or test env
# The application flow should not be blocked by erros in tracking
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
end
# The array of valid context on which we allow tracking
......
......@@ -154,6 +154,13 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
expect { described_class.track_event('unknown', values: entity1, time: Date.current) }.to raise_error(Gitlab::UsageDataCounters::HLLRedisCounter::UnknownEvent)
end
it 'reports an error if Feature.enabled raise an error' do
expect(Feature).to receive(:enabled?).and_raise(StandardError.new)
expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception)
described_class.track_event(:g_analytics_contribution, values: entity1, time: Date.current)
end
context 'for weekly events' do
it 'sets the keys in Redis to expire automatically after the given expiry time' do
described_class.track_event("g_analytics_contribution", values: entity1)
......
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