mirror of
https://github.com/jimeh/airbrake-statsd.git
synced 2026-02-19 10:56:43 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 27f0403bf1 | |||
| 2e380d1f8f | |||
| 58d68a6779 | |||
| 7009d8c702 | |||
| c3300d264c |
14
README.md
14
README.md
@@ -1,14 +1,20 @@
|
|||||||
# Airbrake-Statsd
|
# Airbrake-Statsd [](http://travis-ci.org/jimeh/airbrake-statsd)
|
||||||
|
|
||||||
[](http://travis-ci.org/jimeh/airbrake-statsd)
|
Extends the [Airbrake][] gem to also report exceptions to Esty's [StatsD][]
|
||||||
|
|
||||||
Extends the [Airbrake][] gem to also report exceptions Esty's [Statsd][]
|
|
||||||
statistics aggregator.
|
statistics aggregator.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
Command line:
|
||||||
|
|
||||||
gem install airbrake-statsd
|
gem install airbrake-statsd
|
||||||
|
|
||||||
|
Gemfile:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
gem 'airbrake-statsd'
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
It's assumed you know what both Airbrake and StatsD are before attempting to
|
It's assumed you know what both Airbrake and StatsD are before attempting to
|
||||||
|
|||||||
@@ -1,21 +1,15 @@
|
|||||||
module Airbrake
|
module Airbrake
|
||||||
class << self
|
class << self
|
||||||
|
|
||||||
def notify_with_statds(*args)
|
private
|
||||||
|
|
||||||
|
def send_notice_with_statsd(*args)
|
||||||
Airbrake::Statsd.increment
|
Airbrake::Statsd.increment
|
||||||
notify_without_statsd(*args)
|
send_notice_without_statsd(*args)
|
||||||
end
|
end
|
||||||
|
|
||||||
alias :notify_without_statsd :notify
|
alias :send_notice_without_statsd :send_notice
|
||||||
alias :notify :notify_with_statds
|
alias :send_notice :send_notice_with_statsd
|
||||||
|
|
||||||
def notify_or_ignore_with_statsd(*args)
|
|
||||||
Airbrake::Statsd.increment
|
|
||||||
notify_or_ignore_without_statsd(*args)
|
|
||||||
end
|
|
||||||
|
|
||||||
alias :notify_or_ignore_without_statsd :notify_or_ignore
|
|
||||||
alias :notify_or_ignore :notify_or_ignore_with_statsd
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module Airbrake
|
module Airbrake
|
||||||
module Statsd
|
module Statsd
|
||||||
VERSION = '0.2.0'
|
VERSION = '0.2.1'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,58 +4,33 @@ describe Airbrake do
|
|||||||
|
|
||||||
subject { Airbrake }
|
subject { Airbrake }
|
||||||
|
|
||||||
it '#notify is an alias to #notify_with_statsd' do
|
let(:notice) { mock('Notice', :to_xml => '') }
|
||||||
subject.method(:notify).should == subject.method(:notify_with_statds)
|
let(:configuration) { mock('Configuration', :public? => true) }
|
||||||
|
|
||||||
|
let(:sender) do
|
||||||
|
sender = mock('Sender')
|
||||||
|
sender.stub(:send_to_airbrake)
|
||||||
|
sender
|
||||||
end
|
end
|
||||||
|
|
||||||
it '#notify_or_ignore is an alias to #notify_or_ignore_with_statsd' do
|
describe '#send_notice_without_statsd' do
|
||||||
subject.method(:notify_or_ignore).
|
before do
|
||||||
should == subject.method(:notify_or_ignore_with_statsd)
|
Airbrake.stub(:configuration).and_return(configuration)
|
||||||
end
|
Airbrake.stub(:sender).and_return(sender)
|
||||||
|
end
|
||||||
|
|
||||||
describe '#notify_without_statsd' do
|
|
||||||
it 'does not call Airbrake::Statsd.increment' do
|
it 'does not call Airbrake::Statsd.increment' do
|
||||||
Airbrake.stub(:send_notice).and_return(nil)
|
|
||||||
|
|
||||||
Airbrake.should_receive(:build_notice_for).with('oops', {})
|
|
||||||
Airbrake::Statsd.should_not_receive(:increment)
|
Airbrake::Statsd.should_not_receive(:increment)
|
||||||
|
Airbrake.send(:send_notice_without_statsd, notice)
|
||||||
Airbrake.notify_without_statsd('oops', {})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#notify' do
|
describe '#send_notice' do
|
||||||
it 'calls Airbrake::Statsd.increment' do
|
it 'calls Airbrake::Statsd.increment' do
|
||||||
Airbrake.stub(:send_notice).and_return(nil)
|
|
||||||
|
|
||||||
Airbrake.should_receive(:build_notice_for).with('oops', {})
|
|
||||||
Airbrake::Statsd.should_receive(:increment)
|
Airbrake::Statsd.should_receive(:increment)
|
||||||
|
Airbrake.should_receive(:send_notice_without_statsd)
|
||||||
|
|
||||||
Airbrake.notify('oops', {})
|
Airbrake.send(:send_notice, notice)
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#notify_or_ignore_without_statsd' do
|
|
||||||
it 'does not call Airbrake::Statsd.increment' do
|
|
||||||
Airbrake.stub(:send_notice).and_return(nil)
|
|
||||||
|
|
||||||
Airbrake.should_receive(:build_notice_for).with('oops', {}).
|
|
||||||
and_return(mock('Notice', :ignore? => false))
|
|
||||||
Airbrake::Statsd.should_not_receive(:increment)
|
|
||||||
|
|
||||||
Airbrake.notify_or_ignore_without_statsd('oops', {})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#notify_or_ignore' do
|
|
||||||
it 'calls Airbrake::Statsd.increment' do
|
|
||||||
Airbrake.stub(:send_notice).and_return(nil)
|
|
||||||
|
|
||||||
Airbrake.should_receive(:build_notice_for).with('oops', {}).
|
|
||||||
and_return(mock('Notice', :ignore? => false))
|
|
||||||
Airbrake::Statsd.should_receive(:increment)
|
|
||||||
|
|
||||||
Airbrake.notify_or_ignore('oops', {})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user