diff options
author | Stan Hu <stanhu@gmail.com> | 2019-07-17 12:33:49 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-07-17 15:11:01 -0700 |
commit | 9dd59df6991b9d82bcbb95bf406194aab8ecf743 (patch) | |
tree | 8e1331802676781b266be121e8e228cb272fa054 /spec/lib/peek | |
parent | c11eb0c3a42dba550764e96426dd9bf21347b917 (diff) | |
download | gitlab-ce-9dd59df6991b9d82bcbb95bf406194aab8ecf743.tar.gz |
Fix inconsistency in Redis performance bar statssh-fix-redis-performance-bar
peek-redis resets its counters at the start of an ActionController
notification (`start_processing.action_controller`), which causes it to
miss some Redis queries that precede it, such as the database load
balancer and Rack Attack queries. This produces inconsistencies in the
performance bar between the number of calls and their durations with the
actual calls in the detailed view.
We fix this by getting rid of peek-redis in favor of consolidating all
logic into the `RedisDetailed` view, which tracks Redis queries using
`RequestStore`. This has the nice property of removing thread-specific
counters as well.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/64707
Diffstat (limited to 'spec/lib/peek')
-rw-r--r-- | spec/lib/peek/views/redis_detailed_spec.rb | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/spec/lib/peek/views/redis_detailed_spec.rb b/spec/lib/peek/views/redis_detailed_spec.rb index da13b6df53b..61096e6c69e 100644 --- a/spec/lib/peek/views/redis_detailed_spec.rb +++ b/spec/lib/peek/views/redis_detailed_spec.rb @@ -2,14 +2,8 @@ require 'spec_helper' -describe Peek::Views::RedisDetailed do - let(:redis_detailed_class) do - Class.new do - include Peek::Views::RedisDetailed - end - end - - subject { redis_detailed_class.new } +describe Peek::Views::RedisDetailed, :request_store do + subject { described_class.new } using RSpec::Parameterized::TableSyntax @@ -22,15 +16,24 @@ describe Peek::Views::RedisDetailed do end with_them do - it 'scrubs Redis commands', :request_store do + it 'scrubs Redis commands' do subject.detail_store << { cmd: cmd, duration: 1.second } - expect(subject.details.count).to eq(1) - expect(subject.details.first) + expect(subject.results[:details].count).to eq(1) + expect(subject.results[:details].first) .to eq({ cmd: expected, duration: 1000 }) end end + + it 'returns aggregated results' do + subject.detail_store << { cmd: [:get, 'test'], duration: 0.001 } + subject.detail_store << { cmd: [:get, 'test'], duration: 1.second } + + expect(subject.results[:calls]).to eq(2) + expect(subject.results[:duration]).to eq('1001.00ms') + expect(subject.results[:details].count).to eq(2) + end end |