Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/metrics_spec.rb')
-rw-r--r--spec/lib/gitlab/metrics_spec.rb44
1 files changed, 33 insertions, 11 deletions
diff --git a/spec/lib/gitlab/metrics_spec.rb b/spec/lib/gitlab/metrics_spec.rb
index 8f63a5f2043..10177c0e8dd 100644
--- a/spec/lib/gitlab/metrics_spec.rb
+++ b/spec/lib/gitlab/metrics_spec.rb
@@ -74,24 +74,21 @@ describe Gitlab::Metrics do
let(:transaction) { Gitlab::Metrics::Transaction.new }
before do
- allow(Gitlab::Metrics::Transaction).to receive(:current).
+ allow(Gitlab::Metrics).to receive(:current_transaction).
and_return(transaction)
end
it 'adds a metric to the current transaction' do
- expect(transaction).to receive(:add_metric).
- with(:foo, { duration: a_kind_of(Numeric) }, { tag: 'value' })
+ expect(transaction).to receive(:increment).
+ with('foo_real_time', a_kind_of(Numeric))
- Gitlab::Metrics.measure(:foo, {}, tag: 'value') { 10 }
- end
-
- it 'supports adding of custom values' do
- values = { duration: a_kind_of(Numeric), number: 10 }
+ expect(transaction).to receive(:increment).
+ with('foo_cpu_time', a_kind_of(Numeric))
- expect(transaction).to receive(:add_metric).
- with(:foo, values, { tag: 'value' })
+ expect(transaction).to receive(:increment).
+ with('foo_call_count', 1)
- Gitlab::Metrics.measure(:foo, { number: 10 }, tag: 'value') { 10 }
+ Gitlab::Metrics.measure(:foo) { 10 }
end
it 'returns the return value of the block' do
@@ -101,4 +98,29 @@ describe Gitlab::Metrics do
end
end
end
+
+ describe '.tag_transaction' do
+ context 'without a transaction' do
+ it 'does nothing' do
+ expect_any_instance_of(Gitlab::Metrics::Transaction).
+ not_to receive(:add_tag)
+
+ Gitlab::Metrics.tag_transaction(:foo, 'bar')
+ end
+ end
+
+ context 'with a transaction' do
+ let(:transaction) { Gitlab::Metrics::Transaction.new }
+
+ it 'adds the tag to the transaction' do
+ expect(Gitlab::Metrics).to receive(:current_transaction).
+ and_return(transaction)
+
+ expect(transaction).to receive(:add_tag).
+ with(:foo, 'bar')
+
+ Gitlab::Metrics.tag_transaction(:foo, 'bar')
+ end
+ end
+ end
end