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

#callObject

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



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

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

  result = Gruf::Interceptors::Timer.time do
    yield
  end
  .update( => result.elapsed.to_s)

  raise result.message unless result.successful?
  result.message
end