regrapher-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 63958aba1bfbdfe0634f655ba8ac7cba003eb9ab
4
+ data.tar.gz: 1ecb126ed1237c35678019a8659145575a790c87
5
+ SHA512:
6
+ metadata.gz: 3033f2eae4a61f0dd9af70d500ca4dc9576ca72b73226fceb19de3eb2a03f966ba9e9e6e181cec2f66234747a3776961b4f5dbeec10107304038e7aaa40f6f52
7
+ data.tar.gz: fe8e1da98f436860480c81501cdd783d3ed6a57b00abbf5a10f522e84961657aae53f65d632e8ffa9c16c878554eaaa825865ea30bf35453fb87649634d1cff2
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ Regrapher Rails
2
+ ======================
3
+
4
+ Provides convenience logger to print events and metric values in the Regrapher format.
5
+
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
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generates callback hooks for metrics logging in config/initializers/regrapher.rb.
3
+
4
+ Example:
5
+ rails generate regrapher
6
+
7
+ This will create:
8
+ config/initializers/regrapher.rb
@@ -0,0 +1,7 @@
1
+ class RegrapherGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+
4
+ def copy_initializer_file
5
+ copy_file 'regrapher_initializer.rb', 'config/initializers/regrapher.rb'
6
+ end
7
+ end
@@ -0,0 +1,43 @@
1
+ #
2
+ # emit metrics on active record events
3
+ #
4
+ ActiveSupport.on_load(:active_record) do
5
+ before_create do |r|
6
+ Regrapher.client.increment("record.created.#{r.class.table_name}")
7
+ true
8
+ end
9
+ before_destroy do |r|
10
+ Regrapher.client.increment("record.destroyed.#{r.class.table_name}")
11
+ true
12
+ end
13
+ before_update do |r|
14
+ Regrapher.client.increment("record.updated.#{r.class.table_name}")
15
+ true
16
+ end
17
+ end
18
+
19
+ #
20
+ # emit metrics on authentication events
21
+ #
22
+ if defined?(Warden)
23
+ Warden::Manager.after_authentication do |r|
24
+ Regrapher.client.increment("auth.sign_in.#{r.class.table_name}")
25
+ end
26
+ Warden::Manager.before_logout do |r|
27
+ Regrapher.client.increment("auth.sign_out.#{r.class.table_name}")
28
+ end
29
+ end
30
+
31
+ #
32
+ # emit metrics on action processing events
33
+ #
34
+ ActiveSupport::Notifications.subscribe 'process_action.action_controller' do |name, started, finished, unique_id, data|
35
+ next unless data[:status] || data[:exception]
36
+
37
+ Regrapher.client.gauge("#{name}.runtime.view", data[:view_runtime].to_f)
38
+ Regrapher.client.gauge("#{name}.runtime.db", data[:db_runtime].to_f)
39
+ Regrapher.client.gauge("#{name}.runtime.total", (finished - started) * 1000.0)
40
+
41
+ status = data[:status] || Rack::Utils.status_code(ActionDispatch::ExceptionWrapper.rescue_responses[data[:exception][0]])
42
+ Regrapher.client.increment("#{name}.status.#{status}")
43
+ end
@@ -0,0 +1 @@
1
+ require 'regrapher'
@@ -0,0 +1,5 @@
1
+ module Regrapher
2
+ module Rails
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
data/spec/examples.txt ADDED
File without changes
@@ -0,0 +1,78 @@
1
+ require 'regrapher-rails'
2
+
3
+ RSpec.configure do |config|
4
+ # rspec-expectations config goes here. You can use an alternate
5
+ # assertion/expectation library such as wrong or the stdlib/minitest
6
+ # assertions if you prefer.
7
+ config.expect_with :rspec do |expectations|
8
+ # This option will default to `true` in RSpec 4. It makes the `description`
9
+ # and `failure_message` of custom matchers include text for helper methods
10
+ # defined using `chain`, e.g.:
11
+ # be_bigger_than(2).and_smaller_than(4).description
12
+ # # => "be bigger than 2 and smaller than 4"
13
+ # ...rather than:
14
+ # # => "be bigger than 2"
15
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
16
+ end
17
+
18
+ # rspec-mocks config goes here. You can use an alternate test double
19
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
20
+ config.mock_with :rspec do |mocks|
21
+ # Prevents you from mocking or stubbing a method that does not exist on
22
+ # a real object. This is generally recommended, and will default to
23
+ # `true` in RSpec 4.
24
+ mocks.verify_partial_doubles = true
25
+ end
26
+
27
+ # The settings below are suggested to provide a good initial experience
28
+ # with RSpec, but feel free to customize to your heart's content.
29
+ # These two settings work together to allow you to limit a spec run
30
+ # to individual examples or groups you care about by tagging them with
31
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
32
+ # get run.
33
+ config.filter_run :focus
34
+ config.run_all_when_everything_filtered = true
35
+
36
+ # Allows RSpec to persist some state between runs in order to support
37
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
38
+ # you configure your source control system to ignore this file.
39
+ config.example_status_persistence_file_path = 'spec/examples.txt'
40
+
41
+ # Limits the available syntax to the non-monkey patched syntax that is
42
+ # recommended. For more details, see:
43
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
44
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
45
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
46
+ config.disable_monkey_patching!
47
+
48
+ # This setting enables warnings. It's recommended, but in some cases may
49
+ # be too noisy due to issues in dependencies.
50
+ config.warnings = true
51
+
52
+ # Many RSpec users commonly either run the entire suite or an individual
53
+ # file, and it's useful to allow more verbose output when running an
54
+ # individual spec file.
55
+ if config.files_to_run.one?
56
+ # Use the documentation formatter for detailed output,
57
+ # unless a formatter has already been configured
58
+ # (e.g. via a command-line flag).
59
+ config.default_formatter = 'doc'
60
+ end
61
+
62
+ # Print the 10 slowest examples and example groups at the
63
+ # end of the spec run, to help surface which specs are running
64
+ # particularly slow.
65
+ config.profile_examples = 10
66
+
67
+ # Run specs in random order to surface order dependencies. If you find an
68
+ # order dependency and want to debug it, you can fix the order by providing
69
+ # the seed, which is printed after each run.
70
+ # --seed 1234
71
+ config.order = :random
72
+
73
+ # Seed global randomization in this process using the `--seed` CLI option.
74
+ # Setting this allows you to use `--seed` to deterministically reproduce
75
+ # test failures related to randomization by passing the same `--seed` value
76
+ # as the one that triggered the failure.
77
+ Kernel.srand config.seed
78
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: regrapher-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ramsay
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: regrapher
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '3.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '3.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '11.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '11.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ description: Provides convenience logger to format events and metric values in the
70
+ regrapher format
71
+ email:
72
+ - ramzi.salah@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - README.md
78
+ - Rakefile
79
+ - lib/generators/regrapher/USAGE
80
+ - lib/generators/regrapher/regrapher_generator.rb
81
+ - lib/generators/regrapher/templates/regrapher_initializer.rb
82
+ - lib/regrapher-rails.rb
83
+ - lib/regrapher/rails/version.rb
84
+ - spec/examples.txt
85
+ - spec/spec_helper.rb
86
+ homepage: http://github.com/regrapher/regrapher-rails
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options:
92
+ - "--charset=UTF-8"
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 1.9.3
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.6.11
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Regrapher logger for Rails applications
111
+ test_files:
112
+ - spec/examples.txt
113
+ - spec/spec_helper.rb