activeinsights 0.1.4 → 0.2.0

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: dadcb3ff31dcb9021bea6a79dbbe8c2e9de03a268a0c82f6a36158bd513c9f2a
4
+ data.tar.gz: 6c99fafe1e426fbd8de6fbe53c889e5bd780a4d5b37fdc110665e0eddff0ae0a
5
5
  SHA512:
6
- metadata.gz: fc8e3e23c6d340f047392bf9f21cd8e1bc1b255d9d072e7f30f4b2494d639522e3f1276021461ff87649c48bc0c61854ba234422ad2e508e0efbced367a28ab0
7
- data.tar.gz: 1f184e727faf3f5a50ecc017158ee97058b5de3dacb4d8e0b8d3ba9d4725f62f245a4220d47a9221fb6dbfcbe700943c92f213ca4c58e2ef15586f22238d60b0
6
+ metadata.gz: 732e3356cdcb0d23798fc0a5c3f6414b3f1f7e1fa5226b1d27b100f58a7081190fdb5dec27ae71b836beee660cd0dfe3e26ed9c1d9d2cb8d089e22787a4ef649
7
+ data.tar.gz: 03a8cd017f4fa4b5da97825a2ad2414a4e18b4ec771f14ff38e9bf90d9afa6f40e50f9ea262c90e354fea3baf0d4184bde4aeea15eae77ab7e93dd98666c1a1a
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
@@ -20,7 +20,8 @@ module ActiveInsights
20
20
  ActiveSupport::Notifications.
21
21
  subscribe("process_action.action_controller") do |_name,
22
22
  started, finished, unique_id, payload|
23
- next if Rails.env.development?
23
+ next if Rails.env.development? ||
24
+ ActiveInsights.ignored_endpoint?(payload)
24
25
 
25
26
  Thread.new do
26
27
  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.0"
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza