Class: OpenTelemetry::Instrumentation::ActionPack::Handlers::ActionController
- Inherits:
-
Object
- Object
- OpenTelemetry::Instrumentation::ActionPack::Handlers::ActionController
- Defined in:
- lib/opentelemetry/instrumentation/action_pack/handlers/action_controller.rb
Overview
Action Controller handler to handle the notification from Active Support
Instance Method Summary collapse
-
#finish(_name, _id, payload) ⇒ Hash
Invoked by ActiveSupport::Notifications at the end of the instrumentation block.
-
#initialize(config) ⇒ ActionController
constructor
A new instance of ActionController.
-
#start(_name, _id, payload) ⇒ Hash
Invoked by ActiveSupport::Notifications at the start of the instrumentation block.
Constructor Details
#initialize(config) ⇒ ActionController
Returns a new instance of ActionController.
14 15 16 17 |
# File 'lib/opentelemetry/instrumentation/action_pack/handlers/action_controller.rb', line 14 def initialize(config) @config = config @span_naming = config.fetch(:span_naming) end |
Instance Method Details
#finish(_name, _id, payload) ⇒ Hash
Invoked by ActiveSupport::Notifications at the end of the instrumentation block
41 42 43 44 45 46 |
# File 'lib/opentelemetry/instrumentation/action_pack/handlers/action_controller.rb', line 41 def finish(_name, _id, payload) span = OpenTelemetry::Instrumentation::Rack.current_span span.record_exception(payload[:exception_object]) if payload[:exception_object] rescue StandardError => e OpenTelemetry.handle_error(exception: e) end |
#start(_name, _id, payload) ⇒ Hash
Invoked by ActiveSupport::Notifications at the start of the instrumentation block
25 26 27 28 29 30 31 32 33 |
# File 'lib/opentelemetry/instrumentation/action_pack/handlers/action_controller.rb', line 25 def start(_name, _id, payload) span_name, attributes = to_span_name_and_attributes(payload) span = OpenTelemetry::Instrumentation::Rack.current_span span.name = span_name span.add_attributes(attributes) rescue StandardError => e OpenTelemetry.handle_error(exception: e) end |