class Gruf::Interceptors::Instrumentation::OutputMetadataTimer

Appends the timer metadata to the active call output metadata

Public Instance Methods

call(&block) click to toggle source

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

# 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)
  output_metadata.update(metadata_key => result.elapsed.to_s)

  raise result.message unless result.successful?

  result.message
end

Private Instance Methods

metadata_key() click to toggle source

@return [Symbol] The metadata key that the time result should be set to

# File lib/gruf/interceptors/instrumentation/output_metadata_timer.rb, line 46
def metadata_key
  options.fetch(:metadata_key, :timer).to_sym
end
output_metadata() click to toggle source

@return [Hash]

# File lib/gruf/interceptors/instrumentation/output_metadata_timer.rb, line 53
def output_metadata
  active_call.output_metadata
end