dashing-newrelic 1.0.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.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,3 @@
1
+ ## 1.0.0
2
+
3
+ * First stable version
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dashing-newrelic.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Pierre-Louis Gottfrois
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,86 @@
1
+ # Dashing::Newrelic
2
+
3
+ [Dashing-Rails](https://github.com/gottfrois/dashing-rails) widget that display Newrelic metrics.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your [Dashing-Rails](https://github.com/gottfrois/dashing-rails) application's Gemfile:
8
+
9
+ gem 'dashing-newrelic'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ ## Getting Started
16
+
17
+ Follow the following steps in order to make it work on your dashing-rails project:
18
+
19
+ 1. Add the following line to your `app/assets/javascripts/dashing/widgets/index.js` file:
20
+
21
+ //= require newrelic
22
+
23
+ 2. Add the following line to your `app/assets/stylesheets/dashing/widgets/index.css` file:
24
+
25
+ *= require newrelic
26
+
27
+ 3. Add the following html to your dashboard:
28
+
29
+ <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
30
+ <div data-id="new_relic_app_id_metric_name" data-view="Number" data-title="WidgetTitle"></div>
31
+ </li>
32
+
33
+ # or with https://github.com/gottfrois/dashing-hotness gem
34
+ <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
35
+ <div data-id="new_relic_app_id_metric_name" data-view="Hotness" data-title="WidgetTitle" data-cool="0" data-warm="100"></div>
36
+ </li>
37
+
38
+ 4. Run
39
+
40
+ rails g dashing:newrelic:install
41
+
42
+ 5. Edit `config/initializers/dashing-newrelic.rb` with your semaphore crendentials and project name as follow:
43
+
44
+ Dashing::Newrelic.configure do |config|
45
+ config.api_key = 'your_new_relic_api_key'
46
+ config.application_ids = ['app_id']
47
+ end
48
+
49
+ *Note: the paths to index files may have changed depending on your Dashing-Rails configuration.*
50
+
51
+ ## Fields
52
+
53
+ ### Required
54
+
55
+ * `data-id`: Like all widgets, you must include an identifier so that your jobs can update the value.
56
+
57
+ The `data-id` must include the `new_relic_app_id` + `the_metric_name` you are interrested in. For example:
58
+
59
+ data-id="2299_rpm_memory"
60
+
61
+ Here is the list of available metrics:
62
+
63
+ * `rpm_apdex`
64
+ * `rpm_error_rate`
65
+ * `rpm_throughput`
66
+ * `rpm_errors`
67
+ * `rpm_response_time`
68
+ * `rpm_db`
69
+ * `rpm_cpu`
70
+ * `rpm_memory`
71
+
72
+ ## Contributing
73
+
74
+ 1. Fork it
75
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
76
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
77
+ 4. Push to the branch (`git push origin my-new-feature`)
78
+ 5. Create new Pull Request
79
+
80
+ ## Author
81
+
82
+ Full credits for this widget should go to [Tair Assimov](https://github.com/assimovt).
83
+
84
+ ## License
85
+
86
+ dashing-semaphore is released under the MIT License. Developed by [Tair Assimov](https://github.com/rastasheep). Adapted by [gottfrois](https://github.com/gottfrois).
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,53 @@
1
+ require 'delegate'
2
+ require 'newrelic_api'
3
+
4
+ module Dashing
5
+ module Newrelic
6
+ class Scheduler < ::SimpleDelegator
7
+
8
+ attr_reader :config, :frequence
9
+
10
+ def initialize(frequence)
11
+ @config = Dashing::Newrelic.config
12
+ @frequence = frequence
13
+ ::NewRelicApi.api_key = api_key
14
+ super(config)
15
+ end
16
+
17
+ def call
18
+ schedule if valid?
19
+ end
20
+
21
+ private
22
+
23
+ def schedule
24
+ Dashing.scheduler.every frequence, first_in: 1.second.since do
25
+ app.threshold_values.each do |v|
26
+ Dashing.send_event(key(app, v), value: v.metric_value.to_i)
27
+ end
28
+ end
29
+ end
30
+
31
+ def valid?
32
+ true
33
+ end
34
+
35
+ def app
36
+ ::NewRelicApi::Account.find(:first).applications.first
37
+ end
38
+
39
+ def key(app, value)
40
+ "#{app.id}_rpm_#{value.name.downcase.gsub(/ /, '_')}"
41
+ end
42
+
43
+ def api_key
44
+ config.api_key
45
+ end
46
+
47
+ def application_ids
48
+ config.application_ids
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dashing/newrelic/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dashing-newrelic"
8
+ spec.version = Dashing::Newrelic::VERSION
9
+ spec.authors = ["Pierre-Louis Gottfrois"]
10
+ spec.email = ["pierrelouis.gottfrois@gmail.com"]
11
+ spec.description = %q{Dashing-Rails widget that display newrelic metrics}
12
+ spec.summary = %q{Dashing-Rails widget that display newrelic metrics}
13
+ spec.homepage = "https://github.com/gottfrois/dashing-newrelic"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,21 @@
1
+ require 'dashing/newrelic/version'
2
+
3
+ module Dashing
4
+ module Newrelic
5
+ class << self
6
+
7
+ attr_accessor :configuration
8
+
9
+ def config
10
+ self.configuration ||= Configuration.new
11
+ end
12
+
13
+ def configure
14
+ yield config if block_given?
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ require 'dashing/newrelic/configuration'
21
+ require 'dashing/newrelic/engine'
@@ -0,0 +1,14 @@
1
+ module Dashing
2
+ module Newrelic
3
+ class Configuration
4
+
5
+ attr_accessor :api_key, :application_ids
6
+
7
+ def initialize
8
+ @api_key = ''
9
+ @application_ids = []
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module Dashing
2
+ module Newrelic
3
+ class Engine < ::Rails::Engine
4
+
5
+ # config.assets.paths.unshift Dashing::Newrelic::Engine.root.join('vendor', 'assets', 'javascripts', 'dashing')
6
+ # config.assets.paths.unshift Dashing::Newrelic::Engine.root.join('vendor', 'assets', 'stylesheets', 'dashing')
7
+ config.paths['app/views'].unshift Dashing::Newrelic::Engine.root.join('app', 'views', 'dashing', 'newrelic')
8
+
9
+ initializer 'require dashing newlic jobs' do
10
+ Dir[Dashing::Newrelic::Engine.root.join('app', 'jobs', '**', '*.rb')].each { |file| require file }
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module Dashing
2
+ module Newrelic
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ module Dashing
2
+ module Newrelic
3
+ module Generators
4
+ class InstallGenerator < ::Rails::Generators::Base
5
+
6
+ source_root File.expand_path('../../../templates', __FILE__)
7
+
8
+ desc 'Install dashing-newrelic into your dashing application'
9
+
10
+ def copy_initializer
11
+ template 'initializer.rb', 'config/initializers/dashing-newrelic.rb'
12
+ end
13
+
14
+ def copy_job
15
+ template 'jobs/newrelic.rb', 'app/jobs/newrelic.rb'
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ # Use this hook to configure Dashing-Newrelic bahaviors.
2
+ Dashing::Newrelic.configure do |config|
3
+ # Your newrelic api key.
4
+ # config.api_key = 'your_newrelic_api_key'
5
+
6
+ # A list of application ids.
7
+ # config.application_ids = ['app_id']
8
+ end
@@ -0,0 +1,2 @@
1
+ # You can set the frequency here.
2
+ Dashing::Newrelic::Scheduler.new('1m').call
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,12 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_tree .
12
+ */
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dashing-newrelic
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Pierre-Louis Gottfrois
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-11-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Dashing-Rails widget that display newrelic metrics
47
+ email:
48
+ - pierrelouis.gottfrois@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - CHANGELOG.md
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - app/jobs/dashing/newrelic/scheduler.rb
60
+ - app/views/dashing/newrelic/newrelic.html
61
+ - dashing-newrelic.gemspec
62
+ - lib/dashing/newrelic.rb
63
+ - lib/dashing/newrelic/configuration.rb
64
+ - lib/dashing/newrelic/engine.rb
65
+ - lib/dashing/newrelic/version.rb
66
+ - lib/generators/dashing/newrelic/install_generator.rb
67
+ - lib/generators/templates/initializer.rb
68
+ - lib/generators/templates/jobs/newrelic.rb
69
+ - vendor/assets/javascripts/dashing/newrelic/index.js
70
+ - vendor/assets/stylesheets/dashing/newrelic/index.css
71
+ homepage: https://github.com/gottfrois/dashing-newrelic
72
+ licenses:
73
+ - MIT
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ segments:
85
+ - 0
86
+ hash: 3134115210743623363
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ segments:
94
+ - 0
95
+ hash: 3134115210743623363
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 1.8.25
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Dashing-Rails widget that display newrelic metrics
102
+ test_files: []