rails_band 0.3.0 → 0.6.0
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 +26 -24
- data/lib/rails_band/action_cable/event/broadcast.rb +22 -0
- data/lib/rails_band/action_cable/event/perform_action.rb +22 -0
- data/lib/rails_band/action_cable/event/transmit.rb +22 -0
- data/lib/rails_band/action_cable/event/transmit_subscription_confirmation.rb +14 -0
- data/lib/rails_band/action_cable/event/transmit_subscription_rejection.rb +14 -0
- data/lib/rails_band/action_cable/log_subscriber.rb +42 -0
- data/lib/rails_band/active_job/event/discard.rb +22 -0
- data/lib/rails_band/active_job/event/enqueue.rb +18 -0
- data/lib/rails_band/active_job/event/enqueue_at.rb +18 -0
- data/lib/rails_band/active_job/event/enqueue_retry.rb +26 -0
- data/lib/rails_band/active_job/event/perform.rb +18 -0
- data/lib/rails_band/active_job/event/perform_start.rb +18 -0
- data/lib/rails_band/active_job/event/retry_stopped.rb +22 -0
- data/lib/rails_band/active_job/log_subscriber.rb +52 -0
- data/lib/rails_band/active_storage/event/analyze.rb +14 -0
- data/lib/rails_band/active_storage/event/preview.rb +16 -0
- data/lib/rails_band/active_storage/event/service_delete.rb +20 -0
- data/lib/rails_band/active_storage/event/service_delete_prefixed.rb +18 -0
- data/lib/rails_band/active_storage/event/service_download.rb +20 -0
- data/lib/rails_band/active_storage/event/service_download_chunk.rb +24 -0
- data/lib/rails_band/active_storage/event/service_exist.rb +26 -0
- data/lib/rails_band/active_storage/event/service_streaming_download.rb +20 -0
- data/lib/rails_band/active_storage/event/service_update_metadata.rb +28 -0
- data/lib/rails_band/active_storage/event/service_upload.rb +26 -0
- data/lib/rails_band/active_storage/event/service_url.rb +24 -0
- data/lib/rails_band/active_storage/event/transform.rb +11 -0
- data/lib/rails_band/active_storage/log_subscriber.rb +77 -0
- data/lib/rails_band/railtie.rb +19 -0
- data/lib/rails_band/version.rb +1 -1
- data/lib/rails_band.rb +12 -0
- metadata +36 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d8062da3d8ef85024e23c439e5d3eea7daca6d1a02b67e8182ba7ca570f3b22
|
4
|
+
data.tar.gz: dff4f9a0b08ef4c09dde608ad7e00855859014059cbc7c6e430725d6cc51548a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab91a63e9c231a7c92731c276749753b8ef862854192cb5cc9e10cfc2d0d96c56d293ba2fcbbc6d307cf6894d33ce71e82b86ab00e170a8314c6fd090414f362
|
7
|
+
data.tar.gz: 592ec597dfcdf32bbf1be74a962b4763c6b9c60903a2788fc44bf40d44ee5be379fbd3da9e70837d14c996cfe3f860cde368f8b02e4b01a537f9775819857ad0
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# rails_band
|
2
2
|
|
3
3
|
<a href="https://github.com/yykamei/rails_band/actions/workflows/ci.yml"><img alt="GitHub Actions workflow status" src="https://github.com/yykamei/rails_band/actions/workflows/ci.yml/badge.svg"></a>
|
4
|
-
<a href="https://rubygems.org/gems/rails_band"><img alt="
|
4
|
+
<a href="https://rubygems.org/gems/rails_band"><img alt="rails_band" src="https://img.shields.io/gem/v/rails_band"></a>
|
5
5
|
|
6
6
|
Easy-to-use Rails Instrumentation API.
|
7
7
|
|
@@ -82,6 +82,7 @@ These are Rails Instrumentation API hooks supported by this gem so far.
|
|
82
82
|
| [`render_template.action_view`](https://guides.rubyonrails.org/active_support_instrumentation.html#render-template-action-view) | ✅ |
|
83
83
|
| [`render_partial.action_view`](https://guides.rubyonrails.org/active_support_instrumentation.html#render-partial-action-view) | ✅ |
|
84
84
|
| [`render_collection.action_view`](https://guides.rubyonrails.org/active_support_instrumentation.html#render-collection-action-view) | ✅ |
|
85
|
+
| [`render_layout.action_view`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#render-layout-action-view) | |
|
85
86
|
|
86
87
|
### Active Record
|
87
88
|
|
@@ -116,39 +117,40 @@ These are Rails Instrumentation API hooks supported by this gem so far.
|
|
116
117
|
|
117
118
|
| Event name | Supported |
|
118
119
|
| ------------------------------------------------------------------------------------------------------------------------- | --------- |
|
119
|
-
| [`enqueue_at.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-at-active-job) |
|
120
|
-
| [`enqueue.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-active-job) |
|
121
|
-
| [`enqueue_retry.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-retry-active-job) |
|
122
|
-
| [`perform_start.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-start-active-job) |
|
123
|
-
| [`perform.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-active-job) |
|
124
|
-
| [`retry_stopped.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#retry-stopped-active-job) |
|
125
|
-
| [`discard.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#discard-active-job) |
|
120
|
+
| [`enqueue_at.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-at-active-job) | ✅ |
|
121
|
+
| [`enqueue.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-active-job) | ✅ |
|
122
|
+
| [`enqueue_retry.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-retry-active-job) | ✅ |
|
123
|
+
| [`perform_start.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-start-active-job) | ✅ |
|
124
|
+
| [`perform.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-active-job) | ✅ |
|
125
|
+
| [`retry_stopped.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#retry-stopped-active-job) | ✅ |
|
126
|
+
| [`discard.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#discard-active-job) | ✅ |
|
126
127
|
|
127
128
|
### Action Cable
|
128
129
|
|
129
130
|
| Event name | Supported |
|
130
131
|
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
|
131
|
-
| [`perform_action.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-action-action-cable) |
|
132
|
-
| [`transmit.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-action-cable) |
|
133
|
-
| [`transmit_subscription_confirmation.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-subscription-confirmation-action-cable) |
|
134
|
-
| [`transmit_subscription_rejection.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-subscription-rejection-action-cable) |
|
135
|
-
| [`broadcast.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#broadcast-action-cable) |
|
132
|
+
| [`perform_action.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-action-action-cable) | ✅ |
|
133
|
+
| [`transmit.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-action-cable) | ✅ |
|
134
|
+
| [`transmit_subscription_confirmation.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-subscription-confirmation-action-cable) | ✅ |
|
135
|
+
| [`transmit_subscription_rejection.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-subscription-rejection-action-cable) | ✅ |
|
136
|
+
| [`broadcast.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#broadcast-action-cable) | ✅ |
|
136
137
|
|
137
138
|
### Active Storage
|
138
139
|
|
139
140
|
| Event name | Supported |
|
140
141
|
| ----------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
|
141
|
-
| [`service_upload.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-upload-active-storage) |
|
142
|
-
| [`service_streaming_download.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-streaming-download-active-storage) |
|
143
|
-
| [`service_download_chunk.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-download-chunk-active-storage) |
|
144
|
-
| [`service_download.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-download-active-storage) |
|
145
|
-
| [`service_delete.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-delete-active-storage) |
|
146
|
-
| [`service_delete_prefixed.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-delete-prefixed-active-storage) |
|
147
|
-
| [`service_exist.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-exist-active-storage) |
|
148
|
-
| [`service_url.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-url-active-storage) |
|
149
|
-
| [`service_update_metadata.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-update-metadata-active-storage) |
|
150
|
-
| [`preview.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#preview-active-storage) |
|
151
|
-
| [`
|
142
|
+
| [`service_upload.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-upload-active-storage) | ✅ |
|
143
|
+
| [`service_streaming_download.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-streaming-download-active-storage) | ✅ |
|
144
|
+
| [`service_download_chunk.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-download-chunk-active-storage) | ✅ |
|
145
|
+
| [`service_download.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-download-active-storage) | ✅ |
|
146
|
+
| [`service_delete.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-delete-active-storage) | ✅ |
|
147
|
+
| [`service_delete_prefixed.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-delete-prefixed-active-storage) | ✅ |
|
148
|
+
| [`service_exist.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-exist-active-storage) | ✅ |
|
149
|
+
| [`service_url.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-url-active-storage) | ✅ |
|
150
|
+
| [`service_update_metadata.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-update-metadata-active-storage) | ✅ |
|
151
|
+
| [`preview.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#preview-active-storage) | ✅ |
|
152
|
+
| [`transform.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#transform-active-storage) | ✅ |
|
153
|
+
| [`analyze.active_storage`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#analyze-active-storage) | ✅ |
|
152
154
|
|
153
155
|
### Railties
|
154
156
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActionCable
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `broadcast.action_cable`.
|
7
|
+
class Broadcast < BaseEvent
|
8
|
+
def broadcasting
|
9
|
+
@broadcasting ||= @event.payload.fetch(:broadcasting)
|
10
|
+
end
|
11
|
+
|
12
|
+
def message
|
13
|
+
@message ||= @event.payload.fetch(:message)
|
14
|
+
end
|
15
|
+
|
16
|
+
def coder
|
17
|
+
@coder ||= @event.payload.fetch(:coder)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActionCable
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `perform_action.action_cable`.
|
7
|
+
class PerformAction < BaseEvent
|
8
|
+
def channel_class
|
9
|
+
@channel_class ||= @event.payload.fetch(:channel_class)
|
10
|
+
end
|
11
|
+
|
12
|
+
def action
|
13
|
+
@action ||= @event.payload.fetch(:action)
|
14
|
+
end
|
15
|
+
|
16
|
+
def data
|
17
|
+
@data ||= @event.payload.fetch(:data)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActionCable
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `transmit.action_cable`.
|
7
|
+
class Transmit < BaseEvent
|
8
|
+
def channel_class
|
9
|
+
@channel_class ||= @event.payload.fetch(:channel_class)
|
10
|
+
end
|
11
|
+
|
12
|
+
def data
|
13
|
+
@data ||= @event.payload.fetch(:data)
|
14
|
+
end
|
15
|
+
|
16
|
+
def via
|
17
|
+
@via ||= @event.payload.fetch(:via)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActionCable
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `transmit_subscription_confirmation.action_cable`.
|
7
|
+
class TransmitSubscriptionConfirmation < BaseEvent
|
8
|
+
def channel_class
|
9
|
+
@channel_class ||= @event.payload.fetch(:channel_class)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActionCable
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `transmit_subscription_rejection.action_cable`.
|
7
|
+
class TransmitSubscriptionRejection < BaseEvent
|
8
|
+
def channel_class
|
9
|
+
@channel_class ||= @event.payload.fetch(:channel_class)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_band/action_cable/event/perform_action'
|
4
|
+
require 'rails_band/action_cable/event/transmit'
|
5
|
+
require 'rails_band/action_cable/event/transmit_subscription_confirmation'
|
6
|
+
require 'rails_band/action_cable/event/transmit_subscription_rejection'
|
7
|
+
require 'rails_band/action_cable/event/broadcast'
|
8
|
+
|
9
|
+
module RailsBand
|
10
|
+
module ActionCable
|
11
|
+
# The custom LogSubscriber for ActionCable.
|
12
|
+
class LogSubscriber < ::ActiveSupport::LogSubscriber
|
13
|
+
mattr_accessor :consumers
|
14
|
+
|
15
|
+
def perform_action(event)
|
16
|
+
consumer_of(__method__)&.call(Event::PerformAction.new(event))
|
17
|
+
end
|
18
|
+
|
19
|
+
def transmit(event)
|
20
|
+
consumer_of(__method__)&.call(Event::Transmit.new(event))
|
21
|
+
end
|
22
|
+
|
23
|
+
def transmit_subscription_confirmation(event)
|
24
|
+
consumer_of(__method__)&.call(Event::TransmitSubscriptionConfirmation.new(event))
|
25
|
+
end
|
26
|
+
|
27
|
+
def transmit_subscription_rejection(event)
|
28
|
+
consumer_of(__method__)&.call(Event::TransmitSubscriptionRejection.new(event))
|
29
|
+
end
|
30
|
+
|
31
|
+
def broadcast(event)
|
32
|
+
consumer_of(__method__)&.call(Event::Broadcast.new(event))
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def consumer_of(sub_event)
|
38
|
+
consumers[:"#{sub_event}.action_cable"] || consumers[:action_cable] || consumers[:default]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveJob
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `discard.active_job`.
|
7
|
+
class Discard < BaseEvent
|
8
|
+
def adapter
|
9
|
+
@adapter ||= @event.payload.fetch(:adapter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def job
|
13
|
+
@job ||= @event.payload.fetch(:job)
|
14
|
+
end
|
15
|
+
|
16
|
+
def error
|
17
|
+
@error ||= @event.payload.fetch(:error)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveJob
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `enqueue.active_job`.
|
7
|
+
class Enqueue < BaseEvent
|
8
|
+
def adapter
|
9
|
+
@adapter ||= @event.payload.fetch(:adapter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def job
|
13
|
+
@job ||= @event.payload.fetch(:job)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveJob
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `enqueue_at.active_job`.
|
7
|
+
class EnqueueAt < BaseEvent
|
8
|
+
def adapter
|
9
|
+
@adapter ||= @event.payload.fetch(:adapter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def job
|
13
|
+
@job ||= @event.payload.fetch(:job)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveJob
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `enqueue_retry.active_job`.
|
7
|
+
class EnqueueRetry < BaseEvent
|
8
|
+
def adapter
|
9
|
+
@adapter ||= @event.payload.fetch(:adapter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def job
|
13
|
+
@job ||= @event.payload.fetch(:job)
|
14
|
+
end
|
15
|
+
|
16
|
+
def wait
|
17
|
+
@wait ||= @event.payload.fetch(:wait)
|
18
|
+
end
|
19
|
+
|
20
|
+
def error
|
21
|
+
@error ||= @event.payload.fetch(:error)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveJob
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `perform.active_job`.
|
7
|
+
class Perform < BaseEvent
|
8
|
+
def adapter
|
9
|
+
@adapter ||= @event.payload.fetch(:adapter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def job
|
13
|
+
@job ||= @event.payload.fetch(:job)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveJob
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `perform_start.active_job`.
|
7
|
+
class PerformStart < BaseEvent
|
8
|
+
def adapter
|
9
|
+
@adapter ||= @event.payload.fetch(:adapter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def job
|
13
|
+
@job ||= @event.payload.fetch(:job)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveJob
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `retry_stopped.active_job`.
|
7
|
+
class RetryStopped < BaseEvent
|
8
|
+
def adapter
|
9
|
+
@adapter ||= @event.payload.fetch(:adapter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def job
|
13
|
+
@job ||= @event.payload.fetch(:job)
|
14
|
+
end
|
15
|
+
|
16
|
+
def error
|
17
|
+
@error ||= @event.payload.fetch(:error)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_band/active_job/event/enqueue_at'
|
4
|
+
require 'rails_band/active_job/event/enqueue'
|
5
|
+
require 'rails_band/active_job/event/enqueue_retry'
|
6
|
+
require 'rails_band/active_job/event/perform_start'
|
7
|
+
require 'rails_band/active_job/event/perform'
|
8
|
+
require 'rails_band/active_job/event/retry_stopped'
|
9
|
+
require 'rails_band/active_job/event/discard'
|
10
|
+
|
11
|
+
module RailsBand
|
12
|
+
module ActiveJob
|
13
|
+
# The custom LogSubscriber for ActiveJob.
|
14
|
+
class LogSubscriber < ::ActiveSupport::LogSubscriber
|
15
|
+
mattr_accessor :consumers
|
16
|
+
|
17
|
+
def enqueue_at(event)
|
18
|
+
consumer_of(__method__)&.call(Event::EnqueueAt.new(event))
|
19
|
+
end
|
20
|
+
|
21
|
+
def enqueue(event)
|
22
|
+
consumer_of(__method__)&.call(Event::Enqueue.new(event))
|
23
|
+
end
|
24
|
+
|
25
|
+
def enqueue_retry(event)
|
26
|
+
consumer_of(__method__)&.call(Event::EnqueueRetry.new(event))
|
27
|
+
end
|
28
|
+
|
29
|
+
def perform_start(event)
|
30
|
+
consumer_of(__method__)&.call(Event::PerformStart.new(event))
|
31
|
+
end
|
32
|
+
|
33
|
+
def perform(event)
|
34
|
+
consumer_of(__method__)&.call(Event::Perform.new(event))
|
35
|
+
end
|
36
|
+
|
37
|
+
def retry_stopped(event)
|
38
|
+
consumer_of(__method__)&.call(Event::RetryStopped.new(event))
|
39
|
+
end
|
40
|
+
|
41
|
+
def discard(event)
|
42
|
+
consumer_of(__method__)&.call(Event::Discard.new(event))
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def consumer_of(sub_event)
|
48
|
+
consumers[:"#{sub_event}.active_job"] || consumers[:active_job] || consumers[:default]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `analyze.active_storage`.
|
7
|
+
class Analyze < BaseEvent
|
8
|
+
def analyzer
|
9
|
+
@analyzer ||= @event.payload.fetch(:analyzer)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `preview.active_storage`.
|
7
|
+
class Preview < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_delete.active_storage`.
|
7
|
+
class ServiceDelete < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def service
|
15
|
+
@service ||= @event.payload.fetch(:service)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_delete_prefixed.active_storage`.
|
7
|
+
class ServiceDeletePrefixed < BaseEvent
|
8
|
+
def prefix
|
9
|
+
@prefix ||= @event.payload.fetch(:prefix)
|
10
|
+
end
|
11
|
+
|
12
|
+
def service
|
13
|
+
@service ||= @event.payload.fetch(:service)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_download.active_storage`.
|
7
|
+
class ServiceDownload < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def service
|
15
|
+
@service ||= @event.payload.fetch(:service)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_download_chunk.active_storage`.
|
7
|
+
class ServiceDownloadChunk < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def service
|
15
|
+
@service ||= @event.payload.fetch(:service)
|
16
|
+
end
|
17
|
+
|
18
|
+
def range
|
19
|
+
@range ||= @event.payload.fetch(:range)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_exist.active_storage`.
|
7
|
+
class ServiceExist < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def service
|
15
|
+
@service ||= @event.payload.fetch(:service)
|
16
|
+
end
|
17
|
+
|
18
|
+
def exist
|
19
|
+
return @exist if defined? @exist
|
20
|
+
|
21
|
+
@exist = @event.payload.fetch(:exist)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_streaming_download.active_storage`.
|
7
|
+
class ServiceStreamingDownload < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def service
|
15
|
+
@service ||= @event.payload.fetch(:service)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_update_metadata.active_storage`.
|
7
|
+
class ServiceUpdateMetadata < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def service
|
15
|
+
@service ||= @event.payload.fetch(:service)
|
16
|
+
end
|
17
|
+
|
18
|
+
def content_type
|
19
|
+
@content_type ||= @event.payload.fetch(:content_type)
|
20
|
+
end
|
21
|
+
|
22
|
+
def disposition
|
23
|
+
@disposition ||= @event.payload.fetch(:disposition)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_upload.active_storage`.
|
7
|
+
class ServiceUpload < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def checksum
|
15
|
+
return @checksum if defined? @checksum
|
16
|
+
|
17
|
+
@checksum = @event.payload[:checksum]
|
18
|
+
end
|
19
|
+
|
20
|
+
def service
|
21
|
+
@service ||= @event.payload.fetch(:service)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_url.active_storage`.
|
7
|
+
class ServiceUrl < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def service
|
15
|
+
@service ||= @event.payload.fetch(:service)
|
16
|
+
end
|
17
|
+
|
18
|
+
def url
|
19
|
+
@url ||= @event.payload.fetch(:url)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_band/active_storage/event/service_upload'
|
4
|
+
require 'rails_band/active_storage/event/service_streaming_download'
|
5
|
+
require 'rails_band/active_storage/event/service_download_chunk'
|
6
|
+
require 'rails_band/active_storage/event/service_download'
|
7
|
+
require 'rails_band/active_storage/event/service_delete'
|
8
|
+
require 'rails_band/active_storage/event/service_delete_prefixed'
|
9
|
+
require 'rails_band/active_storage/event/service_exist'
|
10
|
+
require 'rails_band/active_storage/event/service_url'
|
11
|
+
require 'rails_band/active_storage/event/service_update_metadata'
|
12
|
+
require 'rails_band/active_storage/event/preview'
|
13
|
+
require 'rails_band/active_storage/event/transform'
|
14
|
+
require 'rails_band/active_storage/event/analyze'
|
15
|
+
|
16
|
+
module RailsBand
|
17
|
+
module ActiveStorage
|
18
|
+
# The custom LogSubscriber for ActiveStorage.
|
19
|
+
class LogSubscriber < ::ActiveSupport::LogSubscriber
|
20
|
+
mattr_accessor :consumers
|
21
|
+
|
22
|
+
def service_upload(event)
|
23
|
+
consumer_of(__method__)&.call(Event::ServiceUpload.new(event))
|
24
|
+
end
|
25
|
+
|
26
|
+
def service_streaming_download(event)
|
27
|
+
consumer_of(__method__)&.call(Event::ServiceStreamingDownload.new(event))
|
28
|
+
end
|
29
|
+
|
30
|
+
def service_download_chunk(event)
|
31
|
+
consumer_of(__method__)&.call(Event::ServiceDownloadChunk.new(event))
|
32
|
+
end
|
33
|
+
|
34
|
+
def service_download(event)
|
35
|
+
consumer_of(__method__)&.call(Event::ServiceDownload.new(event))
|
36
|
+
end
|
37
|
+
|
38
|
+
def service_delete(event)
|
39
|
+
consumer_of(__method__)&.call(Event::ServiceDelete.new(event))
|
40
|
+
end
|
41
|
+
|
42
|
+
def service_delete_prefixed(event)
|
43
|
+
consumer_of(__method__)&.call(Event::ServiceDeletePrefixed.new(event))
|
44
|
+
end
|
45
|
+
|
46
|
+
def service_exist(event)
|
47
|
+
consumer_of(__method__)&.call(Event::ServiceExist.new(event))
|
48
|
+
end
|
49
|
+
|
50
|
+
def service_url(event)
|
51
|
+
consumer_of(__method__)&.call(Event::ServiceUrl.new(event))
|
52
|
+
end
|
53
|
+
|
54
|
+
def service_update_metadata(event)
|
55
|
+
consumer_of(__method__)&.call(Event::ServiceUpdateMetadata.new(event))
|
56
|
+
end
|
57
|
+
|
58
|
+
def preview(event)
|
59
|
+
consumer_of(__method__)&.call(Event::Preview.new(event))
|
60
|
+
end
|
61
|
+
|
62
|
+
def transform(event)
|
63
|
+
consumer_of(__method__)&.call(Event::Transform.new(event))
|
64
|
+
end
|
65
|
+
|
66
|
+
def analyze(event)
|
67
|
+
consumer_of(__method__)&.call(Event::Analyze.new(event))
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def consumer_of(sub_event)
|
73
|
+
consumers[:"#{sub_event}.active_storage"] || consumers[:active_storage] || consumers[:default]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/rails_band/railtie.rb
CHANGED
@@ -30,7 +30,26 @@ module RailsBand
|
|
30
30
|
swap.call(::ActionMailer::LogSubscriber, RailsBand::ActionMailer::LogSubscriber, :action_mailer)
|
31
31
|
end
|
32
32
|
|
33
|
+
if defined?(::ActionCable)
|
34
|
+
RailsBand::ActionCable::LogSubscriber.attach_to :action_cable
|
35
|
+
end
|
36
|
+
|
37
|
+
if defined?(::ActiveStorage)
|
38
|
+
RailsBand::ActiveStorage::LogSubscriber.attach_to :active_storage
|
39
|
+
end
|
40
|
+
|
33
41
|
RailsBand::ActiveSupport::LogSubscriber.attach_to :active_support
|
42
|
+
|
43
|
+
if defined?(::ActiveJob)
|
44
|
+
require 'active_job/logging'
|
45
|
+
|
46
|
+
if defined?(::ActiveJob::Logging::LogSubscriber)
|
47
|
+
swap.call(::ActiveJob::Logging::LogSubscriber, RailsBand::ActiveJob::LogSubscriber, :active_job)
|
48
|
+
else
|
49
|
+
require 'active_job/log_subscriber'
|
50
|
+
swap.call(::ActiveJob::LogSubscriber, RailsBand::ActiveJob::LogSubscriber, :active_job)
|
51
|
+
end
|
52
|
+
end
|
34
53
|
end
|
35
54
|
end
|
36
55
|
end
|
data/lib/rails_band/version.rb
CHANGED
data/lib/rails_band.rb
CHANGED
@@ -27,4 +27,16 @@ module RailsBand
|
|
27
27
|
module ActiveSupport
|
28
28
|
autoload :LogSubscriber, 'rails_band/active_support/log_subscriber'
|
29
29
|
end
|
30
|
+
|
31
|
+
module ActiveJob
|
32
|
+
autoload :LogSubscriber, 'rails_band/active_job/log_subscriber'
|
33
|
+
end
|
34
|
+
|
35
|
+
module ActionCable
|
36
|
+
autoload :LogSubscriber, 'rails_band/action_cable/log_subscriber'
|
37
|
+
end
|
38
|
+
|
39
|
+
module ActiveStorage
|
40
|
+
autoload :LogSubscriber, 'rails_band/active_storage/log_subscriber'
|
41
|
+
end
|
30
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_band
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yutaka Kamei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '6.0'
|
20
|
+
- - "!="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 7.0.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '6.0'
|
30
|
+
- - "!="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 7.0.0
|
27
33
|
description: A Rails plugin to facilitate the use of Rails Instrumentation API.
|
28
34
|
email:
|
29
35
|
- kamei@yykamei.me
|
@@ -35,6 +41,12 @@ files:
|
|
35
41
|
- README.md
|
36
42
|
- Rakefile
|
37
43
|
- lib/rails_band.rb
|
44
|
+
- lib/rails_band/action_cable/event/broadcast.rb
|
45
|
+
- lib/rails_band/action_cable/event/perform_action.rb
|
46
|
+
- lib/rails_band/action_cable/event/transmit.rb
|
47
|
+
- lib/rails_band/action_cable/event/transmit_subscription_confirmation.rb
|
48
|
+
- lib/rails_band/action_cable/event/transmit_subscription_rejection.rb
|
49
|
+
- lib/rails_band/action_cable/log_subscriber.rb
|
38
50
|
- lib/rails_band/action_controller/event/exist_fragment.rb
|
39
51
|
- lib/rails_band/action_controller/event/expire_fragment.rb
|
40
52
|
- lib/rails_band/action_controller/event/halted_callback.rb
|
@@ -55,10 +67,31 @@ files:
|
|
55
67
|
- lib/rails_band/action_view/event/render_template.rb
|
56
68
|
- lib/rails_band/action_view/from_views.rb
|
57
69
|
- lib/rails_band/action_view/log_subscriber.rb
|
70
|
+
- lib/rails_band/active_job/event/discard.rb
|
71
|
+
- lib/rails_band/active_job/event/enqueue.rb
|
72
|
+
- lib/rails_band/active_job/event/enqueue_at.rb
|
73
|
+
- lib/rails_band/active_job/event/enqueue_retry.rb
|
74
|
+
- lib/rails_band/active_job/event/perform.rb
|
75
|
+
- lib/rails_band/active_job/event/perform_start.rb
|
76
|
+
- lib/rails_band/active_job/event/retry_stopped.rb
|
77
|
+
- lib/rails_band/active_job/log_subscriber.rb
|
58
78
|
- lib/rails_band/active_record/event/instantiation.rb
|
59
79
|
- lib/rails_band/active_record/event/sql.rb
|
60
80
|
- lib/rails_band/active_record/event/strict_loading_violation.rb
|
61
81
|
- lib/rails_band/active_record/log_subscriber.rb
|
82
|
+
- lib/rails_band/active_storage/event/analyze.rb
|
83
|
+
- lib/rails_band/active_storage/event/preview.rb
|
84
|
+
- lib/rails_band/active_storage/event/service_delete.rb
|
85
|
+
- lib/rails_band/active_storage/event/service_delete_prefixed.rb
|
86
|
+
- lib/rails_band/active_storage/event/service_download.rb
|
87
|
+
- lib/rails_band/active_storage/event/service_download_chunk.rb
|
88
|
+
- lib/rails_band/active_storage/event/service_exist.rb
|
89
|
+
- lib/rails_band/active_storage/event/service_streaming_download.rb
|
90
|
+
- lib/rails_band/active_storage/event/service_update_metadata.rb
|
91
|
+
- lib/rails_band/active_storage/event/service_upload.rb
|
92
|
+
- lib/rails_band/active_storage/event/service_url.rb
|
93
|
+
- lib/rails_band/active_storage/event/transform.rb
|
94
|
+
- lib/rails_band/active_storage/log_subscriber.rb
|
62
95
|
- lib/rails_band/active_support/event/cache_delete.rb
|
63
96
|
- lib/rails_band/active_support/event/cache_delete_multi.rb
|
64
97
|
- lib/rails_band/active_support/event/cache_exist.rb
|
@@ -95,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
128
|
- !ruby/object:Gem::Version
|
96
129
|
version: '0'
|
97
130
|
requirements: []
|
98
|
-
rubygems_version: 3.
|
131
|
+
rubygems_version: 3.3.7
|
99
132
|
signing_key:
|
100
133
|
specification_version: 4
|
101
134
|
summary: Easy-to-use Rails Instrumentation API
|