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
|
2022-10-11 01:57:18 +05:30
|
|
|
# Actioncable has it's separate instrumentation, but isn't configurable
|
|
|
|
# in the same way as all the other instances using a class.
|
2020-06-23 00:09:42 +05:30
|
|
|
ActionCable = Class.new(RedisBase)
|
2022-10-11 01:57:18 +05:30
|
|
|
|
|
|
|
STORAGES = (
|
|
|
|
Gitlab::Redis::ALL_CLASSES.map do |redis_instance_class|
|
|
|
|
instrumentation_class = Class.new(RedisBase)
|
|
|
|
|
|
|
|
instrumentation_class.enable_redis_cluster_validation unless redis_instance_class == Gitlab::Redis::Queues
|
|
|
|
|
|
|
|
const_set(redis_instance_class.store_name, instrumentation_class)
|
|
|
|
instrumentation_class
|
|
|
|
end << ActionCable
|
|
|
|
).freeze
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
# Milliseconds represented in seconds
|
|
|
|
QUERY_TIME_BUCKETS = [0.1, 0.25, 0.5].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
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
%i[get_request_count get_cross_slot_request_count get_allowed_cross_slot_request_count query_time read_bytes
|
|
|
|
write_bytes].each do |method|
|
2020-06-23 00:09:42 +05:30
|
|
|
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
|