Welcome to mirror list, hosted at ThFree Co, Russian Federation.

redis_counter.rb « usage_data_counters « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6f887fe610658f5dcf0e6ee2316cdb7653e89735 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

# WARNING: This module has been deprecated and will be removed in the future
# Use InternalEvents.track_event instead https://docs.gitlab.com/ee/development/internal_analytics/internal_event_instrumentation/index.html

module Gitlab
  module UsageDataCounters
    module RedisCounter
      def increment(redis_counter_key)
        return unless ::ServicePing::ServicePingSettings.enabled?

        Gitlab::Redis::SharedState.with { |redis| redis.incr(redis_counter_key) }
      end

      def increment_by(redis_counter_key, incr)
        return unless ::ServicePing::ServicePingSettings.enabled?

        Gitlab::Redis::SharedState.with { |redis| redis.incrby(redis_counter_key, incr) }
      end

      def total_count(redis_counter_key)
        Gitlab::Redis::SharedState.with { |redis| redis.get(redis_counter_key).to_i }
      end
    end
  end
end