Commit d45e8c55 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Reduce the number of buckets for ElasticSearch

These are buckets of the time spent in ElasticSearch within a
transaction.
parent ec247475
......@@ -4,7 +4,7 @@ module Gitlab
module Metrics
# Rack middleware for tracking Elasticsearch metrics from Grape and Web requests.
class ElasticsearchRackMiddleware
HISTOGRAM_BUCKETS = [0.1, 0.25, 0.5, 1, 2.5, 5, 10, 60].freeze
HISTOGRAM_BUCKETS = [0.1, 0.5, 1, 10, 50].freeze
def initialize(app)
@app = app
......@@ -28,6 +28,8 @@ module Gitlab
docstring 'Amount of calls to Elasticsearch servers during web requests'
end
return unless request_count > 0
transaction.observe(:http_elasticsearch_requests_duration_seconds, query_time) do
docstring 'Query time for Elasticsearch servers during web requests'
buckets HISTOGRAM_BUCKETS
......
......@@ -38,5 +38,15 @@ RSpec.describe Gitlab::Metrics::ElasticsearchRackMiddleware do
expect { middleware.call(env) }.to raise_error(StandardError)
end
context 'when there are no elasticsearch requests' do
let(:elasticsearch_requests_count) { 0 }
it 'does not record duration if there were no ES calls' do
expect(transaction).not_to receive(:observe).with(:http_elasticsearch_requests_duration_seconds)
middleware.call(env)
end
end
end
end
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