Skip to content

Commit

Permalink
Merge f2c217b into 1f7f007
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinAiken committed Feb 14, 2014
2 parents 1f7f007 + f2c217b commit 54c22d4
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# feature/single_socket
* Use a single UDP Socket

# 0.0.2
* BUGFIX: Log location relative to `Adhearsion.root`

Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source "https://rubygems.org"

gem 'statsd-ruby', require: false, github: "JustinAiken/statsd", branch: "feature/optional_socket_argument"

gemspec
1 change: 1 addition & 0 deletions lib/adhearsion-stats.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module AdhearsionStats; end

require "adhearsion-stats/version"
require "adhearsion-stats/stactor"
require "adhearsion-stats/metrics_logger"
require "adhearsion-stats/plugin"
5 changes: 3 additions & 2 deletions lib/adhearsion-stats/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ class Plugin < Adhearsion::Plugin
init :statsd do
AdhearsionStats.setup_logger if Adhearsion.config.statsd.log_metrics

AdhearsionStats.statsd = Statsd.new Adhearsion.config.statsd.host, Adhearsion.config.statsd.port
AdhearsionStats.loaded = true
statsd = Statsd.new Adhearsion.config.statsd.host, Adhearsion.config.statsd.port, UDPSocket.new
AdhearsionStats.statsd = AdhearsionStats::Stactor.new statsd

AdhearsionStats.loaded = true
logger.info "Adhearsion-Stats has been loaded"
end
end
Expand Down
19 changes: 19 additions & 0 deletions lib/adhearsion-stats/stactor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module AdhearsionStats
class Stactor
include Celluloid

attr_accessor :statsd

def initialize(statsd)
@statsd = statsd
end

def send_stat(meth, *args, &blk)
statsd.send meth, *args, &blk
end

def method_missing(meth, *args, &blk)
self.async.send_stat meth, *args, &blk
end
end
end
7 changes: 4 additions & 3 deletions spec/adhearsion-stats/plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
end

it "sets init variables" do
subject.statsd.should be_an_instance_of Statsd
subject.statsd.host.should == "127.0.0.1"
subject.statsd.port.should == 8125
subject.statsd.should be_an_instance_of AdhearsionStats::Stactor
subject.statsd.statsd.should be_an_instance_of Statsd
subject.statsd.statsd.host.should == "127.0.0.1"
subject.statsd.statsd.port.should == 8125

subject.metrics_logger.should be_an_instance_of AdhearsionStats::MetricsLogger
subject.loaded.should be_true
Expand Down

0 comments on commit 54c22d4

Please sign in to comment.