activeinsights 0.1.4 → 0.2.1

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: 357a2bfdbba595c8b40f5a63b2417d49bc6f4288c688e0d75ab77ba378cd078e
4
- data.tar.gz: 52e2ad59d758b76ad46aa01cf592a3365dfe3baa407556196acbc027cbec121a
3
+ metadata.gz: 76e005aeac4566e4090e0b0eaf1109f15ebe7b9ad1593bc0fa2182d1dbcdc219
4
+ data.tar.gz: 04c8d6d629166c53342b3b49ee6ade131d2aa8b9e4664d9e0f7ee461e7112d6c
5
5
  SHA512:
6
- metadata.gz: fc8e3e23c6d340f047392bf9f21cd8e1bc1b255d9d072e7f30f4b2494d639522e3f1276021461ff87649c48bc0c61854ba234422ad2e508e0efbced367a28ab0
7
- data.tar.gz: 1f184e727faf3f5a50ecc017158ee97058b5de3dacb4d8e0b8d3ba9d4725f62f245a4220d47a9221fb6dbfcbe700943c92f213ca4c58e2ef15586f22238d60b0
6
+ metadata.gz: '07459ea24e4941797ce69358fca6a478f17c80a029db7d4fa5b3f99f768b8901867ccda21334f38e89e24ed6877525c008496a52e5b5dd9cb386cac4d30143c1'
7
+ data.tar.gz: 262cb9bfb588175b8018159d6eea787c7d8fc9ea9fd5290a0214f82c7a8636cbbee848430cd8b6062beebb267727963f16af4c25c700471b817529e94263cca7
data/README.md CHANGED
@@ -48,6 +48,12 @@ options for the `Request` model.
48
48
  ActiveInsights.connects_to = { database: { writing: :requests, reading: :requests } }
49
49
  ```
50
50
 
51
+ You can supply an array of ignored endpoints
52
+
53
+ ```ruby
54
+ ActiveInsights.ignored_endpoints = ["Rails::HealthController#show"]
55
+ ```
56
+
51
57
  ## Development
52
58
 
53
59
  After checking out the repo, run `bin/setup` to install dependencies. Then, run
@@ -24,5 +24,14 @@ module ActiveInsights
24
24
  Date.current
25
25
  end.beginning_of_day
26
26
  end
27
+
28
+ def base_scope
29
+ scope = ActiveInsights::Request.where(started_at: @date)
30
+ if ActiveInsights.ignored_endpoints.present?
31
+ scope = scope.where.
32
+ not(formatted_controller: ActiveInsights.ignored_endpoints)
33
+ end
34
+ scope
35
+ end
27
36
  end
28
37
  end
@@ -17,8 +17,7 @@ module ActiveInsights
17
17
 
18
18
  def minutes
19
19
  @minutes ||=
20
- ActiveInsights::Request.where(started_at: @date).
21
- where(formatted_controller: params[:formatted_controller]).
20
+ base_scope.where(formatted_controller: params[:formatted_controller]).
22
21
  minute_by_minute.with_durations.select_started_at
23
22
  end
24
23
  end
@@ -15,9 +15,7 @@ module ActiveInsights
15
15
  private
16
16
 
17
17
  def minutes
18
- @minutes ||=
19
- ActiveInsights::Request.where(started_at: @date).
20
- minute_by_minute.with_durations.select_started_at
18
+ @minutes ||= base_scope.minute_by_minute.with_durations.select_started_at
21
19
  end
22
20
  end
23
21
  end
@@ -4,10 +4,8 @@ module ActiveInsights
4
4
  class RequestsController < ApplicationController
5
5
  def index
6
6
  @requests =
7
- ActiveInsights::Request.where(started_at: @date).
8
- with_durations.select(:formatted_controller).
9
- group(:formatted_controller).
10
- sort_by(&:agony).reverse
7
+ base_scope.with_durations.select(:formatted_controller).
8
+ group(:formatted_controller).sort_by(&:agony).reverse
11
9
  end
12
10
  end
13
11
  end
@@ -4,9 +4,10 @@ module ActiveInsights
4
4
  class RpmController < ApplicationController
5
5
  def index
6
6
  @minutes =
7
- ActiveInsights::Request.where(started_at: @date).
8
- minute_by_minute.select("COUNT(id) AS rpm").select_started_at.
9
- map { |minute| [minute.started_at.strftime("%-l:%M%P"), minute.rpm] }
7
+ base_scope.minute_by_minute.select("COUNT(id) AS rpm").
8
+ select_started_at.map do |minute|
9
+ [minute.started_at.strftime("%-l:%M%P"), minute.rpm]
10
+ end
10
11
  end
11
12
 
12
13
  def redirection
@@ -11,6 +11,14 @@ module ActiveInsights
11
11
  end
12
12
  end
13
13
 
14
+ config.active_insights = ActiveSupport::OrderedOptions.new
15
+
16
+ initializer "active_insights.config" do
17
+ config.active_insights.each do |name, value|
18
+ ActiveInsights.public_send(:"#{name}=", value)
19
+ end
20
+ end
21
+
14
22
  initializer "active_insights.importmap", before: "importmap" do |app|
15
23
  app.config.importmap.paths <<
16
24
  Engine.root.join("config/initializers/importmap.rb")
@@ -20,7 +28,8 @@ module ActiveInsights
20
28
  ActiveSupport::Notifications.
21
29
  subscribe("process_action.action_controller") do |_name,
22
30
  started, finished, unique_id, payload|
23
- next if Rails.env.development?
31
+ next if Rails.env.development? ||
32
+ ActiveInsights.ignored_endpoint?(payload)
24
33
 
25
34
  Thread.new do
26
35
  ActiveRecord::Base.connection_pool.with_connection do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveInsights
4
- VERSION = "0.1.4"
4
+ VERSION = "0.2.1"
5
5
  end
@@ -7,5 +7,11 @@ require "active_insights/version"
7
7
  require "active_insights/engine"
8
8
 
9
9
  module ActiveInsights
10
- mattr_accessor :connects_to
10
+ mattr_accessor :connects_to, :ignored_endpoints
11
+
12
+ def self.ignored_endpoint?(payload)
13
+ ignored_endpoints.to_a.include?(
14
+ "#{payload[:controller]}##{payload[:action]}"
15
+ )
16
+ end
11
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeinsights
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza