message-driver-newrelic 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 17b8aa672e3c7d14c1a3b418e6a0fc6ed3a15719
4
+ data.tar.gz: 23bc3ef586e6e8c391e21a5b15c4fbdbbc1a58e7
5
+ SHA512:
6
+ metadata.gz: 92999a997f8c17f0fa10875bd4b1eaae628d4975c974c76392d4c31d538299d4b62fe2245027eff2c47692d1eb016c18c7dac31972b3b61a29d3f718df116081
7
+ data.tar.gz: 48e7025ffb39495f31eba296654ad85538d4608311b338f1dbafe064525b07715047dc5f1a6c0e81558845cd1da8cb67f03e7d747e7f102c71c369802912bb7a
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /gemfiles/*.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,19 @@
1
+ dist: trusty
2
+ sudo: false
3
+ language: ruby
4
+ rvm:
5
+ - 2.3
6
+ - 2.2
7
+ - 2.0
8
+ - 1.9.3
9
+ gemfile:
10
+ - Gemfile
11
+ - gemfiles/message_driver_master.gemfile
12
+ - gemfiles/message_driver_development.gemfile
13
+ matrix:
14
+ fast_finish: true
15
+ allow_failures:
16
+ - gemfile: gemfiles/message_driver_development.gemfile
17
+ before_install: gem install bundler
18
+ bundler_args: --without tools
19
+ script: bundle exec rake
data/Appraisals ADDED
@@ -0,0 +1,7 @@
1
+ appraise 'message_driver master' do
2
+ gem 'message-driver', git: 'https://github.com/message-driver/message-driver.git', branch: 'master'
3
+ end
4
+
5
+ appraise 'message_driver development' do
6
+ gem 'message-driver', git: 'https://github.com/message-driver/message-driver.git', branch: 'development'
7
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 - 2016-12-19
4
+
5
+ Initial Release
6
+
7
+ * Support the following operations being reported to NewRelic
8
+ * publish
9
+ * pop_message
10
+ * ack_message
11
+ * nack_message
12
+ * begin_transaction
13
+ * commit_transaction
14
+ * rollback_transaction
15
+ * subscribe
16
+ * message_count
17
+ * consumer_count
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in message-driver-newrelic.gemspec
4
+ gemspec
5
+
6
+ group "tools" do
7
+ gem "appraisal"
8
+ gem "pry"
9
+ gem "pry-byebug"
10
+ gem "guard-rspec"
11
+ if RUBY_PLATFORM =~ /darwin/
12
+ gem "ruby_gntp"
13
+ end
14
+ end
data/Guardfile ADDED
@@ -0,0 +1,12 @@
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ require "guard/rspec/dsl"
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ rspec = dsl.rspec
6
+ watch(rspec.spec_helper) { rspec.spec_dir }
7
+ watch(rspec.spec_support) { rspec.spec_dir }
8
+ watch(rspec.spec_files)
9
+
10
+ ruby = dsl.ruby
11
+ dsl.watch_spec_files_for(ruby.lib_files)
12
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013-2016 Matt Campbell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # MessageDriver::Newrelic
2
+
3
+ [NewRelic APM](https://newrelic.com/) integration for [MessageDriver](https://github.com/message-driver/message-driver)
4
+
5
+ [![Build Status](https://travis-ci.org/message-driver/message-driver-newrelic.svg?branch=master)](https://travis-ci.org/message-driver/message-driver-newrelic)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'message-driver-newrelic'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install message-driver-newrelic
22
+
23
+ ## Usage
24
+
25
+ That's all! This gem hooks into newrelic_rpm's dependency detection and is setup and configured from there.
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/message-driver/message-driver-newrelic.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "message/driver/newrelic"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "pry"
10
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,15 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "message-driver", :git => "https://github.com/message-driver/message-driver.git", :branch => "development"
6
+
7
+ group "tools" do
8
+ gem "appraisal"
9
+ gem "pry"
10
+ gem "pry-byebug"
11
+ gem "guard-rspec"
12
+ gem "ruby_gntp"
13
+ end
14
+
15
+ gemspec :path => "../"
@@ -0,0 +1,15 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "message-driver", :git => "https://github.com/message-driver/message-driver.git", :branch => "master"
6
+
7
+ group "tools" do
8
+ gem "appraisal"
9
+ gem "pry"
10
+ gem "pry-byebug"
11
+ gem "guard-rspec"
12
+ gem "ruby_gntp"
13
+ end
14
+
15
+ gemspec :path => "../"
@@ -0,0 +1 @@
1
+ require 'message_driver/new_relic'
@@ -0,0 +1,8 @@
1
+ require 'message_driver/new_relic/version'
2
+ require 'message_driver/new_relic/instrumentation'
3
+
4
+ module MessageDriver
5
+ module NewRelic
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,95 @@
1
+ require 'newrelic_rpm'
2
+ require 'new_relic/agent/datastores'
3
+
4
+ module MessageDriver
5
+ module NewRelic
6
+ module Instrumentation
7
+ DESTINATION_OPS = %w(publish pop_message message_count consumer_count).map!(&:freeze).freeze
8
+ DESTINATION_BLOCK_OPS = %w(subscribe).map!(&:freeze).freeze
9
+ MESSAGE_OPS = %w(ack_message nack_message).map!(&:freeze).freeze
10
+ BROKER_OPS = %w(begin_transaction commit_transaction rollback_transaction).map!(&:freeze).freeze
11
+ OPTS_TO_OVERRIDE = (DESTINATION_OPS + DESTINATION_BLOCK_OPS + MESSAGE_OPS + BROKER_OPS).freeze
12
+
13
+ DESTINATION_OPS.each do |op|
14
+ define_method "#{op}_with_newrelic" do |*args|
15
+ destination_name = args[0].nil? ? nil : args[0].name
16
+ callback = proc do |result, metric, elapsed|
17
+ ::NewRelic::Agent::Datastores.notice_statement([op, destination_name].inspect, elapsed)
18
+ end
19
+
20
+ ::NewRelic::Agent::Datastores.wrap('MessageDriver', op, destination_name, callback) do
21
+ send(:"#{op}_without_newrelic", *args)
22
+ end
23
+ end
24
+ end
25
+
26
+ DESTINATION_BLOCK_OPS.each do |op|
27
+ define_method "#{op}_with_newrelic" do |*args, &block|
28
+ destination_name = args[0].nil? ? nil : args[0].name
29
+ callback = proc do |result, metric, elapsed|
30
+ ::NewRelic::Agent::Datastores.notice_statement([op, destination_name].inspect, elapsed)
31
+ end
32
+
33
+ ::NewRelic::Agent::Datastores.wrap('MessageDriver', op, destination_name, callback) do
34
+ send(:"#{op}_without_newrelic", *args, &block)
35
+ end
36
+ end
37
+ end
38
+
39
+ MESSAGE_OPS.each do |op|
40
+ define_method "#{op}_with_newrelic" do |*args, &block|
41
+ destination_name = args[0].nil? ? nil : args[0].destination.name
42
+ callback = proc do |result, metric, elapsed|
43
+ ::NewRelic::Agent::Datastores.notice_statement([op, destination_name].inspect, elapsed)
44
+ end
45
+
46
+ ::NewRelic::Agent::Datastores.wrap('MessageDriver', op, destination_name, callback) do
47
+ send(:"#{op}_without_newrelic", *args)
48
+ end
49
+ end
50
+ end
51
+
52
+ BROKER_OPS.each do |op|
53
+ define_method "#{op}_with_newrelic" do |*args, &block|
54
+ broker_name = adapter.broker.name
55
+ callback = proc do |result, metric, elapsed|
56
+ ::NewRelic::Agent::Datastores.notice_statement([op].inspect, elapsed)
57
+ end
58
+
59
+ ::NewRelic::Agent::Datastores.wrap('MessageDriver', op, broker_name, callback) do
60
+ send(:"#{op}_without_newrelic", *args, &block)
61
+ end
62
+ end
63
+ end
64
+
65
+ def self.included(other)
66
+ other.class_eval do
67
+ OPTS_TO_OVERRIDE.each do |op|
68
+ alias :"#{op}_without_newrelic" :"#{op}"
69
+ alias :"#{op}" :"#{op}_with_newrelic"
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ DependencyDetection.defer do
78
+ named :message_driver
79
+
80
+ depends_on do
81
+ defined?(MessageDriver) &&
82
+ defined?(MessageDriver::Adapters::ContextBase) &&
83
+ ENV['NEWRELIC_ENABLE'].to_s !~ /false|off|no/i
84
+ end
85
+
86
+ executes do
87
+ ::NewRelic::Agent.logger.info 'Installing Message Driver instrumentation'
88
+ end
89
+
90
+ executes do
91
+ ::MessageDriver::Adapters::ContextBase.class_eval do
92
+ include MessageDriver::NewRelic::Instrumentation
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,5 @@
1
+ module MessageDriver
2
+ module NewRelic
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'message_driver/new_relic/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "message-driver-newrelic"
8
+ spec.version = MessageDriver::NewRelic::VERSION
9
+ spec.authors = ["Matt Campbell"]
10
+ spec.email = ["matt@soupmatt.com"]
11
+
12
+ spec.summary = %q{Add NewRelic instrumentation to MessageDriver}
13
+ spec.homepage = "https://github.com/message-driver/message-driver-newrelic"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ # spec.bindir = "exe"
19
+ # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "newrelic_rpm", "~> 3.15"
23
+ spec.add_dependency "message-driver", "~> 0.7"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.13"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.5"
28
+ spec.add_development_dependency "minitest" # needed by test helpers from the newrelic_rpm gem
29
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: message-driver-newrelic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matt Campbell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: newrelic_rpm
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.15'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: message-driver
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.13'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - matt@soupmatt.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Appraisals
108
+ - CHANGELOG.md
109
+ - Gemfile
110
+ - Guardfile
111
+ - LICENSE
112
+ - README.md
113
+ - Rakefile
114
+ - bin/console
115
+ - bin/setup
116
+ - gemfiles/message_driver_development.gemfile
117
+ - gemfiles/message_driver_master.gemfile
118
+ - lib/message-driver-newrelic.rb
119
+ - lib/message_driver/new_relic.rb
120
+ - lib/message_driver/new_relic/instrumentation.rb
121
+ - lib/message_driver/new_relic/version.rb
122
+ - message-driver-newrelic.gemspec
123
+ homepage: https://github.com/message-driver/message-driver-newrelic
124
+ licenses: []
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.5.2
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Add NewRelic instrumentation to MessageDriver
146
+ test_files: []