nunes 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -7
- data/Changelog.md +8 -0
- data/Gemfile +1 -1
- data/README.md +2 -3
- data/Rakefile +10 -0
- data/lib/nunes.rb +12 -0
- data/lib/nunes/adapter.rb +4 -2
- data/lib/nunes/instrumentable.rb +1 -1
- data/lib/nunes/subscriber.rb +5 -2
- data/lib/nunes/subscribers/action_controller.rb +51 -24
- data/lib/nunes/subscribers/action_mailer.rb +2 -2
- data/lib/nunes/subscribers/action_view.rb +5 -2
- data/lib/nunes/subscribers/active_job.rb +2 -3
- data/lib/nunes/subscribers/active_record.rb +4 -1
- data/lib/nunes/version.rb +1 -1
- data/script/test +10 -13
- data/test/controller_instrumentation_test.rb +47 -5
- data/test/helper.rb +5 -1
- data/test/instrumentable_test.rb +27 -3
- data/test/job_instrumentation_test.rb +11 -8
- data/test/mailer_instrumentation_test.rb +5 -1
- data/test/namespaced_controller_instrumentation_test.rb +7 -7
- data/test/namespaced_job_instrumentation_test.rb +33 -0
- data/test/namespaced_mailer_instrumentation_test.rb +35 -0
- data/test/namespaced_model_instrumentation_test.rb +55 -0
- data/test/nunes_test.rb +8 -0
- data/test/{rails_app → rails_app_4.2.5}/.gitignore +0 -0
- data/test/{rails_app → rails_app_4.2.5}/Rakefile +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/assets/images/rails.png +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/assets/javascripts/application.js +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/assets/stylesheets/application.css +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/controllers/admin/posts_controller.rb +2 -7
- data/test/{rails_app → rails_app_4.2.5}/app/controllers/application_controller.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/controllers/posts_controller.rb +1 -7
- data/test/{rails_app → rails_app_4.2.5}/app/helpers/application_helper.rb +0 -0
- data/test/rails_app_4.2.5/app/jobs/spam/detector_job.rb +11 -0
- data/test/{rails_app → rails_app_4.2.5}/app/jobs/spam_detector_job.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/mailers/.gitkeep +0 -0
- data/test/rails_app_4.2.5/app/mailers/admin/post_mailer.rb +13 -0
- data/test/{rails_app → rails_app_4.2.5}/app/mailers/post_mailer.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/models/.gitkeep +0 -0
- data/test/rails_app_4.2.5/app/models/admin/post.rb +5 -0
- data/test/{rails_app → rails_app_4.2.5}/app/models/post.rb +0 -0
- data/test/{rails_app/app/views → rails_app_4.2.5/app/views/admin}/post_mailer/created.text.erb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/views/admin/posts/index.html.erb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/views/layouts/application.html.erb +0 -0
- data/test/rails_app_4.2.5/app/views/post_mailer/created.text.erb +1 -0
- data/test/{rails_app → rails_app_4.2.5}/app/views/posts/_post.html.erb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/app/views/posts/index.html.erb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config.ru +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/application.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/boot.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/database.yml +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/environment.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/environments/development.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/environments/production.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/environments/test.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/initializers/backtrace_silencers.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/initializers/force_test_schema_load.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/initializers/inflections.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/initializers/mime_types.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/initializers/secret_token.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/initializers/session_store.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/initializers/wrap_parameters.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/locales/en.yml +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/routes.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/config/secrets.yml +0 -0
- data/test/{rails_app → rails_app_4.2.5}/db/migrate/20130417154459_create_posts.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/db/schema.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/db/seeds.rb +0 -0
- data/test/{rails_app → rails_app_4.2.5}/lib/assets/.gitkeep +0 -0
- data/test/{rails_app → rails_app_4.2.5}/lib/tasks/.gitkeep +0 -0
- data/test/{rails_app → rails_app_4.2.5}/public/404.html +0 -0
- data/test/{rails_app → rails_app_4.2.5}/public/422.html +0 -0
- data/test/{rails_app → rails_app_4.2.5}/public/500.html +0 -0
- data/test/{rails_app → rails_app_4.2.5}/public/favicon.ico +0 -0
- data/test/{rails_app → rails_app_4.2.5}/public/index.html +0 -0
- data/test/{rails_app → rails_app_4.2.5}/public/robots.txt +0 -0
- data/test/{rails_app → rails_app_4.2.5}/script/rails +0 -0
- data/test/rails_app_5.0.0/.gitignore +21 -0
- data/test/rails_app_5.0.0/Gemfile +48 -0
- data/test/rails_app_5.0.0/README.md +24 -0
- data/test/rails_app_5.0.0/Rakefile +6 -0
- data/test/rails_app_5.0.0/app/assets/config/manifest.js +3 -0
- data/test/rails_app_5.0.0/app/assets/images/.keep +0 -0
- data/test/rails_app_5.0.0/app/assets/images/rails.png +0 -0
- data/test/rails_app_5.0.0/app/assets/javascripts/application.js +13 -0
- data/test/rails_app_5.0.0/app/assets/javascripts/cable.js +13 -0
- data/test/rails_app_5.0.0/app/assets/javascripts/channels/.keep +0 -0
- data/test/rails_app_5.0.0/app/assets/stylesheets/application.css +15 -0
- data/test/rails_app_5.0.0/app/channels/application_cable/channel.rb +4 -0
- data/test/rails_app_5.0.0/app/channels/application_cable/connection.rb +4 -0
- data/test/rails_app_5.0.0/app/controllers/admin/posts_controller.rb +14 -0
- data/test/rails_app_5.0.0/app/controllers/application_controller.rb +3 -0
- data/test/rails_app_5.0.0/app/controllers/concerns/.keep +0 -0
- data/test/rails_app_5.0.0/app/controllers/posts_controller.rb +22 -0
- data/test/rails_app_5.0.0/app/helpers/application_helper.rb +2 -0
- data/test/rails_app_5.0.0/app/jobs/application_job.rb +2 -0
- data/test/rails_app_5.0.0/app/jobs/spam/detector_job.rb +11 -0
- data/test/rails_app_5.0.0/app/jobs/spam_detector_job.rb +9 -0
- data/test/rails_app_5.0.0/app/mailers/admin/post_mailer.rb +13 -0
- data/test/rails_app_5.0.0/app/mailers/application_mailer.rb +4 -0
- data/test/rails_app_5.0.0/app/mailers/post_mailer.rb +11 -0
- data/test/rails_app_5.0.0/app/models/admin/post.rb +5 -0
- data/test/rails_app_5.0.0/app/models/application_record.rb +3 -0
- data/test/rails_app_5.0.0/app/models/concerns/.keep +0 -0
- data/test/rails_app_5.0.0/app/models/post.rb +2 -0
- data/test/rails_app_5.0.0/app/views/admin/post_mailer/created.text.erb +1 -0
- data/test/rails_app_5.0.0/app/views/admin/posts/index.html.erb +5 -0
- data/test/rails_app_5.0.0/app/views/layouts/application.html.erb +14 -0
- data/test/rails_app_5.0.0/app/views/layouts/mailer.html.erb +13 -0
- data/test/rails_app_5.0.0/app/views/layouts/mailer.text.erb +1 -0
- data/test/rails_app_5.0.0/app/views/post_mailer/created.text.erb +1 -0
- data/test/rails_app_5.0.0/app/views/posts/_post.html.erb +1 -0
- data/test/rails_app_5.0.0/app/views/posts/index.html.erb +5 -0
- data/test/rails_app_5.0.0/bin/bundle +3 -0
- data/test/rails_app_5.0.0/bin/rails +9 -0
- data/test/rails_app_5.0.0/bin/rake +9 -0
- data/test/rails_app_5.0.0/bin/setup +34 -0
- data/test/rails_app_5.0.0/bin/spring +15 -0
- data/test/rails_app_5.0.0/bin/update +29 -0
- data/test/rails_app_5.0.0/config.ru +5 -0
- data/test/rails_app_5.0.0/config/application.rb +15 -0
- data/test/rails_app_5.0.0/config/boot.rb +3 -0
- data/test/rails_app_5.0.0/config/cable.yml +9 -0
- data/test/rails_app_5.0.0/config/database.yml +25 -0
- data/test/rails_app_5.0.0/config/environment.rb +5 -0
- data/test/rails_app_5.0.0/config/environments/development.rb +54 -0
- data/test/rails_app_5.0.0/config/environments/production.rb +86 -0
- data/test/rails_app_5.0.0/config/environments/test.rb +42 -0
- data/test/rails_app_5.0.0/config/initializers/application_controller_renderer.rb +6 -0
- data/test/rails_app_5.0.0/config/initializers/assets.rb +11 -0
- data/test/rails_app_5.0.0/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app_5.0.0/config/initializers/cookies_serializer.rb +5 -0
- data/test/rails_app_5.0.0/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/rails_app_5.0.0/config/initializers/force_test_schema_load.rb +3 -0
- data/test/rails_app_5.0.0/config/initializers/inflections.rb +16 -0
- data/test/rails_app_5.0.0/config/initializers/mime_types.rb +4 -0
- data/test/rails_app_5.0.0/config/initializers/new_framework_defaults.rb +24 -0
- data/test/rails_app_5.0.0/config/initializers/session_store.rb +3 -0
- data/test/rails_app_5.0.0/config/initializers/wrap_parameters.rb +14 -0
- data/test/rails_app_5.0.0/config/locales/en.yml +23 -0
- data/test/rails_app_5.0.0/config/puma.rb +47 -0
- data/test/rails_app_5.0.0/config/routes.rb +12 -0
- data/test/rails_app_5.0.0/config/secrets.yml +22 -0
- data/test/rails_app_5.0.0/config/spring.rb +6 -0
- data/test/rails_app_5.0.0/db/migrate/20160812134213_create_posts.rb +9 -0
- data/test/rails_app_5.0.0/db/schema.rb +21 -0
- data/test/rails_app_5.0.0/db/seeds.rb +7 -0
- data/test/rails_app_5.0.0/lib/assets/.keep +0 -0
- data/test/rails_app_5.0.0/lib/tasks/.keep +0 -0
- data/test/rails_app_5.0.0/log/.keep +0 -0
- data/test/rails_app_5.0.0/public/404.html +67 -0
- data/test/rails_app_5.0.0/public/422.html +67 -0
- data/test/rails_app_5.0.0/public/500.html +66 -0
- data/test/rails_app_5.0.0/public/apple-touch-icon-precomposed.png +0 -0
- data/test/rails_app_5.0.0/public/apple-touch-icon.png +0 -0
- data/test/rails_app_5.0.0/public/favicon.ico +0 -0
- data/test/rails_app_5.0.0/public/robots.txt +5 -0
- data/test/rails_app_5.0.0/test/controllers/.keep +0 -0
- data/test/rails_app_5.0.0/test/fixtures/.keep +0 -0
- data/test/rails_app_5.0.0/test/fixtures/files/.keep +0 -0
- data/test/rails_app_5.0.0/test/helpers/.keep +0 -0
- data/test/rails_app_5.0.0/test/integration/.keep +0 -0
- data/test/rails_app_5.0.0/test/mailers/.keep +0 -0
- data/test/rails_app_5.0.0/test/models/.keep +0 -0
- data/test/rails_app_5.0.0/test/test_helper.rb +10 -0
- data/test/rails_app_5.0.0/vendor/assets/javascripts/.keep +0 -0
- data/test/rails_app_5.0.0/vendor/assets/stylesheets/.keep +0 -0
- data/test/support/adapter_test_helpers.rb +17 -2
- metadata +295 -100
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 519721bdfa50f41504919cb7a153d5be9bf0ccd2
|
4
|
+
data.tar.gz: 6b912ad6b4fbafdc54fe19e5bc0de7c986f3ab77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76cc5998cd987b32faa08bfc2607c56c3e913294ebd26a57a853ce2a31699e3b98901920b95f96b130cf6d148c3b8f879bb0f5b375cb00a659e503113d7cf59a
|
7
|
+
data.tar.gz: 48c54dd8a5bdf5a8c1d26e3f9cdb6533bd07e6fb5b0cda62bef195c8d96c5f2a8284aa77ef730e03f1234db78db6932f803837db4d46b41d4e9012640285f8c6
|
data/.travis.yml
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
-
|
4
|
-
- 2.1.
|
5
|
-
- 2.2.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
- 2.0.0
|
4
|
+
- 2.1.10
|
5
|
+
- 2.2.5
|
6
|
+
bundler_args: --without guard watch bench
|
7
|
+
script: bundle exec rake
|
8
|
+
env:
|
9
|
+
- RAILS_VERSION=4.2.5
|
10
|
+
- RAILS_VERSION=5.0.0
|
11
|
+
matrix:
|
12
|
+
# don't run rails 5 on ruby versions that can't install rack 2
|
13
|
+
exclude:
|
14
|
+
- rvm: 2.0.0
|
15
|
+
env: RAILS_VERSION=5.0.0
|
16
|
+
- rvm: 2.1.10
|
17
|
+
env: RAILS_VERSION=5.0.0
|
data/Changelog.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# 0.5.0
|
2
|
+
|
3
|
+
* no longer doing underscore on active job class name when instrumenting it (ie: active_job.spam_detector_job.perform changed to active_job.SpamDetectorJob.perform)
|
4
|
+
* drop ruby 1.9 support
|
5
|
+
* ruby namespaces are now converted to dash instead of dot in metric namespace (https://github.com/jnunemaker/nunes/pull/27)
|
6
|
+
* allow disabling view/db runtime, format and exception instrumentation
|
7
|
+
* official support for rails 5
|
8
|
+
|
1
9
|
# 0.4.0
|
2
10
|
|
3
11
|
## Backwards Compatibility Break
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -18,8 +18,8 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Compatibility
|
20
20
|
|
21
|
-
* >= Ruby
|
22
|
-
* Rails 4.2.x
|
21
|
+
* >= Ruby 2.0
|
22
|
+
* Rails 4.2.x, 5.0.x
|
23
23
|
|
24
24
|
Note: you can use v0.3.1 is for rails 3.2.x support.
|
25
25
|
|
@@ -74,7 +74,6 @@ Based on those events, you'll get metrics like this in instrumental and statsd:
|
|
74
74
|
* `action_controller.format.html`
|
75
75
|
* `action_controller.controller.Admin.PostsController.new.status.403`
|
76
76
|
* `action_controller.controller.Admin.PostsController.index.format.json`
|
77
|
-
* `action_controller.exception.RuntimeError` - where RuntimeError is the class of any exceptions that occur while processing a controller's action.
|
78
77
|
* `active_support.cache.hit`
|
79
78
|
* `active_support.cache.miss`
|
80
79
|
|
data/Rakefile
ADDED
data/lib/nunes.rb
CHANGED
@@ -37,4 +37,16 @@ module Nunes
|
|
37
37
|
|
38
38
|
subscribers
|
39
39
|
end
|
40
|
+
|
41
|
+
# Private: What ruby uses to separate namespaces.
|
42
|
+
NAMESPACE_SEPARATOR = "::".freeze
|
43
|
+
|
44
|
+
# Private: What nunes uses to separate namespaces in the metric.
|
45
|
+
METRIC_NAMESPACE_SEPARATOR = "-".freeze
|
46
|
+
|
47
|
+
# Private: Converts a class to a metric safe name.
|
48
|
+
def self.class_to_metric(class_or_class_name)
|
49
|
+
return if class_or_class_name.nil?
|
50
|
+
class_or_class_name.to_s.gsub(NAMESPACE_SEPARATOR, METRIC_NAMESPACE_SEPARATOR)
|
51
|
+
end
|
40
52
|
end
|
data/lib/nunes/adapter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_support/core_ext/class/subclasses'
|
2
|
+
|
1
3
|
module Nunes
|
2
4
|
class Adapter
|
3
5
|
# Private: Wraps a given object with the correct adapter/decorator.
|
@@ -55,10 +57,10 @@ module Nunes
|
|
55
57
|
ReplaceRegex = /[^a-z0-9\-_]+/i
|
56
58
|
|
57
59
|
# Private: The default metric namespace separator.
|
58
|
-
Separator = "."
|
60
|
+
Separator = ".".freeze
|
59
61
|
|
60
62
|
# Private
|
61
|
-
Nothing = ""
|
63
|
+
Nothing = "".freeze
|
62
64
|
|
63
65
|
# Private: Prepare a metric name before it is sent to the adapter's client.
|
64
66
|
def prepare(metric, replacement = Separator)
|
data/lib/nunes/instrumentable.rb
CHANGED
data/lib/nunes/subscriber.rb
CHANGED
@@ -3,7 +3,10 @@ require "active_support/notifications"
|
|
3
3
|
module Nunes
|
4
4
|
class Subscriber
|
5
5
|
# Private: The bang character that is the first char of some events.
|
6
|
-
BANG =
|
6
|
+
BANG = "!".freeze
|
7
|
+
|
8
|
+
# Private: The dot charactor used to determine the method name.
|
9
|
+
DOT = ".".freeze
|
7
10
|
|
8
11
|
# Public: Setup a subscription for the subscriber using the
|
9
12
|
# provided adapter.
|
@@ -34,7 +37,7 @@ module Nunes
|
|
34
37
|
# when in production
|
35
38
|
return if name.start_with?(BANG)
|
36
39
|
|
37
|
-
method_name = name.split(
|
40
|
+
method_name = name.split(DOT).first
|
38
41
|
|
39
42
|
if respond_to?(method_name)
|
40
43
|
send(method_name, start, ending, transaction_id, payload)
|
@@ -11,46 +11,73 @@ module Nunes
|
|
11
11
|
Pattern
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
class << self
|
15
|
+
attr_accessor :instrument_format
|
16
|
+
attr_accessor :instrument_view_runtime
|
17
|
+
attr_accessor :instrument_db_runtime
|
18
|
+
end
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
# Public: Should we instrument the number of requests per format overall and per controller/action.
|
21
|
+
self.instrument_format = true
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
# Public: Should we instrument the view runtime overall and per controller/action.
|
24
|
+
self.instrument_view_runtime = true
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
# Public: Should we instrument the db runtime overall and per controller/action.
|
27
|
+
self.instrument_db_runtime = true
|
28
28
|
|
29
|
+
def process_action(start, ending, transaction_id, payload)
|
29
30
|
runtime = ((ending - start) * 1_000).round
|
30
|
-
|
31
31
|
timing "action_controller.runtime.total", runtime
|
32
|
-
timing "action_controller.runtime.view", view_runtime if view_runtime
|
33
|
-
timing "action_controller.runtime.db", db_runtime if db_runtime
|
34
32
|
|
35
|
-
|
33
|
+
status = payload[:status]
|
36
34
|
increment "action_controller.status.#{status}" if status
|
37
35
|
|
36
|
+
controller = ::Nunes.class_to_metric(payload[:controller])
|
37
|
+
action = payload[:action]
|
38
|
+
|
38
39
|
if controller && action
|
39
|
-
|
40
|
+
timing "action_controller.controller.#{controller}.#{action}.runtime.total", runtime
|
41
|
+
increment "action_controller.controller.#{controller}.#{action}.status.#{status}" if status
|
42
|
+
end
|
40
43
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
+
if self.class.instrument_view_runtime
|
45
|
+
view_runtime = payload[:view_runtime]
|
46
|
+
view_runtime = view_runtime.round if view_runtime
|
44
47
|
|
45
|
-
|
46
|
-
|
48
|
+
if view_runtime
|
49
|
+
timing "action_controller.runtime.view", view_runtime
|
47
50
|
|
51
|
+
if controller && action
|
52
|
+
timing "action_controller.controller.#{controller}.#{action}.runtime.view", view_runtime
|
53
|
+
end
|
54
|
+
end
|
48
55
|
end
|
49
56
|
|
50
|
-
if
|
51
|
-
|
57
|
+
if self.class.instrument_db_runtime
|
58
|
+
db_runtime = payload[:db_runtime]
|
59
|
+
db_runtime = db_runtime.round if db_runtime
|
60
|
+
|
61
|
+
if db_runtime
|
62
|
+
timing "action_controller.runtime.db", db_runtime
|
63
|
+
|
64
|
+
if controller && action
|
65
|
+
timing "action_controller.controller.#{controller}.#{action}.runtime.db", db_runtime
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
if self.class.instrument_format
|
71
|
+
format = payload[:format] || "all"
|
72
|
+
format = "all" if format == "*/*"
|
73
|
+
|
74
|
+
if format
|
75
|
+
increment "action_controller.format.#{format}"
|
52
76
|
|
53
|
-
|
77
|
+
if controller && action
|
78
|
+
increment "action_controller.controller.#{controller}.#{action}.format.#{format}"
|
79
|
+
end
|
80
|
+
end
|
54
81
|
end
|
55
82
|
end
|
56
83
|
|
@@ -13,7 +13,7 @@ module Nunes
|
|
13
13
|
|
14
14
|
def deliver(start, ending, transaction_id, payload)
|
15
15
|
runtime = ((ending - start) * 1_000).round
|
16
|
-
mailer = payload[:mailer]
|
16
|
+
mailer = ::Nunes.class_to_metric(payload[:mailer])
|
17
17
|
|
18
18
|
if mailer
|
19
19
|
timing "action_mailer.deliver.#{mailer}", runtime
|
@@ -22,7 +22,7 @@ module Nunes
|
|
22
22
|
|
23
23
|
def receive(start, ending, transaction_id, payload)
|
24
24
|
runtime = ((ending - start) * 1_000).round
|
25
|
-
mailer = payload[:mailer]
|
25
|
+
mailer = ::Nunes.class_to_metric(payload[:mailer])
|
26
26
|
|
27
27
|
if mailer
|
28
28
|
timing "action_mailer.receive.#{mailer}", runtime
|
@@ -30,14 +30,17 @@ module Nunes
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# Private: What to replace file separators with.
|
33
|
-
FileSeparatorReplacement = "_"
|
33
|
+
FileSeparatorReplacement = "_".freeze
|
34
|
+
|
35
|
+
# Private: An empty string.
|
36
|
+
Nothing = "".freeze
|
34
37
|
|
35
38
|
# Private: Converts an identifier to a metric name. Strips out the rails
|
36
39
|
# root from the full path.
|
37
40
|
#
|
38
41
|
# identifier - The String full path to the template or partial.
|
39
42
|
def identifier_to_metric(kind, identifier)
|
40
|
-
view_path = identifier.to_s.gsub(::Rails.root.to_s,
|
43
|
+
view_path = identifier.to_s.gsub(::Rails.root.to_s, Nothing)
|
41
44
|
metric = adapter.prepare(view_path, FileSeparatorReplacement)
|
42
45
|
"action_view.#{kind}.#{metric}"
|
43
46
|
end
|
@@ -13,16 +13,15 @@ module Nunes
|
|
13
13
|
|
14
14
|
def perform(start, ending, transaction_id, payload)
|
15
15
|
runtime = ((ending - start) * 1_000).round
|
16
|
-
job = payload[:job].class
|
16
|
+
job = ::Nunes.class_to_metric(payload[:job].class)
|
17
17
|
|
18
18
|
timing "active_job.#{job}.perform", runtime
|
19
19
|
end
|
20
20
|
|
21
21
|
def enqueue(start, ending, transaction_id, payload)
|
22
|
-
job = payload[:job].class
|
22
|
+
job = ::Nunes.class_to_metric(payload[:job].class)
|
23
23
|
increment "active_job.#{job}.enqueue"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
@@ -11,11 +11,14 @@ module Nunes
|
|
11
11
|
Pattern
|
12
12
|
end
|
13
13
|
|
14
|
+
# Private: Used to detect the operation from the sql.
|
15
|
+
Space = " ".freeze
|
16
|
+
|
14
17
|
def sql(start, ending, transaction_id, payload)
|
15
18
|
runtime = ((ending - start) * 1_000).round
|
16
19
|
name = payload[:name]
|
17
20
|
sql = payload[:sql].to_s.strip
|
18
|
-
operation = sql.split(
|
21
|
+
operation = sql.split(Space, 2).first.to_s.downcase
|
19
22
|
|
20
23
|
timing "active_record.sql", runtime
|
21
24
|
|
data/lib/nunes/version.rb
CHANGED
data/script/test
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
#!/bin/sh
|
2
|
-
#/ Usage: test
|
2
|
+
#/ Usage: test
|
3
3
|
#/
|
4
|
-
#/ Bootstrap and run all tests
|
5
|
-
#/
|
6
|
-
#/ Examples:
|
7
|
-
#/
|
8
|
-
#/ # run all tests
|
9
|
-
#/ test
|
10
|
-
#/
|
11
|
-
#/ # run individual test
|
12
|
-
#/ test test/controller_instrumentation_test.rb
|
4
|
+
#/ Bootstrap and run all tests.
|
13
5
|
#/
|
14
6
|
|
15
7
|
set -e
|
@@ -20,6 +12,11 @@ cd $(dirname "$0")/..
|
|
20
12
|
exit 0
|
21
13
|
}
|
22
14
|
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
export RAILS_VERSION=5.0.0
|
16
|
+
script/bootstrap || bundle update
|
17
|
+
bundle exec rake
|
18
|
+
|
19
|
+
|
20
|
+
export RAILS_VERSION=4.2.5
|
21
|
+
script/bootstrap || bundle update
|
22
|
+
bundle exec rake
|
@@ -23,10 +23,12 @@ class ControllerInstrumentationTest < ActionController::TestCase
|
|
23
23
|
assert_counter "action_controller.format.html"
|
24
24
|
|
25
25
|
assert_timer "action_controller.runtime.total"
|
26
|
+
assert_timer "action_controller.runtime.db"
|
26
27
|
assert_timer "action_controller.runtime.view"
|
27
28
|
|
28
29
|
assert_timer "action_controller.controller.PostsController.index.runtime.total"
|
29
30
|
assert_timer "action_controller.controller.PostsController.index.runtime.view"
|
31
|
+
assert_timer "action_controller.controller.PostsController.index.runtime.db"
|
30
32
|
end
|
31
33
|
|
32
34
|
test "send_data" do
|
@@ -67,8 +69,8 @@ class ControllerInstrumentationTest < ActionController::TestCase
|
|
67
69
|
assert_timer "action_controller.runtime.total"
|
68
70
|
assert_timer "action_controller.controller.PostsController.some_redirect.runtime.total"
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
+
refute_timer "action_controller.runtime.view"
|
73
|
+
refute_timer "action_controller.controller.PostsController.some_redirect.runtime.view"
|
72
74
|
end
|
73
75
|
|
74
76
|
test "action with exception" do
|
@@ -76,13 +78,53 @@ class ControllerInstrumentationTest < ActionController::TestCase
|
|
76
78
|
|
77
79
|
assert_response :success
|
78
80
|
|
79
|
-
assert_counter "action_controller.exception.RuntimeError"
|
80
81
|
assert_counter "action_controller.format.html"
|
81
82
|
|
82
83
|
assert_timer "action_controller.runtime.total"
|
83
84
|
assert_timer "action_controller.controller.PostsController.some_boom.runtime.total"
|
84
85
|
|
85
|
-
|
86
|
-
|
86
|
+
refute_timer "action_controller.runtime.view"
|
87
|
+
refute_timer "action_controller.controller.PostsController.some_boom.runtime.view"
|
88
|
+
end
|
89
|
+
|
90
|
+
test "with instrument format disabled" do
|
91
|
+
begin
|
92
|
+
original_format_enabled = Nunes::Subscribers::ActionController.instrument_format
|
93
|
+
Nunes::Subscribers::ActionController.instrument_format = false
|
94
|
+
|
95
|
+
get :index
|
96
|
+
|
97
|
+
refute_counter "action_controller.format.html"
|
98
|
+
ensure
|
99
|
+
Nunes::Subscribers::ActionController.instrument_format = original_format_enabled
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
test "with instrument db runtime disabled" do
|
104
|
+
begin
|
105
|
+
original_format_enabled = Nunes::Subscribers::ActionController.instrument_db_runtime
|
106
|
+
Nunes::Subscribers::ActionController.instrument_db_runtime = false
|
107
|
+
|
108
|
+
get :index
|
109
|
+
|
110
|
+
refute_timer "action_controller.runtime.db"
|
111
|
+
refute_timer "action_controller.controller.PostsController.index.runtime.db"
|
112
|
+
ensure
|
113
|
+
Nunes::Subscribers::ActionController.instrument_db_runtime = original_format_enabled
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
test "with instrument view runtime disabled" do
|
118
|
+
begin
|
119
|
+
original_format_enabled = Nunes::Subscribers::ActionController.instrument_view_runtime
|
120
|
+
Nunes::Subscribers::ActionController.instrument_view_runtime = false
|
121
|
+
|
122
|
+
get :index
|
123
|
+
|
124
|
+
refute_timer "action_controller.runtime.view"
|
125
|
+
refute_timer "action_controller.controller.PostsController.index.runtime.view"
|
126
|
+
ensure
|
127
|
+
Nunes::Subscribers::ActionController.instrument_view_runtime = original_format_enabled
|
128
|
+
end
|
87
129
|
end
|
88
130
|
end
|