Commit a6892cd1 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch '219197-follow-up-refactor-instrumentation-elasticsearch' into 'master'

Minor refactor extract method InstrumentationHelper

Closes #219197

See merge request gitlab-org/gitlab!33133
parents 15eacc87 696ebc2f
......@@ -20,43 +20,60 @@ module Gitlab
DURATION_PRECISION = 6 # microseconds
def add_instrumentation_data(payload)
instrument_gitaly(payload)
instrument_rugged(payload)
instrument_redis(payload)
instrument_redis_bytes(payload)
instrument_elasticsearch(payload)
end
def instrument_gitaly(payload)
gitaly_calls = Gitlab::GitalyClient.get_request_count
if gitaly_calls > 0
return if gitaly_calls == 0
payload[:gitaly_calls] = gitaly_calls
payload[:gitaly_duration_s] = Gitlab::GitalyClient.query_time
end
def instrument_rugged(payload)
rugged_calls = Gitlab::RuggedInstrumentation.query_count
if rugged_calls > 0
return if rugged_calls == 0
payload[:rugged_calls] = rugged_calls
payload[:rugged_duration_s] = Gitlab::RuggedInstrumentation.query_time
end
def instrument_redis(payload)
redis_calls = Gitlab::Instrumentation::Redis.get_request_count
if redis_calls > 0
return if redis_calls == 0
payload[:redis_calls] = redis_calls
payload[:redis_duration_s] = Gitlab::Instrumentation::Redis.query_time
end
def instrument_redis_bytes(payload)
redis_read_bytes = Gitlab::Instrumentation::Redis.read_bytes
redis_write_bytes = Gitlab::Instrumentation::Redis.write_bytes
if redis_read_bytes > 0 || redis_write_bytes > 0
return if redis_read_bytes == 0 && redis_write_bytes == 0
payload[:redis_read_bytes] = redis_read_bytes
payload[:redis_write_bytes] = redis_write_bytes
end
def instrument_elasticsearch(payload)
# Elasticsearch integration is only available in EE but instrumentation
# only depends on the Gem which is also available in FOSS.
elasticsearch_calls = Gitlab::Instrumentation::ElasticsearchTransport.get_request_count
if elasticsearch_calls > 0
return if elasticsearch_calls == 0
payload[:elasticsearch_calls] = elasticsearch_calls
payload[:elasticsearch_duration_s] = Gitlab::Instrumentation::ElasticsearchTransport.query_time
end
end
# Returns the queuing duration for a Sidekiq job in seconds, as a float, if the
# `enqueued_at` field or `created_at` field is available.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment