Class: Gruf::Interceptors::Instrumentation::OutputMetadataTimer

Inherits:
ServerInterceptor show all
Defined in:
lib/gruf/interceptors/instrumentation/output_metadata_timer.rb

Overview

Appends the timer metadata to the active call output metadata

Instance Attribute Summary

Attributes inherited from Base

#error, #options, #request

Instance Method Summary collapse

Methods included from Errors::Helpers

#fail!

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Gruf::Interceptors::Base

Instance Method Details

#call(&block) ⇒ Object

Handle the instrumented response. Note: this will only instrument timings of successful responses.



30
31
32
33
34
35
36
37
38
39
# File 'lib/gruf/interceptors/instrumentation/output_metadata_timer.rb', line 30

def call(&block)
  return unless active_call.respond_to?(:output_metadata)

  result = Gruf::Interceptors::Timer.time(&block)
  .update( => result.elapsed.to_s)

  raise result.message unless result.successful?

  result.message
end