Class OkHttpPoster

  • All Implemented Interfaces:
    com.newrelic.telemetry.http.HttpPoster

    public class OkHttpPoster
    extends java.lang.Object
    implements com.newrelic.telemetry.http.HttpPoster
    Implementation of the HttpPoster interface using an OkHttp client.
    • Constructor Summary

      Constructors 
      Constructor Description
      OkHttpPoster()
      Create an OkHttpPoster with a default OkHttpClient, and a connect timeout of 2 seconds.
      OkHttpPoster​(java.time.Duration callTimeout)
      Create an OkHttpPoster with a default OkHttpClient, with only a custom http timeout.
      OkHttpPoster​(okhttp3.OkHttpClient client)
      Create an OkHttpPoster with your own OkHttpClient implementation.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static com.newrelic.telemetry.EventBatchSenderFactory eventSenderFactory()  
      static com.newrelic.telemetry.MetricBatchSenderFactory metricSenderFactory()  
      com.newrelic.telemetry.http.HttpResponse post​(java.net.URL url, java.util.Map<java.lang.String,​java.lang.String> headers, byte[] body, java.lang.String mediaType)  
      static com.newrelic.telemetry.SpanBatchSenderFactory spanSenderFactory()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OkHttpPoster

        public OkHttpPoster()
        Create an OkHttpPoster with a default OkHttpClient, and a connect timeout of 2 seconds.
      • OkHttpPoster

        public OkHttpPoster​(java.time.Duration callTimeout)
        Create an OkHttpPoster with a default OkHttpClient, with only a custom http timeout.
        Parameters:
        callTimeout - expected call timeout
      • OkHttpPoster

        public OkHttpPoster​(okhttp3.OkHttpClient client)
        Create an OkHttpPoster with your own OkHttpClient implementation.
        Parameters:
        client - http client responsible for the http communication
    • Method Detail

      • post

        public com.newrelic.telemetry.http.HttpResponse post​(java.net.URL url,
                                                             java.util.Map<java.lang.String,​java.lang.String> headers,
                                                             byte[] body,
                                                             java.lang.String mediaType)
                                                      throws java.io.IOException
        Specified by:
        post in interface com.newrelic.telemetry.http.HttpPoster
        Throws:
        java.io.IOException
      • metricSenderFactory

        public static com.newrelic.telemetry.MetricBatchSenderFactory metricSenderFactory()
      • spanSenderFactory

        public static com.newrelic.telemetry.SpanBatchSenderFactory spanSenderFactory()
      • eventSenderFactory

        public static com.newrelic.telemetry.EventBatchSenderFactory eventSenderFactory()