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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
958 B
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
module Gitlab
module Instrumentation
module RedisPayload
include ::Gitlab::Utils::StrongMemoize
def payload
to_lazy_payload.transform_values do |value|
result = value.call
result if result > 0
end.compact
end
private
def to_lazy_payload
strong_memoize(:to_lazy_payload) do
key_prefix = storage_key ? "redis_#{storage_key}" : 'redis'
{
"#{key_prefix}_calls": -> { get_request_count },
2023-03-04 22:38:38 +05:30
"#{key_prefix}_cross_slot_calls": -> { get_cross_slot_request_count },
"#{key_prefix}_allowed_cross_slot_calls": -> { get_allowed_cross_slot_request_count },
2020-06-23 00:09:42 +05:30
"#{key_prefix}_duration_s": -> { query_time },
"#{key_prefix}_read_bytes": -> { read_bytes },
"#{key_prefix}_write_bytes": -> { write_bytes }
}.symbolize_keys
end
end
end
end
end