activeinsights 0.1.4 → 0.2.1
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/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 +10 -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: 76e005aeac4566e4090e0b0eaf1109f15ebe7b9ad1593bc0fa2182d1dbcdc219
|
4
|
+
data.tar.gz: 04c8d6d629166c53342b3b49ee6ade131d2aa8b9e4664d9e0f7ee461e7112d6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
@@ -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
|
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
|