Module: Rails::Instrumentation::ActionControllerSubscriber
- Includes:
- Subscriber
- Defined in:
- lib/rails/instrumentation/subscribers/action_controller_subscriber.rb
Constant Summary collapse
- EVENT_NAMESPACE =
'action_controller'.freeze
- EVENTS =
%w[ write_fragment read_fragment expire_fragment exist_fragment? write_page expire_page start_processing process_action send_file send_data redirect_to halted_callback unpermitted_parameters ].freeze
- BASE_TAGS =
rubocop:disable Style/MutableConstant
{ 'component' => 'ActionController' }
Class Method Summary collapse
- .exist_fragment?(event) ⇒ Boolean
- .expire_fragment(event) ⇒ Object
- .expire_page(event) ⇒ Object
- .halted_callback(event) ⇒ Object
- .process_action(event) ⇒ Object
- .read_fragment(event) ⇒ Object
- .redirect_to(event) ⇒ Object
- .send_data(event) ⇒ Object
- .send_file(event) ⇒ Object
- .start_processing(event) ⇒ Object
- .unpermitted_parameters(event) ⇒ Object
- .write_fragment(event) ⇒ Object
- .write_page(event) ⇒ Object
Methods included from Subscriber
Class Method Details
.exist_fragment?(event) ⇒ Boolean
53 54 55 56 57 58 59 |
# File 'lib/rails/instrumentation/subscribers/action_controller_subscriber.rb', line 53 def exist_fragment?(event) = ( 'key.exist' => event.payload[:key] ) Utils.trace_notification(event: event, tags: ) end |
.expire_fragment(event) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/rails/instrumentation/subscribers/action_controller_subscriber.rb', line 45 def expire_fragment(event) = ( 'key.expire' => event.payload[:key] ) Utils.trace_notification(event: event, tags: ) end |
.expire_page(event) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/rails/instrumentation/subscribers/action_controller_subscriber.rb', line 69 def expire_page(event) = ( 'path.expire' => event.payload[:path] ) Utils.trace_notification(event: event, tags: ) end |
.halted_callback(event) ⇒ Object
145 146 147 148 149 150 151 |
# File 'lib/rails/instrumentation/subscribers/action_controller_subscriber.rb', line 145 def halted_callback(event) = ( 'filter' => event.payload[:filter] ) Utils.trace_notification(event: event, tags: ) end |
.process_action(event) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/rails/instrumentation/subscribers/action_controller_subscriber.rb', line 90 def process_action(event) span_name = "#{event.payload[:controller]}.#{event.payload[:action]}" = ( 'controller' => event.payload[:controller], 'controller.action' => event.payload[:action], 'request.params' => event.payload[:params], 'request.format' => event.payload[:format], 'http.method' => event.payload[:method], 'http.url' => event.payload[:path], 'http.status_code' => event.payload[:status], 'view.runtime.ms' => event.payload[:view_runtime], 'db.runtime.ms' => event.payload[:db_runtime], 'span.kind' => 'server' ) # Only append these tags onto the active span created by the patched 'process_action' # Otherwise, create a new span for this notification as usual active_span = ::Rails::Instrumentation.tracer.active_span if active_span && active_span.operation_name == span_name .each do |key, value| ::Rails::Instrumentation.tracer.active_span.set_tag(key, value) end else Utils.trace_notification(event: event, tags: ) end end |
.read_fragment(event) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/rails/instrumentation/subscribers/action_controller_subscriber.rb', line 37 def read_fragment(event) = ( 'key.read' => event.payload[:key] ) Utils.trace_notification(event: event, tags: ) end |
.redirect_to(event) ⇒ Object
136 137 138 139 140 141 142 143 |
# File 'lib/rails/instrumentation/subscribers/action_controller_subscriber.rb', line 136 def redirect_to(event) = ( 'http.status_code' => event.payload[:status], 'redirect.url' => event.payload[:location] ) Utils.trace_notification(event: event, tags: ) end |
.send_data(event) ⇒ Object
129 130 131 132 133 134 |
# File 'lib/rails/instrumentation/subscribers/action_controller_subscriber.rb', line 129 def send_data(event) # no defined keys, but user keys may be passed in. Might want to add # them at some point Utils.trace_notification(event: event, tags: BASE_TAGS) end |
.send_file(event) ⇒ Object
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/rails/instrumentation/subscribers/action_controller_subscriber.rb', line 118 def send_file(event) = ( 'path.send' => event.payload[:path] ) # there may be additional keys in the payload. It might be worth # trying to tag them too Utils.trace_notification(event: event, tags: ) end |
.start_processing(event) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/rails/instrumentation/subscribers/action_controller_subscriber.rb', line 77 def start_processing(event) = ( 'controller' => event.payload[:controller], 'controller.action' => event.payload[:action], 'request.params' => event.payload[:params], 'request.format' => event.payload[:format], 'http.method' => event.payload[:method], 'http.url' => event.payload[:path] ) Utils.trace_notification(event: event, tags: ) end |
.unpermitted_parameters(event) ⇒ Object
153 154 155 156 157 158 159 |
# File 'lib/rails/instrumentation/subscribers/action_controller_subscriber.rb', line 153 def unpermitted_parameters(event) = ( 'unpermitted_keys' => event.payload[:keys] ) Utils.trace_notification(event: event, tags: ) end |
.write_fragment(event) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/rails/instrumentation/subscribers/action_controller_subscriber.rb', line 29 def write_fragment(event) = ( 'key.write' => event.payload[:key] ) Utils.trace_notification(event: event, tags: ) end |
.write_page(event) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/rails/instrumentation/subscribers/action_controller_subscriber.rb', line 61 def write_page(event) = ( 'path.write' => event.payload[:path] ) Utils.trace_notification(event: event, tags: ) end |