ezmetrics 3.0.1 → 3.0.2
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -24
- data/lib/ezmetrics/dashboard/app/controllers/dashboard/metrics_controller.rb +2 -0
- data/lib/ezmetrics/dashboard/app/views/layouts/dashboard/application.html.erb +1 -1
- data/lib/ezmetrics/version.rb +1 -1
- data/lib/generators/ezmetrics/initializer_generator.rb +39 -0
- metadata +2 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 649ab1e2c20a015b6d86ea2223f7433412df4512abfc56006cadd6cf66fcfd92
         | 
| 4 | 
            +
              data.tar.gz: ca8ffc1be36df9a4ef919b6e1142d5a37b4c648a4ad8465102c4cdcf3549201f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c6497dc65a44695ebfdba14a1432fb6817f5f1cc7475b2e220946dc9ce0e3b6381fb45f73d5b147c762e5ca1b4d7c1200133dec582001c596b5ae001df013c84
         | 
| 7 | 
            +
              data.tar.gz: da66965496e68efbdfd01de30c2ef1ec2a3dddca73e83fc966d0da519bf83146e76084b8d7f81137581d1c6e6cfaaf97c2e7fd863dc90bbd36872cb369ad5b92
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -25,30 +25,8 @@ gem 'ezmetrics' | |
| 25 25 |  | 
| 26 26 | 
             
            ### Capture metrics
         | 
| 27 27 |  | 
| 28 | 
            -
             | 
| 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
         | 
    
        data/lib/ezmetrics/version.rb
    CHANGED
    
    
| @@ -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. | 
| 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:
         |