debian-mirror-gitlab/lib/peek/views/elasticsearch.rb

48 lines
998 B
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
module Peek
module Views
class Elasticsearch < DetailedView
DEFAULT_THRESHOLDS = {
calls: 5,
duration: 1000,
individual_call: 1000
}.freeze
THRESHOLDS = {
production: {
calls: 5,
duration: 1000,
individual_call: 1000
}
}.freeze
def key
'es'
end
def self.thresholds
@thresholds ||= THRESHOLDS.fetch(Rails.env.to_sym, DEFAULT_THRESHOLDS)
end
private
def duration
::Gitlab::Instrumentation::ElasticsearchTransport.query_time * 1000
end
def calls
::Gitlab::Instrumentation::ElasticsearchTransport.get_request_count
end
def call_details
::Gitlab::Instrumentation::ElasticsearchTransport.detail_store
end
def format_call_details(call)
2020-07-28 23:09:34 +05:30
super.merge(request: "#{call[:method]} #{call[:path]}?#{call[:params].to_query}")
2020-06-23 00:09:42 +05:30
end
end
end
end