Module: Gitlab::Instrumentation::RedisInterceptor

Defined in:
lib/gitlab/instrumentation/redis_interceptor.rb

Defined Under Namespace

Classes: MysteryRedisDurationError

Constant Summary collapse

APDEX_EXCLUDE =
%w[brpop blpop brpoplpush bzpopmin bzpopmax xread xreadgroup].freeze

Instance Method Summary collapse

Instance Method Details

#call(*args, &block) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/gitlab/instrumentation/redis_interceptor.rb', line 16

def call(*args, &block)
  start = Gitlab::Metrics::System.monotonic_time # must come first so that 'start' is always defined
  instrumentation_class.instance_count_request
  instrumentation_class.redis_cluster_validate!(args.first)

  super(*args, &block)
rescue ::Redis::BaseError => ex
  instrumentation_class.instance_count_exception(ex)
  raise ex
ensure
  duration = Gitlab::Metrics::System.monotonic_time - start

  unless APDEX_EXCLUDE.include?(command_from_args(args))
    instrumentation_class.instance_observe_duration(duration)
  end

  if ::RequestStore.active?
    # These metrics measure total Redis usage per Rails request / job.
    instrumentation_class.increment_request_count
    instrumentation_class.add_duration(duration)
    instrumentation_class.add_call_details(duration, args)
  end
end

#readObject


45
46
47
48
49
# File 'lib/gitlab/instrumentation/redis_interceptor.rb', line 45

def read
  result = super
  measure_read_size(result) if ::RequestStore.active?
  result
end

#write(command) ⇒ Object


40
41
42
43
# File 'lib/gitlab/instrumentation/redis_interceptor.rb', line 40

def write(command)
  measure_write_size(command) if ::RequestStore.active?
  super
end