Class: Datadog::Notifications::Plugins::Grape
- Defined in:
- lib/datadog/notifications/plugins/grape.rb
Constant Summary collapse
- DEFAULT_EXCEPTION_HANDLER =
->(e) { Grape.exception_status(e) }
Instance Attribute Summary collapse
-
#exception_handler ⇒ Object
readonly
Returns the value of attribute exception_handler.
-
#metric_name ⇒ Object
readonly
Returns the value of attribute metric_name.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(metric_name: 'grape.request', exception_handler: DEFAULT_EXCEPTION_HANDLER, **opts) ⇒ Grape
constructor
Options:.
Constructor Details
#initialize(metric_name: 'grape.request', exception_handler: DEFAULT_EXCEPTION_HANDLER, **opts) ⇒ Grape
Options:
*:metric_name
- the metric name, defaults to “grape.request” *:exception_handler
- a custom exception handler proc which accepts an exception object and returns a status *:tags
- additional tags
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/datadog/notifications/plugins/grape.rb', line 16 def initialize(metric_name: 'grape.request', exception_handler: DEFAULT_EXCEPTION_HANDLER, **opts) super @metric_name = metric_name @exception_handler = exception_handler Datadog::Notifications.subscribe 'endpoint_run.grape' do |reporter, event| record reporter, event end end |
Instance Attribute Details
#exception_handler ⇒ Object (readonly)
Returns the value of attribute exception_handler.
9 10 11 |
# File 'lib/datadog/notifications/plugins/grape.rb', line 9 def exception_handler @exception_handler end |
#metric_name ⇒ Object (readonly)
Returns the value of attribute metric_name.
9 10 11 |
# File 'lib/datadog/notifications/plugins/grape.rb', line 9 def metric_name @metric_name end |
Class Method Details
.exception_status(err) ⇒ Object
5 6 7 |
# File 'lib/datadog/notifications/plugins/grape.rb', line 5 def self.exception_status(err) err.respond_to?(:status) ? err.status : 500 end |