summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/gitlab/gitaly_client.rb9
-rw-r--r--lib/peek/views/gitaly.rb1
-rw-r--r--spec/lib/gitlab/gitaly_client_spec.rb25
3 files changed, 29 insertions, 6 deletions
diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb
index 66666b88c15..9be553a8b86 100644
--- a/lib/gitlab/gitaly_client.rb
+++ b/lib/gitlab/gitaly_client.rb
@@ -296,15 +296,14 @@ module Gitlab
def self.add_call_details(details)
return unless Gitlab::SafeRequestStore[:peek_enabled]
- Gitlab::SafeRequestStore['gitaly_call_details'] ||= {}
- Gitlab::SafeRequestStore['gitaly_call_details'][id] ||= {}
- Gitlab::SafeRequestStore['gitaly_call_details'][id].merge!(details)
+ Gitlab::SafeRequestStore['gitaly_call_details'] ||= []
+ Gitlab::SafeRequestStore['gitaly_call_details'] << details
end
def self.list_call_details
- return {} unless Gitlab::SafeRequestStore[:peek_enabled]
+ return [] unless Gitlab::SafeRequestStore[:peek_enabled]
- Gitlab::SafeRequestStore['gitaly_call_details'] || {}
+ Gitlab::SafeRequestStore['gitaly_call_details'] || []
end
def self.expected_server_version
diff --git a/lib/peek/views/gitaly.rb b/lib/peek/views/gitaly.rb
index 860963ef94f..30f95a10024 100644
--- a/lib/peek/views/gitaly.rb
+++ b/lib/peek/views/gitaly.rb
@@ -23,7 +23,6 @@ module Peek
def details
::Gitlab::GitalyClient.list_call_details
- .values
.sort { |a, b| b[:duration] <=> a[:duration] }
.map(&method(:format_call_details))
end
diff --git a/spec/lib/gitlab/gitaly_client_spec.rb b/spec/lib/gitlab/gitaly_client_spec.rb
index 3ae319456da..5eda4d041a8 100644
--- a/spec/lib/gitlab/gitaly_client_spec.rb
+++ b/spec/lib/gitlab/gitaly_client_spec.rb
@@ -216,4 +216,29 @@ describe Gitlab::GitalyClient do
end
end
end
+
+ describe 'Peek Performance bar details' do
+ let(:gitaly_server) { Gitaly::Server.all.first }
+
+ before do
+ Gitlab::SafeRequestStore[:peek_enabled] = true
+ end
+
+ context 'when the request store is active', :request_store do
+ it 'records call details if a RPC is called' do
+ gitaly_server.server_version
+
+ expect(described_class.list_call_details).not_to be_empty
+ expect(described_class.list_call_details.size).to be(1)
+ end
+ end
+
+ context 'when no request store is active' do
+ it 'records nothing' do
+ gitaly_server.server_version
+
+ expect(described_class.list_call_details).to be_empty
+ end
+ end
+ end
end