diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-12-20 19:30:58 +0100 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-12-21 00:39:52 +0100 |
commit | 040167f0724027020f2d63b6e43481fb3e29dbfc (patch) | |
tree | 43d4c3aa998a4a8a4471d5ece67b6b9b68ce76f3 /spec/lib | |
parent | ed715b7926c31fddb1c835823d509672663e23e6 (diff) | |
download | gitlab-ce-040167f0724027020f2d63b6e43481fb3e29dbfc.tar.gz |
Use seconds where possible, and convert to milliseconds for Influxdb consumption
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/metrics/method_call_spec.rb | 18 | ||||
-rw-r--r-- | spec/lib/gitlab/metrics/system_spec.rb | 4 |
2 files changed, 12 insertions, 10 deletions
diff --git a/spec/lib/gitlab/metrics/method_call_spec.rb b/spec/lib/gitlab/metrics/method_call_spec.rb index 91a70ba01a0..448246ff513 100644 --- a/spec/lib/gitlab/metrics/method_call_spec.rb +++ b/spec/lib/gitlab/metrics/method_call_spec.rb @@ -8,8 +8,7 @@ describe Gitlab::Metrics::MethodCall do it 'measures the performance of the supplied block' do method_call.measure { 'foo' } - expect(method_call.real_time_seconds).to be_a_kind_of(Numeric) - expect(method_call.real_time_milliseconds).to be_a_kind_of(Numeric) + expect(method_call.real_time).to be_a_kind_of(Numeric) expect(method_call.cpu_time).to be_a_kind_of(Numeric) expect(method_call.call_count).to eq(1) end @@ -65,14 +64,17 @@ describe Gitlab::Metrics::MethodCall do describe '#to_metric' do it 'returns a Metric instance' do + expect(method_call).to receive(:real_time).and_return(4.0001) + expect(method_call).to receive(:cpu_time).and_return(3.0001) + method_call.measure { 'foo' } metric = method_call.to_metric expect(metric).to be_an_instance_of(Gitlab::Metrics::Metric) expect(metric.series).to eq('rails_method_calls') - expect(metric.values[:duration]).to be_a_kind_of(Numeric) - expect(metric.values[:cpu_duration]).to be_a_kind_of(Numeric) + expect(metric.values[:duration]).to eq(4000) + expect(metric.values[:cpu_duration]).to eq(3000) expect(metric.values[:call_count]).to be_an(Integer) expect(metric.tags).to eq({ method: 'Foo#bar' }) @@ -85,13 +87,13 @@ describe Gitlab::Metrics::MethodCall do end it 'returns false when the total call time is not above the threshold' do - expect(method_call).to receive(:real_time_seconds).and_return(0.009) + expect(method_call).to receive(:real_time).and_return(0.009) expect(method_call.above_threshold?).to eq(false) end it 'returns true when the total call time is above the threshold' do - expect(method_call).to receive(:real_time_seconds).and_return(9) + expect(method_call).to receive(:real_time).and_return(9) expect(method_call.above_threshold?).to eq(true) end @@ -132,7 +134,7 @@ describe Gitlab::Metrics::MethodCall do describe '#real_time' do context 'without timings' do it 'returns 0.0' do - expect(method_call.real_time_seconds).to eq(0.0) + expect(method_call.real_time).to eq(0.0) end end @@ -140,7 +142,7 @@ describe Gitlab::Metrics::MethodCall do it 'returns the total real time' do method_call.measure { 'foo' } - expect(method_call.real_time_seconds >= 0.0).to be(true) + expect(method_call.real_time >= 0.0).to be(true) end end end diff --git a/spec/lib/gitlab/metrics/system_spec.rb b/spec/lib/gitlab/metrics/system_spec.rb index ea3bd00970e..14afcdf5daa 100644 --- a/spec/lib/gitlab/metrics/system_spec.rb +++ b/spec/lib/gitlab/metrics/system_spec.rb @@ -29,13 +29,13 @@ describe Gitlab::Metrics::System do describe '.cpu_time' do it 'returns a Fixnum' do - expect(described_class.cpu_time).to be_an(Integer) + expect(described_class.cpu_time).to be_an(Float) end end describe '.real_time' do it 'returns a Fixnum' do - expect(described_class.real_time).to be_an(Integer) + expect(described_class.real_time).to be_an(Float) end end |