Commit 2a520b57 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch '214279-es-instrumentation-performance-bar' into 'master'

Performance bar for Elasticsearch

See merge request gitlab-org/gitlab!32939
parents 1520fcb7 e3922741
......@@ -57,6 +57,11 @@ export default {
header: s__('PerformanceBar|Redis calls'),
keys: ['cmd'],
},
{
metric: 'es',
header: s__('PerformanceBar|Elasticsearch calls'),
keys: ['request', 'body'],
},
{
metric: 'total',
header: s__('PerformanceBar|Frontend resources'),
......
......@@ -9,6 +9,7 @@ Peek.into Peek::Views::Host
Peek.into Peek::Views::ActiveRecord
Peek.into Peek::Views::Gitaly
Peek.into Peek::Views::RedisDetailed
Peek.into Peek::Views::Elasticsearch
Peek.into Peek::Views::Rugged
Peek.into Peek::Views::BulletDetailed if defined?(Bullet)
......
# frozen_string_literal: true
require 'spec_helper'
# We don't want to interact with Elasticsearch in GitLab FOSS so we test
# this in ee/ only. The code exists in FOSS and won't do anything.
describe Peek::Views::Elasticsearch, :elastic, :request_store do
before do
allow(::Gitlab::PerformanceBar).to receive(:enabled_for_request?).and_return(true)
ensure_elasticsearch_index!
end
describe '#results' do
let(:results) { described_class.new.results }
it 'includes performance details' do
expect(results[:calls]).to be > 0
expect(results[:duration]).to be_kind_of(String)
expect(results[:details].last[:method]).to eq("POST")
expect(results[:details].last[:path]).to eq("gitlab-test/_refresh")
end
end
end
# 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)
super.merge(request: "#{call[:method]} #{call[:path]}")
end
end
end
end
......@@ -15513,6 +15513,9 @@ msgstr ""
msgid "PerformanceBar|Download"
msgstr ""
msgid "PerformanceBar|Elasticsearch calls"
msgstr ""
msgid "PerformanceBar|Frontend resources"
msgstr ""
......
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