class Gruf::Interceptors::Timer::Result

Represents a timed result for an interceptor

@property [Object] message The protobuf message @property [Float] elapsed The elapsed time of the request

Attributes

elapsed[R]
message[R]

Public Class Methods

new(message, elapsed, successful) click to toggle source

@param [Object] message The protobuf message @param [Float] elapsed The elapsed time of the request @param [Boolean] successful If the request was successful

# File lib/gruf/interceptors/timer.rb, line 39
def initialize(message, elapsed, successful)
  @message = message
  @elapsed = elapsed.to_f
  @successful = successful ? true : false
end

Public Instance Methods

elapsed_rounded(precision: 2) click to toggle source

Return the execution time rounded to a specified precision

@param [Integer] precision The amount of decimal places to round to @return [Float] The execution time rounded to the appropriate decimal point

# File lib/gruf/interceptors/timer.rb, line 65
def elapsed_rounded(precision: 2)
  @elapsed.to_f.round(precision)
end
message_class_name() click to toggle source

@return [String] The name of the message class

# File lib/gruf/interceptors/timer.rb, line 55
def message_class_name
  @message.class.name
end
successful?() click to toggle source

@return [Boolean] True if this was a successful request

# File lib/gruf/interceptors/timer.rb, line 48
def successful?
  @successful
end