def report_metrics(payload)
      unless @discovered
        ::Instana.logger.debug("#{__method__} called but discovery hasn't run yet!")
        return false
      end

      path = "com.instana.plugin.ruby.#{@process[:report_pid]}"
      uri = URI.parse("http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/#{path}")
      req = Net::HTTP::Post.new(uri)

      req.body = Oj.dump(payload, OJ_OPTIONS)
      response = make_host_agent_request(req)

      if response
        if response.body && response.body.length > 2
          # The host agent returned something indicating that is has a request for us that we
          # need to process.
          handle_agent_tasks(response.body)
        end

        if response.code.to_i == 200
          @entity_last_seen = Time.now
          return true
        end

      end
      false
    rescue => e
      Instana.logger.debug "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
      Instana.logger.debug e.backtrace.join("\r\n")
    end
def report_metrics(payload)
      unless @discovered
        ::Instana.logger.debug("#{__method__} called but discovery hasn't run yet!")
        return false
      end

      path = "com.instana.plugin.ruby.#{@process[:report_pid]}"
      uri = URI.parse("http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/#{path}")
      req = Net::HTTP::Post.new(uri)

      req.body = Oj.dump(payload, OJ_OPTIONS)
      response = make_host_agent_request(req)

      if response
        if response.body && response.body.length > 2
          # The host agent returned something indicating that is has a request for us that we
          # need to process.
          handle_agent_tasks(response.body)
        end

        if response.code.to_i == 200
          @entity_last_seen = Time.now
          return true
        end

      end
      false
    rescue => e
      Instana.logger.debug "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
      Instana.logger.debug e.backtrace.join("\r\n")
    end
Method to report metrics data to the host agent.

 @param paylod [Hash] The collection of metrics to report.

 @return [Boolean] true on success, false otherwise