def measure_method(index:,
                       level:,
                       message:,
                       min_duration:,
                       metric:,
                       log_exception:,
                       on_exception_level:)

      # Ignores filter, silence, payload
      exception = nil
      start     = Process.clock_gettime(Process::CLOCK_MONOTONIC)
      begin
        yield
      rescue Exception => exc
        exception = exc
      ensure
        log = Log.new(name, level, index)
        # May return false due to elastic logging
        should_log = log.assign(
          message:            message,
          min_duration:       min_duration,
          exception:          exception,
          metric:             metric,
          duration:           1_000.0 * (Process.clock_gettime(Process::CLOCK_MONOTONIC) - start),
          log_exception:      log_exception,
          on_exception_level: on_exception_level
        )

        # Log level may change during assign due to :on_exception_level
        log(log) if should_log && should_log?(log)
        raise exception if exception
      end
    end
def measure_method(index:,
                       level:,
                       message:,
                       min_duration:,
                       metric:,
                       log_exception:,
                       on_exception_level:)

      # Ignores filter, silence, payload
      exception = nil
      start     = Process.clock_gettime(Process::CLOCK_MONOTONIC)
      begin
        yield
      rescue Exception => exc
        exception = exc
      ensure
        log = Log.new(name, level, index)
        # May return false due to elastic logging
        should_log = log.assign(
          message:            message,
          min_duration:       min_duration,
          exception:          exception,
          metric:             metric,
          duration:           1_000.0 * (Process.clock_gettime(Process::CLOCK_MONOTONIC) - start),
          log_exception:      log_exception,
          on_exception_level: on_exception_level
        )

        # Log level may change during assign due to :on_exception_level
        log(log) if should_log && should_log?(log)
        raise exception if exception
      end
    end
For measuring methods and logging their duration.