hallmonitor 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -14
- data/bin/example.rb +15 -4
- data/hallmonitor.gemspec +2 -5
- data/lib/hallmonitor/configuration.rb +11 -0
- data/lib/hallmonitor/dispatcher.rb +40 -0
- data/lib/hallmonitor/event.rb +7 -4
- data/lib/hallmonitor/gauge_event.rb +10 -1
- data/lib/hallmonitor/monitored.rb +8 -5
- data/lib/hallmonitor/outputter.rb +5 -22
- data/lib/hallmonitor/outputters/iooutputter.rb +6 -0
- data/lib/hallmonitor/outputters/statsd_outputter.rb +8 -0
- data/lib/hallmonitor/timed_event.rb +15 -2
- data/lib/hallmonitor/version.rb +2 -2
- data/lib/hallmonitor.rb +24 -0
- data/spec/hallmonitor/dispatcher_spec.rb +58 -0
- data/spec/{monitored_spec.rb → hallmonitor/monitored_spec.rb} +6 -6
- data/spec/spec_helper.rb +2 -0
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a94b8069a987ca9eb3493b18f47b5a92b45b3881
|
4
|
+
data.tar.gz: 44949242eb518251bb8327350c01f4001d978fb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30c54a353d079bfffc7285d229a9b4224ebcf9378fe91412c8e83a5ce4dab7d617d5bc12499890644842be9d5e9864e7f75debaf2ccc74a9b6475e52021163aa
|
7
|
+
data.tar.gz: d17fbde9caa08887b1a704fe9ffa076f362e494b402afc599dee8e798c6f90783b7eef013268218144d08d291fe228d10a0b79795309de3f8ddc11fc52fe20bb
|
data/README.md
CHANGED
@@ -1,18 +1,33 @@
|
|
1
1
|
# Hallmonitor
|
2
2
|
|
3
|
-
Hallmonitor is a simple event monitoring framework for Ruby. It allows programs to define and emit events.
|
3
|
+
Hallmonitor is a simple event monitoring framework for Ruby. It allows programs to define and emit events. These events can then be sent on to various back ends to be counted, monitored, etc.
|
4
4
|
|
5
|
-
Hallmonitor
|
5
|
+
Hallmonitor includes support for publishing events to a Statsd instance if the `statsd-ruby` gem is installed. See https://github.com/reinh/statsd for details
|
6
6
|
|
7
7
|
## Setup
|
8
|
-
Before you can use Hallmonitor you have to do a tiny bit of configuration in the form of adding outputters
|
8
|
+
Before you can use Hallmonitor you have to do a tiny bit of configuration in the form of adding outputters.
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
|
12
|
-
Hallmonitor
|
11
|
+
# Add an outputter to STDOUT
|
12
|
+
Hallmonitor.add_outputter Hallmonitor::Outputters::IOOutputter.new("STDOUT", STDOUT)
|
13
|
+
|
14
|
+
# Add an outputter to StatsD
|
15
|
+
Hallmonitor.add_outputter Hallmonitor::Outputters::StatsdOutputter.new("example", "localhost")
|
16
|
+
```
|
17
|
+
|
18
|
+
The `StatsdOutputter` is only available if you've installed the `statsd-ruby` gem. If it's not available, StatsdOutputter's intitialize method will raise a RuntimeError
|
19
|
+
|
20
|
+
## Configuration
|
21
|
+
Right now there's only one configuration option and here's how you can set it:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
# Configure Hallmonitor
|
25
|
+
Hallmonitor.config |config|
|
26
|
+
config.trap_outputter_exceptions = true # Default value is false
|
27
|
+
end
|
13
28
|
```
|
14
29
|
|
15
|
-
|
30
|
+
**trap_outputter_exceptions:** instructs the output framework to ignore and squash any exceptions that might be raised from inside an outputter. This can be useful if you want to configure multiple outputter and not have a misbehaving one interrupt other outputter, or your system.
|
16
31
|
|
17
32
|
## Usage
|
18
33
|
|
@@ -21,13 +36,15 @@ There are a few different ways to use Hallmonitor:
|
|
21
36
|
### Included in your class
|
22
37
|
```ruby
|
23
38
|
class Foo
|
39
|
+
# Monitored adds a few methods you can use, like emit(...) and watch(...)
|
24
40
|
include Hallmonitor::Monitored
|
25
41
|
|
26
42
|
# This method will emit 100 events
|
27
43
|
def bar
|
44
|
+
|
28
45
|
# Emit 100 events. The string will be the name of the Event object that gets emitted
|
29
46
|
100.times do
|
30
|
-
emit("event")
|
47
|
+
emit("event") # Will emit a new Event with the name 'event'
|
31
48
|
end
|
32
49
|
|
33
50
|
# You can also just emit Event objects themselves
|
@@ -39,9 +56,9 @@ class Foo
|
|
39
56
|
end
|
40
57
|
end
|
41
58
|
|
42
|
-
# This method will emit 1 TimedEvent for the block
|
59
|
+
# This method will emit 1 TimedEvent for the block with the name 'timed'
|
43
60
|
def time_me
|
44
|
-
watch("timed") do
|
61
|
+
watch("timed") do
|
45
62
|
sleep(10)
|
46
63
|
end
|
47
64
|
end
|
@@ -54,14 +71,14 @@ foo.time_me # Will emit a single TimedEvent
|
|
54
71
|
|
55
72
|
### Explicit Event objects
|
56
73
|
```ruby
|
74
|
+
# Event objects include Hallmonitor::Monitored and so they have
|
75
|
+
# an emit method of their own
|
57
76
|
event = Hallmonitor::Event.new("event")
|
58
77
|
event.emit
|
59
78
|
```
|
60
79
|
|
61
|
-
|
62
|
-
|
63
80
|
## Contributing to Hallmonitor
|
64
|
-
|
81
|
+
|
65
82
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
66
83
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
67
84
|
* Fork the project.
|
@@ -72,6 +89,5 @@ event.emit
|
|
72
89
|
|
73
90
|
## Copyright
|
74
91
|
|
75
|
-
Copyright (c) 2012 Chris TenHarmsel. See LICENSE.txt for
|
92
|
+
Copyright (c) 2012-2015 Chris TenHarmsel. See LICENSE.txt for
|
76
93
|
further details.
|
77
|
-
|
data/bin/example.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
1
3
|
lib = File.expand_path('../../lib', __FILE__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
|
@@ -6,8 +8,8 @@ require 'hallmonitor/outputters/iooutputter'
|
|
6
8
|
require 'hallmonitor/outputters/statsd_outputter'
|
7
9
|
require 'pry'
|
8
10
|
|
9
|
-
Hallmonitor
|
10
|
-
Hallmonitor
|
11
|
+
Hallmonitor.add_outputter Hallmonitor::Outputters::IOOutputter.new("STDOUT", STDOUT)
|
12
|
+
Hallmonitor.add_outputter Hallmonitor::Outputters::StatsdOutputter.new("example", "localhost")
|
11
13
|
|
12
14
|
class Foo
|
13
15
|
include Hallmonitor::Monitored
|
@@ -30,9 +32,18 @@ class Foo
|
|
30
32
|
|
31
33
|
def time_me
|
32
34
|
watch("timed") do |x|
|
33
|
-
sleep(
|
35
|
+
sleep(5)
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
|
-
|
40
|
+
f = Foo.new
|
41
|
+
|
42
|
+
puts 'Calling method with timer_for and count_for...'
|
43
|
+
f.do_something
|
44
|
+
|
45
|
+
puts 'Emitting some events'
|
46
|
+
f.emit_events(5)
|
47
|
+
|
48
|
+
puts 'Timing a 5 second block'
|
49
|
+
f.time_me
|
data/hallmonitor.gemspec
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
1
|
lib = File.expand_path('../lib', __FILE__)
|
6
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
7
3
|
require 'hallmonitor/version'
|
@@ -22,7 +18,8 @@ Gem::Specification.new do |s|
|
|
22
18
|
s.require_paths = ["lib"]
|
23
19
|
|
24
20
|
s.add_runtime_dependency("json", [">= 0"])
|
25
|
-
|
21
|
+
|
22
|
+
s.add_development_dependency("statsd-ruby", [">= 0"])
|
26
23
|
s.add_development_dependency("rspec", [">= 3.0"])
|
27
24
|
s.add_development_dependency("rdoc", [">= 0"])
|
28
25
|
s.add_development_dependency("bundler", ["~> 1.3"])
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Hallmonitor
|
2
|
+
class Dispatcher
|
3
|
+
@outputters = []
|
4
|
+
|
5
|
+
# Returns list of outputters registered
|
6
|
+
# @return [Array<Outputter>]
|
7
|
+
def self.outputters
|
8
|
+
@outputters
|
9
|
+
end
|
10
|
+
|
11
|
+
# Adds an outputter. Outputters are required to respond to :process
|
12
|
+
# @param outputter [Object]
|
13
|
+
# @see Hallmonitor::Outputters::StatsdOutputter
|
14
|
+
def self.add_outputter(outputter)
|
15
|
+
@outputters << outputter if outputter.respond_to?(:process)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Removes all outputters
|
19
|
+
def self.clear_outputters
|
20
|
+
@outputters = []
|
21
|
+
end
|
22
|
+
|
23
|
+
# Outputs an event via each registered outputter.
|
24
|
+
# If {Hallmonitor::Configuration} has the option
|
25
|
+
# `trap_outputter_exceptions` set to `true` then this method
|
26
|
+
# will trap and squash any errors raised by the outputter.
|
27
|
+
# @param event [Event] The event to output
|
28
|
+
# @return nil
|
29
|
+
def self.output(event)
|
30
|
+
@outputters.each do |o|
|
31
|
+
begin
|
32
|
+
o.process(event)
|
33
|
+
rescue
|
34
|
+
raise unless Hallmonitor.config.trap_outputter_exceptions
|
35
|
+
end
|
36
|
+
end
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/hallmonitor/event.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
require 'hallmonitor/monitored'
|
2
2
|
module Hallmonitor
|
3
|
-
|
4
|
-
#
|
3
|
+
# The event class is a single-fire event, it most often
|
4
|
+
# represents a single, countable metric.
|
5
5
|
class Event
|
6
6
|
include Hallmonitor::Monitored
|
7
|
-
|
7
|
+
|
8
8
|
attr_accessor :name, :time, :count
|
9
|
-
|
9
|
+
|
10
|
+
# Builds a new event
|
11
|
+
# @param name [String] the name of this event
|
12
|
+
# @param count [Number] the count of this even, defaults to 1
|
10
13
|
def initialize(name, count=1)
|
11
14
|
@name = name
|
12
15
|
@time = Time.now
|
@@ -1,15 +1,24 @@
|
|
1
1
|
module Hallmonitor
|
2
|
+
# A Guage event is an event that has a specific value,
|
3
|
+
# think of it like a tachometer or gas guage on a car:
|
4
|
+
# at any given point it reports the current value of a
|
5
|
+
# variable.
|
2
6
|
class GaugeEvent < Event
|
7
|
+
# @param name [String] Name of this guage
|
8
|
+
# @param value [Number] The current value of this guage
|
3
9
|
def initialize(name, value)
|
4
10
|
super(name, value)
|
5
11
|
end
|
6
12
|
|
13
|
+
# The value of this guage
|
7
14
|
def value
|
8
15
|
count
|
9
16
|
end
|
10
17
|
|
18
|
+
# Sets the value of this guage
|
19
|
+
# @param new_value [Number]
|
11
20
|
def value=(new_value)
|
12
|
-
count = new_value
|
21
|
+
self.count = new_value
|
13
22
|
end
|
14
23
|
|
15
24
|
end
|
@@ -53,12 +53,14 @@ module Hallmonitor
|
|
53
53
|
base.extend(ClassMethods)
|
54
54
|
end
|
55
55
|
|
56
|
-
# Emits an event:
|
57
|
-
# a
|
56
|
+
# Emits an event: self if the event param is nil, the passed in event if
|
57
|
+
# it's an {Event}, or constructs a {Event} from the passed in param.
|
58
|
+
#
|
58
59
|
# If the parameter is a {Hallmonitor::Event}, it will be emitted as is.
|
59
60
|
# Otherwise, a new {Hallmonitor::Event} will be created with the parameter
|
60
61
|
# and emitted.
|
61
62
|
# @param event [Mixed] The thing to emit, see method description
|
63
|
+
# @yield [to_emit] The thing that's going to be emitted
|
62
64
|
# @return nil
|
63
65
|
def emit(event = nil)
|
64
66
|
to_emit = self
|
@@ -69,13 +71,14 @@ module Hallmonitor
|
|
69
71
|
# If we were given a block, then we want to execute that
|
70
72
|
yield(to_emit) if block_given?
|
71
73
|
|
72
|
-
|
74
|
+
Dispatcher.output(to_emit)
|
73
75
|
nil
|
74
76
|
end
|
75
77
|
|
76
|
-
# Executes and times a block of code and emits a
|
77
|
-
# Will emit even if the block raises an error
|
78
|
+
# Executes and times a block of code and emits a {TimedEvent}
|
79
|
+
# @note Will emit the timed event even if the block raises an error
|
78
80
|
# @param name [String] The name of the event to emit
|
81
|
+
# @yield [event] the event object that will be emitted
|
79
82
|
# @return Whatever the block's return value is
|
80
83
|
def watch(name)
|
81
84
|
event = Hallmonitor::TimedEvent.new(name)
|
@@ -1,34 +1,17 @@
|
|
1
1
|
module Hallmonitor
|
2
|
+
# An {Outputter} is an object that can process {Hallmonitor::Event}s
|
2
3
|
class Outputter
|
3
4
|
attr_reader :name
|
4
|
-
@@outputters = Array.new
|
5
5
|
|
6
|
+
# Initializes a new Outputter
|
7
|
+
# @param name [Object] Probably a string or symbol, the name of this
|
8
|
+
# outputter
|
6
9
|
def initialize(name)
|
7
10
|
raise(ArgumentError, "Outputter expects a name") if name.nil?
|
8
11
|
@name = name
|
9
12
|
end
|
10
13
|
|
11
|
-
#
|
12
|
-
# @return [Object] Outputters
|
13
|
-
def self.outputters
|
14
|
-
@@outputters
|
15
|
-
end
|
16
|
-
|
17
|
-
# Adds an outputter. Outputters are required to respond to :process
|
18
|
-
# @see Hallmonitor::Outputters::StatsdOutputter
|
19
|
-
def self.add_outputter(outputter)
|
20
|
-
@@outputters << outputter if outputter.respond_to?(:process)
|
21
|
-
end
|
22
|
-
|
23
|
-
# Outputs the event via each configured outputter
|
24
|
-
# @param event [Event] The event to output
|
25
|
-
def self.output(event)
|
26
|
-
@@outputters.each do |o|
|
27
|
-
o.process(event)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Processes and event. Child classes should implement this to output events
|
14
|
+
# Processes an event. Child classes should implement this to output events
|
32
15
|
# @param event [Event] the event to process
|
33
16
|
def process(event)
|
34
17
|
# Nothing
|
@@ -2,13 +2,19 @@ require 'json'
|
|
2
2
|
|
3
3
|
module Hallmonitor
|
4
4
|
module Outputters
|
5
|
+
# Simple outputter that just prints to an output stream
|
5
6
|
class IOOutputter < Outputter
|
6
7
|
|
8
|
+
# Builds a new IOOutputter
|
9
|
+
# @param name [String] Name for this outputter
|
10
|
+
# @param out [IO] Output to write to
|
7
11
|
def initialize(name, out)
|
8
12
|
super(name)
|
9
13
|
@out = out
|
10
14
|
end
|
11
15
|
|
16
|
+
# Sends an event to the configured output
|
17
|
+
# on IOError the output will be closed
|
12
18
|
def process(event)
|
13
19
|
begin
|
14
20
|
@out.print "EVENT: #{event.to_json}\n"
|
@@ -5,13 +5,21 @@ end
|
|
5
5
|
|
6
6
|
module Hallmonitor
|
7
7
|
module Outputters
|
8
|
+
# An outputter for StatsD
|
8
9
|
class StatsdOutputter < Outputter
|
10
|
+
# Builds a new StatsdOutputter.
|
11
|
+
# @param prefix [String] Prefix for all events output by this outputter,
|
12
|
+
# the prefix will be applied to all event names before sending to statsd
|
13
|
+
# @param host [String] Statsd Host, defaults to 'localhost'
|
14
|
+
# @param port [Number] Statsd Port, defaults to 8125
|
15
|
+
# @raise if Statsd is undefined (Gem not present)
|
9
16
|
def initialize(prefix, host="localhost", port=8125)
|
10
17
|
raise "In order to use StatsdOutputter, statsd gem must be installed" unless defined?(Statsd)
|
11
18
|
super(prefix)
|
12
19
|
@statsd = Statsd.new(host).tap{|sd| sd.namespace = name}
|
13
20
|
end
|
14
21
|
|
22
|
+
# Sends events to statsd instance
|
15
23
|
def process(event)
|
16
24
|
if(event.respond_to?(:duration))
|
17
25
|
@statsd.timing(event.name, event.duration)
|
@@ -1,17 +1,30 @@
|
|
1
1
|
module Hallmonitor
|
2
|
+
# An event that represents a span of time
|
2
3
|
class TimedEvent < Event
|
4
|
+
# @!attribute start
|
5
|
+
# @return [DateTime] the start time of this timed event
|
6
|
+
# @!attribute stop
|
7
|
+
# @return [DateTime] the stop time of this timed event
|
8
|
+
|
3
9
|
attr_accessor :start, :stop
|
4
10
|
|
11
|
+
# Builds a new {TimedEvent}
|
12
|
+
# @param name [String] name of this event
|
13
|
+
# @param duration [Number] the timespan of this event
|
5
14
|
def initialize(name, duration=nil)
|
6
15
|
super(name)
|
7
16
|
@duration = duration
|
8
17
|
end
|
9
18
|
|
10
|
-
#
|
11
|
-
#
|
19
|
+
# @!attribute [w] duration
|
20
|
+
# Duration, should be set in ms, will take precedence over
|
21
|
+
# calculating via start and stop times
|
22
|
+
# @return [Number] the currently value of duration
|
12
23
|
attr_writer :duration
|
13
24
|
|
14
25
|
# Reports duration of this timed event in ms
|
26
|
+
# @return [Number] duration, in ms if calculated based on
|
27
|
+
# {#start} and {#stop}
|
15
28
|
def duration
|
16
29
|
if @duration
|
17
30
|
@duration
|
data/lib/hallmonitor/version.rb
CHANGED
data/lib/hallmonitor.rb
CHANGED
@@ -1,6 +1,30 @@
|
|
1
|
+
require 'hallmonitor/configuration'
|
2
|
+
require 'hallmonitor/dispatcher'
|
1
3
|
require 'hallmonitor/monitored'
|
2
4
|
require 'hallmonitor/event'
|
3
5
|
require 'hallmonitor/timed_event'
|
4
6
|
require 'hallmonitor/gauge_event'
|
5
7
|
require 'hallmonitor/outputter'
|
6
8
|
require 'hallmonitor/middleware'
|
9
|
+
|
10
|
+
module Hallmonitor
|
11
|
+
class << self
|
12
|
+
attr_accessor :config
|
13
|
+
end
|
14
|
+
|
15
|
+
# Method to configure Hallmonitor, takes a block and passes a
|
16
|
+
# {Hallmonitor::Configuration} object in, which can be used to
|
17
|
+
# set configuration options.
|
18
|
+
def self.configure
|
19
|
+
self.config ||= Hallmonitor::Configuration.new
|
20
|
+
yield(config)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Adds an outputter to Hallmonitor. Whenever events are emitted
|
24
|
+
# they will be sent to all registered outputters
|
25
|
+
# @param outputter [Outputter] An instance of an outputter
|
26
|
+
# @note This delegates to {Dispatcher.add_outputter}
|
27
|
+
def self.add_outputter(outputter)
|
28
|
+
Dispatcher.add_outputter(outputter)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Hallmonitor
|
3
|
+
RSpec.describe Dispatcher do
|
4
|
+
let(:outputter) { instance_double(Hallmonitor::Outputter) }
|
5
|
+
before do
|
6
|
+
allow(outputter).to receive(:process)
|
7
|
+
Dispatcher.add_outputter(outputter)
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
Dispatcher.clear_outputters
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "managing outputters" do
|
15
|
+
it 'tracks outputters' do
|
16
|
+
expect(Dispatcher.outputters).to include(outputter)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#output' do
|
21
|
+
it 'dispatches to outputters' do
|
22
|
+
expect(outputter).to receive(:process).with("thing")
|
23
|
+
Dispatcher.output("thing")
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'with exception trapping turned off' do
|
27
|
+
before do
|
28
|
+
allow(outputter).to receive(:process).and_raise("FOOOOO")
|
29
|
+
Hallmonitor.configure do |c|
|
30
|
+
c.trap_outputter_exceptions = false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
it 'raises outputter exceptions' do
|
34
|
+
expect{Dispatcher.output("thing")}.to raise_error
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'with exception trapping turned on' do
|
39
|
+
let(:another_outputter) { instance_double(Hallmonitor::Outputter) }
|
40
|
+
before do
|
41
|
+
allow(outputter).to receive(:process).and_raise("FOOOOO")
|
42
|
+
Hallmonitor.configure do |c|
|
43
|
+
c.trap_outputter_exceptions = true
|
44
|
+
end
|
45
|
+
allow(another_outputter).to receive(:process)
|
46
|
+
Dispatcher.add_outputter(another_outputter)
|
47
|
+
end
|
48
|
+
it 'traps outputter exceptions' do
|
49
|
+
expect{Dispatcher.output("thing")}.to_not raise_error
|
50
|
+
end
|
51
|
+
it 'calls other outputters' do
|
52
|
+
expect(another_outputter).to receive(:process).with("thing")
|
53
|
+
expect{Dispatcher.output("thing")}.to_not raise_error
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -27,7 +27,7 @@ RSpec.describe Hallmonitor::Monitored do
|
|
27
27
|
|
28
28
|
describe '#timer_for' do
|
29
29
|
it 'emits a timer with an appropriate name' do
|
30
|
-
expect(Hallmonitor::
|
30
|
+
expect(Hallmonitor::Dispatcher).to(
|
31
31
|
receive(:output).with(a_timed_event_with_name('thing.timer_for_test')))
|
32
32
|
Thing.new.timer_for_test
|
33
33
|
end
|
@@ -35,7 +35,7 @@ RSpec.describe Hallmonitor::Monitored do
|
|
35
35
|
|
36
36
|
describe '#count_for' do
|
37
37
|
it 'emits an event with an appropriate name' do
|
38
|
-
expect(Hallmonitor::
|
38
|
+
expect(Hallmonitor::Dispatcher).to(
|
39
39
|
receive(:output).with(an_event_with_name('thing.count_for_test')))
|
40
40
|
Thing.new.count_for_test
|
41
41
|
end
|
@@ -58,7 +58,7 @@ RSpec.describe Hallmonitor::Monitored do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'emits a timer event for the block' do
|
61
|
-
expect(Hallmonitor::
|
61
|
+
expect(Hallmonitor::Dispatcher).to(
|
62
62
|
receive(:output).with(a_timed_event_with_name(name)))
|
63
63
|
subject.watch(name) do
|
64
64
|
'foo'
|
@@ -67,7 +67,7 @@ RSpec.describe Hallmonitor::Monitored do
|
|
67
67
|
|
68
68
|
describe 'when the block raises an error' do
|
69
69
|
it 'emits a timer for the block' do
|
70
|
-
expect(Hallmonitor::
|
70
|
+
expect(Hallmonitor::Dispatcher).to(
|
71
71
|
receive(:output).with(a_timed_event_with_name(name)))
|
72
72
|
expect {
|
73
73
|
subject.watch(name) do
|
@@ -83,7 +83,7 @@ RSpec.describe Hallmonitor::Monitored do
|
|
83
83
|
let(:name) { 'foo' }
|
84
84
|
|
85
85
|
it 'emits an event with the passed in name' do
|
86
|
-
expect(Hallmonitor::
|
86
|
+
expect(Hallmonitor::Dispatcher).to(
|
87
87
|
receive(:output).with(an_event_with_name(name)))
|
88
88
|
subject.emit(name)
|
89
89
|
end
|
@@ -107,7 +107,7 @@ RSpec.describe Hallmonitor::Monitored do
|
|
107
107
|
let(:event) { Hallmonitor::Event.new('bar') }
|
108
108
|
|
109
109
|
it 'emits the passed in event' do
|
110
|
-
expect(Hallmonitor::
|
110
|
+
expect(Hallmonitor::Dispatcher).to receive(:output).with(event)
|
111
111
|
subject.emit(event)
|
112
112
|
end
|
113
113
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hallmonitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris TenHarmsel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
|
-
type: :
|
34
|
+
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
@@ -138,6 +138,8 @@ files:
|
|
138
138
|
- bin/example.rb
|
139
139
|
- hallmonitor.gemspec
|
140
140
|
- lib/hallmonitor.rb
|
141
|
+
- lib/hallmonitor/configuration.rb
|
142
|
+
- lib/hallmonitor/dispatcher.rb
|
141
143
|
- lib/hallmonitor/event.rb
|
142
144
|
- lib/hallmonitor/gauge_event.rb
|
143
145
|
- lib/hallmonitor/middleware.rb
|
@@ -148,7 +150,8 @@ files:
|
|
148
150
|
- lib/hallmonitor/outputters/statsd_outputter.rb
|
149
151
|
- lib/hallmonitor/timed_event.rb
|
150
152
|
- lib/hallmonitor/version.rb
|
151
|
-
- spec/
|
153
|
+
- spec/hallmonitor/dispatcher_spec.rb
|
154
|
+
- spec/hallmonitor/monitored_spec.rb
|
152
155
|
- spec/spec_helper.rb
|
153
156
|
homepage: http://github.com/epchris/hallmonitor
|
154
157
|
licenses:
|
@@ -170,11 +173,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
173
|
version: '0'
|
171
174
|
requirements: []
|
172
175
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.
|
176
|
+
rubygems_version: 2.4.5
|
174
177
|
signing_key:
|
175
178
|
specification_version: 4
|
176
179
|
summary: Simple Ruby Event Monitoring
|
177
180
|
test_files:
|
178
|
-
- spec/
|
181
|
+
- spec/hallmonitor/dispatcher_spec.rb
|
182
|
+
- spec/hallmonitor/monitored_spec.rb
|
179
183
|
- spec/spec_helper.rb
|
180
184
|
has_rdoc:
|