diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-12-15 16:38:25 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-12-17 17:25:48 +0100 |
commit | a41287d8989d7d49b405fd8f658d6c6e4edfd307 (patch) | |
tree | 283b85ee5892e999e029afdf035c7713e2dcdc0d /spec | |
parent | 13dbd663acbbe91ddac77b650a90377cd12c54b8 (diff) | |
download | gitlab-ce-a41287d8989d7d49b405fd8f658d6c6e4edfd307.tar.gz |
Only track method calls above a certain threshold
This ensures we don't end up wasting resources by tracking method calls
that only take a few microseconds. By default the threshold is 10
milliseconds but this can be changed using the gitlab.yml configuration
file.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/metrics/instrumentation_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/lib/gitlab/metrics/instrumentation_spec.rb b/spec/lib/gitlab/metrics/instrumentation_spec.rb index 5fe7a369cba..71d7209db0f 100644 --- a/spec/lib/gitlab/metrics/instrumentation_spec.rb +++ b/spec/lib/gitlab/metrics/instrumentation_spec.rb @@ -42,6 +42,9 @@ describe Gitlab::Metrics::Instrumentation do end it 'tracks the call duration upon calling the method' do + allow(Gitlab::Metrics).to receive(:method_call_threshold). + and_return(0) + allow(described_class).to receive(:transaction). and_return(transaction) @@ -51,6 +54,15 @@ describe Gitlab::Metrics::Instrumentation do @dummy.foo end + + it 'does not track method calls below a given duration threshold' do + allow(Gitlab::Metrics).to receive(:method_call_threshold). + and_return(100) + + expect(transaction).to_not receive(:add_metric) + + @dummy.foo + end end describe 'with metrics disabled' do @@ -84,6 +96,9 @@ describe Gitlab::Metrics::Instrumentation do end it 'tracks the call duration upon calling the method' do + allow(Gitlab::Metrics).to receive(:method_call_threshold). + and_return(0) + allow(described_class).to receive(:transaction). and_return(transaction) @@ -93,6 +108,15 @@ describe Gitlab::Metrics::Instrumentation do @dummy.new.bar end + + it 'does not track method calls below a given duration threshold' do + allow(Gitlab::Metrics).to receive(:method_call_threshold). + and_return(100) + + expect(transaction).to_not receive(:add_metric) + + @dummy.new.bar + end end describe 'with metrics disabled' do |