summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/metrics/method_call_spec.rb
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2017-11-23 15:28:37 +0100
committerPawel Chojnacki <pawel@chojnacki.ws>2017-11-23 23:33:01 +0100
commit0051b5fbcc3154dacf20b1e89387b9ea55827266 (patch)
tree7f27a93b1aeb9783b34ff53d00942bf08da35aca /spec/lib/gitlab/metrics/method_call_spec.rb
parentefe4cab92b1c93b2beb75fc6b4c0dbe0787d301e (diff)
downloadgitlab-ce-0051b5fbcc3154dacf20b1e89387b9ea55827266.tar.gz
Use only real duration to measure method call performance via Prometheus
Diffstat (limited to 'spec/lib/gitlab/metrics/method_call_spec.rb')
-rw-r--r--spec/lib/gitlab/metrics/method_call_spec.rb22
1 files changed, 9 insertions, 13 deletions
diff --git a/spec/lib/gitlab/metrics/method_call_spec.rb b/spec/lib/gitlab/metrics/method_call_spec.rb
index cffd061a54d..b20c9e227d6 100644
--- a/spec/lib/gitlab/metrics/method_call_spec.rb
+++ b/spec/lib/gitlab/metrics/method_call_spec.rb
@@ -25,11 +25,7 @@ describe Gitlab::Metrics::MethodCall do
end
it 'observes the performance of the supplied block' do
- expect(described_class.call_real_duration_histogram)
- .to receive(:observe)
- .with({ module: :Foo, method: '#bar' }, be_a_kind_of(Numeric))
-
- expect(described_class.call_cpu_duration_histogram)
+ expect(described_class.call_duration_histogram)
.to receive(:observe)
.with({ module: :Foo, method: '#bar' }, be_a_kind_of(Numeric))
@@ -44,10 +40,7 @@ describe Gitlab::Metrics::MethodCall do
end
it 'does not observe the performance' do
- expect(described_class.call_real_duration_histogram)
- .not_to receive(:observe)
-
- expect(described_class.call_cpu_duration_histogram)
+ expect(described_class.call_duration_histogram)
.not_to receive(:observe)
method_call.measure { 'foo' }
@@ -64,10 +57,7 @@ describe Gitlab::Metrics::MethodCall do
end
it 'does not observe the performance' do
- expect(described_class.call_real_duration_histogram)
- .not_to receive(:observe)
-
- expect(described_class.call_cpu_duration_histogram)
+ expect(described_class.call_duration_histogram)
.not_to receive(:observe)
method_call.measure { 'foo' }
@@ -92,7 +82,13 @@ describe Gitlab::Metrics::MethodCall do
end
describe '#above_threshold?' do
+ before do
+ allow(Gitlab::Metrics).to receive(:method_call_threshold).and_return(100)
+ end
+
it 'returns false when the total call time is not above the threshold' do
+ expect(method_call).to receive(:real_time).and_return(9)
+
expect(method_call.above_threshold?).to eq(false)
end