This repository has been archived by the owner on Jan 2, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
190 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-I lib | ||
--color | ||
--format doc | ||
spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source :rubygems | ||
|
||
gemspec | ||
|
||
group :test do | ||
gem 'rspec' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
multimeter (1.0.0.pre0-java) | ||
json | ||
metrics-core-jars | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
diff-lcs (1.1.3) | ||
json (1.7.3-java) | ||
metrics-core-jars (2.1.2-java) | ||
slf4j-jars (~> 1) | ||
rspec (2.11.0) | ||
rspec-core (~> 2.11.0) | ||
rspec-expectations (~> 2.11.0) | ||
rspec-mocks (~> 2.11.0) | ||
rspec-core (2.11.0) | ||
rspec-expectations (2.11.1) | ||
diff-lcs (~> 1.1.3) | ||
rspec-mocks (2.11.0) | ||
slf4j-jars (1.6.2-java) | ||
|
||
PLATFORMS | ||
java | ||
|
||
DEPENDENCIES | ||
multimeter! | ||
rspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require_relative '../spec_helper' | ||
|
||
|
||
module Multimeter | ||
describe Registry do | ||
let :registry do | ||
Multimeter.registry('a_group', 'some_type') | ||
end | ||
|
||
context 'when creating metrics' do | ||
[:counter, :meter, :histogram, :timer].each do |metric_type| | ||
it "##{metric_type} creates a new #{metric_type}" do | ||
metric = registry.send(metric_type, :some_name) | ||
metric.should_not be_nil | ||
end | ||
end | ||
|
||
it '#gauge creates a gauge' do | ||
registry.gauge(:some_name) { 42 } | ||
end | ||
|
||
it 'caches metric objects' do | ||
registry.counter(:some_name).should equal(registry.counter(:some_name)) | ||
end | ||
|
||
it 'raises an error when a gauge is redeclared, but not when it is accessed without a block' do | ||
g1 = registry.gauge(:some_name) { 42 } | ||
g2 = registry.gauge(:some_name) | ||
g1.should equal(g2) | ||
expect { registry.gauge(:some_name) { 43 } }.to raise_error(ArgumentError) | ||
end | ||
|
||
it 'raises an error if a metric is redeclared as another type' do | ||
registry.counter(:some_name) | ||
expect { registry.meter(:some_name) }.to raise_error(ArgumentError) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'multimeter' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
require_relative '../spec_helper' | ||
|
||
|
||
module Yammer::Metrics | ||
describe Yammer::Metrics do | ||
let :registry do | ||
Multimeter.registry('a_group', 'some_type') | ||
end | ||
|
||
describe Counter do | ||
describe '#to_h' do | ||
it 'returns a hash representation of the counter' do | ||
c = registry.counter(:a_counter) | ||
c.inc | ||
c.to_h.should == {:count => 1} | ||
end | ||
end | ||
end | ||
|
||
describe Meter do | ||
describe '#to_h' do | ||
it 'returns a hash representation of the meter' do | ||
m = registry.meter(:some_meter, :event_type => 'stuff') | ||
m.mark | ||
h = m.to_h | ||
h[:event_type].should == 'stuff' | ||
h[:count].should == 1 | ||
h[:mean_rate].should be_a(Numeric) | ||
h[:one_minute_rate].should be_a(Numeric) | ||
h[:five_minute_rate].should be_a(Numeric) | ||
h[:fifteen_minute_rate].should be_a(Numeric) | ||
end | ||
end | ||
end | ||
|
||
describe Histogram do | ||
it 'returns a hash representation of the histogram' do | ||
hs = registry.histogram(:some_hist) | ||
hs.update(4) | ||
h = hs.to_h | ||
h[:count].should == 1 | ||
h[:max].should be_a(Numeric) | ||
h[:min].should be_a(Numeric) | ||
h[:mean].should be_a(Numeric) | ||
h[:std_dev].should be_a(Numeric) | ||
h[:sum].should be_a(Numeric) | ||
end | ||
end | ||
|
||
describe Timer do | ||
describe '#to_h' do | ||
it 'returns a hash representation of the timer' do | ||
t = registry.timer(:some_timer) | ||
t.measure { } | ||
h = t.to_h | ||
h[:event_type].should == 'calls' | ||
h[:count].should == 1 | ||
h[:mean_rate].should be_a(Numeric) | ||
h[:one_minute_rate].should be_a(Numeric) | ||
h[:five_minute_rate].should be_a(Numeric) | ||
h[:fifteen_minute_rate].should be_a(Numeric) | ||
h[:max].should be_a(Numeric) | ||
h[:min].should be_a(Numeric) | ||
h[:mean].should be_a(Numeric) | ||
h[:std_dev].should be_a(Numeric) | ||
h[:sum].should be_a(Numeric) | ||
end | ||
end | ||
end | ||
|
||
describe Gauge do | ||
describe '#to_h' do | ||
it 'returns a hash representation of the gauge' do | ||
g = registry.gauge(:some_gauge) { 42 } | ||
g.to_h.should == {:value => 42} | ||
end | ||
end | ||
end | ||
end | ||
end |