diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-14 14:35:25 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-14 18:09:06 +0200 |
commit | ab91f1226f9dc99725e10323c0ea319f335204b3 (patch) | |
tree | 16367ba155cb9e3505c100c5c935d1df67286984 /spec/lib | |
parent | 82090d291fa56e11e5be24102fa651273ac28d4b (diff) | |
download | gitlab-ce-ab91f1226f9dc99725e10323c0ea319f335204b3.tar.gz |
Filter out classes without names in the sampler
We can't do a lot with classes without names as we can't filter by them,
have no idea where they come from, etc. As such it's best to just ignore
these.
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/metrics/sampler_spec.rb | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/spec/lib/gitlab/metrics/sampler_spec.rb b/spec/lib/gitlab/metrics/sampler_spec.rb index 59db127674a..1ab923b58cf 100644 --- a/spec/lib/gitlab/metrics/sampler_spec.rb +++ b/spec/lib/gitlab/metrics/sampler_spec.rb @@ -72,14 +72,25 @@ describe Gitlab::Metrics::Sampler do end end - describe '#sample_objects' do - it 'adds a metric containing the amount of allocated objects' do - expect(sampler).to receive(:add_metric). - with(/object_counts/, an_instance_of(Hash), an_instance_of(Hash)). - at_least(:once). - and_call_original + if Gitlab::Metrics.mri? + describe '#sample_objects' do + it 'adds a metric containing the amount of allocated objects' do + expect(sampler).to receive(:add_metric). + with(/object_counts/, an_instance_of(Hash), an_instance_of(Hash)). + at_least(:once). + and_call_original + + sampler.sample_objects + end - sampler.sample_objects + it 'ignores classes without a name' do + expect(Allocations).to receive(:to_hash).and_return({ Class.new => 4 }) + + expect(sampler).not_to receive(:add_metric). + with('object_counts', an_instance_of(Hash), type: nil) + + sampler.sample_objects + end end end |