blabbermouth-new_relic 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/blabbermouth-new_relic.rb +7 -0
- data/lib/blabbermouth/new_relic/bystander.rb +25 -0
- data/lib/blabbermouth/new_relic/version.rb +6 -0
- data/spec/blabbermouth/new_relic/bystander_spec.rb +47 -0
- data/spec/spec_helper.rb +103 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 40e464eeff981a33a06d4df1b942c37c6de2e0e6
|
4
|
+
data.tar.gz: 0ebf5b65616864de2ab57a79d4f4a7af4b8e74af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1d185d8d1db38b0843764368854f5aa4f9f13def05b3b1659e1c65d3cd40f322ba8d5dfe324f2b0979efd3f970829295eb457a818c817144a65bdf4850dab903
|
7
|
+
data.tar.gz: 9d0db392af71d7206f1a3b9f054e277dcb4465b742af708df2febafeb10fe717263044de2d99fc92b9aacd62c646acb80a4322a3f26b7637815918176404094f
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Blabbermouth
|
2
|
+
module Bystanders
|
3
|
+
class NewRelic < Base
|
4
|
+
def error(key, e, *args)
|
5
|
+
::NewRelic::Agent.notice_error(e, (args.extract_options! || {}).merge(key: key))
|
6
|
+
end
|
7
|
+
|
8
|
+
def info(key, msg=nil, *args)
|
9
|
+
::NewRelic::Agent.record_custom_event(key, (args.extract_options! || {}).merge({message: msg}))
|
10
|
+
end
|
11
|
+
|
12
|
+
def increment(key, by=1, *args)
|
13
|
+
::NewRelic::Agent.increment_metric(key, by)
|
14
|
+
end
|
15
|
+
|
16
|
+
def count(key, total, *args)
|
17
|
+
::NewRelic::Agent.record_metric(key, total)
|
18
|
+
end
|
19
|
+
|
20
|
+
def time(key, duration=nil, *args)
|
21
|
+
::NewRelic::Agent.record_custom_event(key, (args.extract_options! || {}).merge({duration: duration}))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'blabbermouth-new_relic'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
RSpec.describe Blabbermouth::Bystanders::NewRelic do
|
5
|
+
before do
|
6
|
+
stub_const("::NewRelic::Agent", double)
|
7
|
+
allow(::NewRelic::Agent).to receive(:notice_error)
|
8
|
+
allow(::NewRelic::Agent).to receive(:record_custom_event)
|
9
|
+
allow(::NewRelic::Agent).to receive(:increment_metric)
|
10
|
+
allow(::NewRelic::Agent).to receive(:record_metric)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#error' do
|
14
|
+
it 'posts to new relic' do
|
15
|
+
expect(::NewRelic::Agent).to receive(:notice_error).with(StandardError.new, {key: 'test.error'})
|
16
|
+
subject.error('test.error', StandardError.new)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#info' do
|
21
|
+
it 'posts to new relic' do
|
22
|
+
expect(::NewRelic::Agent).to receive(:record_custom_event).with('test.info', {message: 'test'})
|
23
|
+
subject.info('test.info', 'test')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#increment' do
|
28
|
+
it 'posts to new relic' do
|
29
|
+
expect(::NewRelic::Agent).to receive(:increment_metric).with('test.increment', 1)
|
30
|
+
subject.increment('test.increment', 1)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#count' do
|
35
|
+
it 'posts to new relic' do
|
36
|
+
expect(::NewRelic::Agent).to receive(:record_metric).with('test.count', 1)
|
37
|
+
subject.count('test.count', 1)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#time' do
|
42
|
+
it 'posts to new relic' do
|
43
|
+
expect(::NewRelic::Agent).to receive(:record_custom_event).with('test.time', {duration: 1})
|
44
|
+
subject.time('test.time', 1)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'blabbermouth'
|
2
|
+
require 'rspec'
|
3
|
+
require 'coveralls'
|
4
|
+
Coveralls.wear!
|
5
|
+
|
6
|
+
Dir[File.join(File.dirname(__FILE__), '..', "spec/support/**/*.rb")].each { |f| require f }
|
7
|
+
|
8
|
+
Blabbermouth.configure do |config|
|
9
|
+
config.bystanders = []
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
#config.before(:suite) do
|
14
|
+
# ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
|
15
|
+
# capture_stdout { load "db/schema.rb" }
|
16
|
+
# load 'support/models.rb'
|
17
|
+
#end
|
18
|
+
|
19
|
+
# rspec-expectations config goes here. You can use an alternate
|
20
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
21
|
+
# assertions if you prefer.
|
22
|
+
config.expect_with :rspec do |expectations|
|
23
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
24
|
+
# and `failure_message` of custom matchers include text for helper methods
|
25
|
+
# defined using `chain`, e.g.:
|
26
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
27
|
+
# # => "be bigger than 2 and smaller than 4"
|
28
|
+
# ...rather than:
|
29
|
+
# # => "be bigger than 2"
|
30
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
31
|
+
end
|
32
|
+
|
33
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
34
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
35
|
+
config.mock_with :rspec do |mocks|
|
36
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
37
|
+
# a real object. This is generally recommended, and will default to
|
38
|
+
# `true` in RSpec 4.
|
39
|
+
mocks.verify_partial_doubles = true
|
40
|
+
end
|
41
|
+
|
42
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
43
|
+
# file, and it's useful to allow more verbose output when running an
|
44
|
+
# individual spec file.
|
45
|
+
if config.files_to_run.one?
|
46
|
+
# Use the documentation formatter for detailed output,
|
47
|
+
# unless a formatter has already been configured
|
48
|
+
# (e.g. via a command-line flag).
|
49
|
+
config.default_formatter = 'doc'
|
50
|
+
end
|
51
|
+
|
52
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
53
|
+
# For more details, see:
|
54
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
55
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
56
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
57
|
+
config.disable_monkey_patching!
|
58
|
+
|
59
|
+
# Run specs in random order to surface order dependencies. If you find an
|
60
|
+
# order dependency and want to debug it, you can fix the order by providing
|
61
|
+
# the seed, which is printed after each run.
|
62
|
+
# --seed 1234
|
63
|
+
config.order = :random
|
64
|
+
|
65
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
66
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
67
|
+
# test failures related to randomization by passing the same `--seed` value
|
68
|
+
# as the one that triggered the failure.
|
69
|
+
Kernel.srand config.seed
|
70
|
+
|
71
|
+
# Print the 10 slowest examples and example groups at the
|
72
|
+
# end of the spec run, to help surface which specs are running
|
73
|
+
# particularly slow.
|
74
|
+
#config.profile_examples = 10
|
75
|
+
|
76
|
+
# These two settings work together to allow you to limit a spec run
|
77
|
+
# to individual examples or groups you care about by tagging them with
|
78
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
79
|
+
# get run.
|
80
|
+
#config.filter_run :focus
|
81
|
+
#config.run_all_when_everything_filtered = true
|
82
|
+
end
|
83
|
+
|
84
|
+
# TODO look into why I need to patch these to work with default behavior?
|
85
|
+
class FalseClass
|
86
|
+
def false?
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
90
|
+
def true?
|
91
|
+
false
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class TrueClass
|
96
|
+
def false?
|
97
|
+
false
|
98
|
+
end
|
99
|
+
|
100
|
+
def true?
|
101
|
+
true
|
102
|
+
end
|
103
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blabbermouth-new_relic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark Rebec
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: blabbermouth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: newrelic_rpm
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Bystander for Blabbermouth that posts to New Relic
|
70
|
+
email:
|
71
|
+
- mark@markrebec.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- lib/blabbermouth-new_relic.rb
|
77
|
+
- lib/blabbermouth/new_relic/bystander.rb
|
78
|
+
- lib/blabbermouth/new_relic/version.rb
|
79
|
+
- spec/blabbermouth/new_relic/bystander_spec.rb
|
80
|
+
- spec/spec_helper.rb
|
81
|
+
homepage: http://github.com/markrebec/blabbermouth
|
82
|
+
licenses: []
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.4.8
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: New Relic bystander for Blabbermouth
|
104
|
+
test_files:
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
- spec/blabbermouth/new_relic/bystander_spec.rb
|
107
|
+
has_rdoc:
|