ezmetrics 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5ac3982d5d61860761d7eead15a0fc4d8cc1d812400fd16e8461d6202242acc
4
- data.tar.gz: 1b411c45eab2c0bf3cf8761b564b9849729e14913d53c0ff63e3ee0a5185f8d9
3
+ metadata.gz: 649ab1e2c20a015b6d86ea2223f7433412df4512abfc56006cadd6cf66fcfd92
4
+ data.tar.gz: ca8ffc1be36df9a4ef919b6e1142d5a37b4c648a4ad8465102c4cdcf3549201f
5
5
  SHA512:
6
- metadata.gz: aaed4842a1a7f13c84fca2d65c7ff7eb3b6a48b860ba557a123c93a7e7320c1af84036c91767af09da8ef85a9754a18805e7cc459c572721946eeabe4e8bc067
7
- data.tar.gz: ecd4eb6cd0d35dc255811449a3baaec99a2fafcb375816d5fa1e90d707d2ec527d1ec48cae96808c9f331592b72ffa6dc4fe035a28fbbfe43321da727617a61a
6
+ metadata.gz: c6497dc65a44695ebfdba14a1432fb6817f5f1cc7475b2e220946dc9ce0e3b6381fb45f73d5b147c762e5ca1b4d7c1200133dec582001c596b5ae001df013c84
7
+ data.tar.gz: da66965496e68efbdfd01de30c2ef1ec2a3dddca73e83fc966d0da519bf83146e76084b8d7f81137581d1c6e6cfaaf97c2e7fd863dc90bbd36872cb369ad5b92
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ezmetrics (3.0.1)
4
+ ezmetrics (3.0.2)
5
5
  hiredis (~> 0.6.3)
6
6
  oj (~> 3.10)
7
7
  redis (~> 4.0)
data/README.md CHANGED
@@ -25,30 +25,8 @@ gem 'ezmetrics'
25
25
 
26
26
  ### Capture metrics
27
27
 
28
- Add an initializer to your application:
29
-
30
- ```ruby
31
- # config/initializers/ezmetrics.rb
32
-
33
- ActiveSupport::Notifications.subscribe("sql.active_record") do |*args|
34
- event = ActiveSupport::Notifications::Event.new(*args)
35
- unless event.payload[:name] == "SCHEMA" || event.payload[:sql] =~ /\ABEGIN|COMMIT|ROLLBACK\z/
36
- Thread.current[:queries] ||= 0
37
- Thread.current[:queries] += 1
38
- end
39
- end
40
-
41
- ActiveSupport::Notifications.subscribe("process_action.action_controller") do |*args|
42
- event = ActiveSupport::Notifications::Event.new(*args)
43
- Ezmetrics::Storage.new(24.hours).log(
44
- duration: event.duration.to_f,
45
- views: event.payload[:view_runtime].to_f,
46
- db: event.payload[:db_runtime].to_f,
47
- status: event.payload[:status].to_i || 500,
48
- queries: Thread.current[:queries].to_i,
49
- )
50
- Thread.current[:queries] = 0
51
- end
28
+ ```
29
+ rails generate ezmetrics:initializer
52
30
  ```
53
31
 
54
32
  ### Display metrics
@@ -1,5 +1,7 @@
1
1
  module Dashboard
2
2
  class MetricsController < ApplicationController
3
+ layout "dashboard/application"
4
+
3
5
  def index
4
6
  end
5
7
 
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Dashboard</title>
5
- <%= stylesheet_link_tag "dashboard/application", media: "all" %>
5
+ <%= stylesheet_link_tag "dashboard/application", media: "all" %>
6
6
  <%= csrf_meta_tags %>
7
7
  </head>
8
8
  <body>
@@ -1,3 +1,3 @@
1
1
  module Ezmetrics
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.2"
3
3
  end
@@ -0,0 +1,39 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Ezmetrics
4
+ module Generators
5
+ class InitializerGenerator < Rails::Generators::Base
6
+ desc "This generator creates an initializer file at config/initializers"
7
+
8
+ def create_initializer_file
9
+ create_file "config/initializers/ezmetrics.rb", config_content
10
+ end
11
+
12
+ def config_content
13
+ <<RUBY
14
+ ActiveSupport::Notifications.subscribe("sql.active_record") do |*args|
15
+ event = ActiveSupport::Notifications::Event.new(*args)
16
+ unless event.payload[:name] == "SCHEMA" || event.payload[:sql] =~ /\ABEGIN|COMMIT|ROLLBACK\z/
17
+ Thread.current[:queries] ||= 0
18
+ Thread.current[:queries] += 1
19
+ end
20
+ end
21
+
22
+ ActiveSupport::Notifications.subscribe("process_action.action_controller") do |*args|
23
+ event = ActiveSupport::Notifications::Event.new(*args)
24
+ Ezmetrics::Storage.new(24.hours).log(
25
+ duration: event.duration.to_f,
26
+ views: event.payload[:view_runtime].to_f,
27
+ db: event.payload[:db_runtime].to_f,
28
+ status: event.payload[:exception] ? 500 : event.payload[:status].to_i,
29
+ queries: Thread.current[:queries].to_i,
30
+ store_each_value: true
31
+ )
32
+
33
+ Thread.current[:queries] = 0
34
+ end
35
+ RUBY
36
+ end
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ezmetrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolae Rotaru
@@ -122,6 +122,7 @@ files:
122
122
  - lib/ezmetrics/dashboard/react-dashboard/yarn.lock
123
123
  - lib/ezmetrics/storage.rb
124
124
  - lib/ezmetrics/version.rb
125
+ - lib/generators/ezmetrics/initializer_generator.rb
125
126
  - scripts/compile_assets
126
127
  homepage: https://github.com/nyku/ezmetrics
127
128
  licenses: