Class OPALatencyMeasuringHTTPClient

java.lang.Object
com.styra.opa.utils.OPAHTTPClient
com.styra.opa.utils.OPALatencyMeasuringHTTPClient
All Implemented Interfaces:
HTTPClient

public class OPALatencyMeasuringHTTPClient extends OPAHTTPClient
This HTTPClient implementation wraps OPAHTTPClient and has the same functionality, but also creates log messages indicating the latency for each request processed.
  • Constructor Details

    • OPALatencyMeasuringHTTPClient

      public OPALatencyMeasuringHTTPClient()
    • OPALatencyMeasuringHTTPClient

      public OPALatencyMeasuringHTTPClient(Map<String,String> headers)
      This constructor allows providing additional headers that should be passed to OPAHTTPClient.
      Parameters:
      logger -
      headers -
      headers -
  • Method Details

    • setLatencyMeasurementFormat

      public void setLatencyMeasurementFormat(String newFormat)
      Modify the format in which the latency measurements are logged, the default is "path=''{1}'' latency={0,number,#}ms". The format string should be compatible with java.text.MessageFormat. The {0} argument will contain the measured request latency in ms, and the {1} argument will contain the URL path for the HTTP request.
      Parameters:
      newFormat -
    • setLatencyMeasurementLogLevel

      public void setLatencyMeasurementLogLevel(Level newLevel)
      Modify the log level at which latency measurements are recorded, the default is FINE.
      Parameters:
      newLevel -
    • send

      Description copied from class: OPAHTTPClient
      This method implements compatibility with the com.styra.opa.sdk.utils.HTTPClient interface.
      Specified by:
      send in interface HTTPClient
      Overrides:
      send in class OPAHTTPClient
      Parameters:
      request - HTTP request
      Returns:
      HTTP response
      Throws:
      IOException
      InterruptedException
      URISyntaxException