Package com.styra.opa.utils
Class OPALatencyMeasuringHTTPClient
java.lang.Object
com.styra.opa.utils.OPAHTTPClient
com.styra.opa.utils.OPALatencyMeasuringHTTPClient
- All Implemented Interfaces:
HTTPClient
This HTTPClient implementation wraps OPAHTTPClient and has the same
functionality, but also creates log messages indicating the latency for each
request processed.
-
Constructor Summary
ConstructorsConstructorDescriptionOPALatencyMeasuringHTTPClient(Map<String, String> headers) This constructor allows providing additional headers that should be passed to OPAHTTPClient. -
Method Summary
Modifier and TypeMethodDescriptionsend(HttpRequest request) This method implements compatibility with the com.styra.opa.sdk.utils.HTTPClient interface.voidsetLatencyMeasurementFormat(String newFormat) Modify the format in which the latency measurements are logged, the default is "path=''{1}'' latency={0,number,#}ms".voidsetLatencyMeasurementLogLevel(Level newLevel) Modify the log level at which latency measurements are recorded, the default is FINE.
-
Constructor Details
-
OPALatencyMeasuringHTTPClient
public OPALatencyMeasuringHTTPClient() -
OPALatencyMeasuringHTTPClient
This constructor allows providing additional headers that should be passed to OPAHTTPClient.- Parameters:
logger-headers-headers-
-
-
Method Details
-
setLatencyMeasurementFormat
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
Modify the log level at which latency measurements are recorded, the default is FINE.- Parameters:
newLevel-
-
send
public HttpResponse<InputStream> send(HttpRequest request) throws IOException, InterruptedException, URISyntaxException Description copied from class:OPAHTTPClientThis method implements compatibility with the com.styra.opa.sdk.utils.HTTPClient interface.- Specified by:
sendin interfaceHTTPClient- Overrides:
sendin classOPAHTTPClient- Parameters:
request- HTTP request- Returns:
- HTTP response
- Throws:
IOExceptionInterruptedExceptionURISyntaxException
-