debian-mirror-gitlab/lib/gitlab/instrumentation/redis.rb

44 lines
1.3 KiB
Ruby
Raw Normal View History

2020-04-22 19:07:51 +05:30
# frozen_string_literal: true
module Gitlab
module Instrumentation
2020-06-23 00:09:42 +05:30
# Aggregates Redis measurements from different request storage sources.
2020-04-22 19:07:51 +05:30
class Redis
2020-06-23 00:09:42 +05:30
ActionCable = Class.new(RedisBase)
2020-07-28 23:09:34 +05:30
Cache = Class.new(RedisBase).enable_redis_cluster_validation
2020-06-23 00:09:42 +05:30
Queues = Class.new(RedisBase)
2020-07-28 23:09:34 +05:30
SharedState = Class.new(RedisBase).enable_redis_cluster_validation
2021-09-04 01:27:46 +05:30
TraceChunks = Class.new(RedisBase).enable_redis_cluster_validation
2020-04-22 19:07:51 +05:30
2021-09-04 01:27:46 +05:30
STORAGES = [ActionCable, Cache, Queues, SharedState, TraceChunks].freeze
2020-04-22 19:07:51 +05:30
2020-06-23 00:09:42 +05:30
# Milliseconds represented in seconds (from 1 millisecond to 2 seconds).
QUERY_TIME_BUCKETS = [0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2].freeze
2020-04-22 19:07:51 +05:30
2020-06-23 00:09:42 +05:30
class << self
include ::Gitlab::Instrumentation::RedisPayload
2020-04-22 19:07:51 +05:30
2020-06-23 00:09:42 +05:30
def storage_key
nil
end
2020-04-22 19:07:51 +05:30
2020-06-23 00:09:42 +05:30
def payload
super.merge(*STORAGES.flat_map(&:payload))
end
2020-04-22 19:07:51 +05:30
2020-06-23 00:09:42 +05:30
def detail_store
STORAGES.flat_map do |storage|
storage.detail_store.map { |details| details.merge(storage: storage.name.demodulize) }
end
end
%i[get_request_count query_time read_bytes write_bytes].each do |method|
define_method method do
2021-01-03 14:25:43 +05:30
STORAGES.sum(&method)
2020-06-23 00:09:42 +05:30
end
end
2020-04-22 19:07:51 +05:30
end
end
end
end