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 +4 -4
- data/README.md +6 -0
- data/app/controllers/active_insights/application_controller.rb +9 -0
- data/app/controllers/active_insights/controller_p_values_controller.rb +1 -2
- data/app/controllers/active_insights/p_values_controller.rb +1 -3
- data/app/controllers/active_insights/requests_controller.rb +2 -4
- data/app/controllers/active_insights/rpm_controller.rb +4 -3
- data/lib/active_insights/engine.rb +2 -1
- data/lib/active_insights/version.rb +1 -1
- data/lib/active_insights.rb +7 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dadcb3ff31dcb9021bea6a79dbbe8c2e9de03a268a0c82f6a36158bd513c9f2a
|
4
|
+
data.tar.gz: 6c99fafe1e426fbd8de6fbe53c889e5bd780a4d5b37fdc110665e0eddff0ae0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
8
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
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
|
data/lib/active_insights.rb
CHANGED
@@ -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
|