Commit 2562dcab authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'bvl-skip-metrics-es-rack' into 'master'

Skip recording ES-metrics when there are none

Closes #233858

See merge request gitlab-org/gitlab!38831
parents e6ab5eff 35694e4c
......@@ -24,12 +24,12 @@ module Gitlab
query_time = ::Gitlab::Instrumentation::ElasticsearchTransport.query_time
request_count = ::Gitlab::Instrumentation::ElasticsearchTransport.get_request_count
return unless request_count > 0
transaction.increment(:http_elasticsearch_requests_total, request_count) do
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
......
......@@ -42,8 +42,9 @@ RSpec.describe Gitlab::Metrics::ElasticsearchRackMiddleware do
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
it 'does not record any metrics' do
expect(transaction).not_to receive(:observe).with(:http_elasticsearch_requests_duration_seconds)
expect(transaction).not_to receive(:increment).with(:http_elasticsearch_requests_total, 0)
middleware.call(env)
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