Add response time to tx log
This commit is contained in:
parent
b37073592b
commit
a1f014730e
|
@ -683,7 +683,7 @@ public class ClientUtils {
|
|||
for (Header h : response.getAllHeaders()) {
|
||||
headers.add(h.toString());
|
||||
}
|
||||
logger.logResponse(response.getStatusLine().toString(), headers, cnt);
|
||||
logger.logResponse(response.getStatusLine().toString(), headers, cnt, 0);
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
|
|
@ -625,7 +625,7 @@ public class ClientUtils {
|
|||
for (Header h : response.getAllHeaders()) {
|
||||
headers.add(h.toString());
|
||||
}
|
||||
logger.logResponse(response.getStatusLine().toString(), headers, cnt);
|
||||
logger.logResponse(response.getStatusLine().toString(), headers, cnt, 0);
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
|
|
@ -371,7 +371,7 @@ public class FhirRequestBuilder {
|
|||
|
||||
try {
|
||||
if (logger != null) {
|
||||
logger.logResponse(Integer.toString(responseCode), headerList, responseBody);
|
||||
logger.logResponse(Integer.toString(responseCode), headerList, responseBody, 0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error parsing response body passed in to logger ->\n" + e.getLocalizedMessage());
|
||||
|
|
|
@ -95,13 +95,13 @@ public class FhirRequestBuilderTests {
|
|||
Mockito.doReturn(parser).when(fhirRequestBuilder).getParser(ArgumentMatchers.eq("json"));
|
||||
|
||||
fhirRequestBuilder.unmarshalReference(response, "json");
|
||||
Mockito.verify(logger).logResponse(ArgumentMatchers.eq("200"), ArgumentMatchers.anyList(), AdditionalMatchers.aryEq(RESPONSE_BODY_STRING.getBytes()));
|
||||
Mockito.verify(logger).logResponse(ArgumentMatchers.eq("200"), ArgumentMatchers.anyList(), AdditionalMatchers.aryEq(RESPONSE_BODY_STRING.getBytes()), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnmarshallFeedLogging() {
|
||||
fhirRequestBuilder.unmarshalFeed(response, "application/json");
|
||||
Mockito.verify(logger).logResponse(ArgumentMatchers.eq("200"), ArgumentMatchers.anyList(), AdditionalMatchers.aryEq(RESPONSE_BODY_STRING.getBytes()));
|
||||
Mockito.verify(logger).logResponse(ArgumentMatchers.eq("200"), ArgumentMatchers.anyList(), AdditionalMatchers.aryEq(RESPONSE_BODY_STRING.getBytes()), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class HTMLClientLogger implements ToolingClientLogger {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void logResponse(String outcome, List<String> headers, byte[] body) {
|
||||
public void logResponse(String outcome, List<String> headers, byte[] body, long start) {
|
||||
if (file == null)
|
||||
return;
|
||||
file.println("<pre>");
|
||||
|
|
|
@ -64,7 +64,7 @@ public class FhirLoggingInterceptor implements Interceptor {
|
|||
headerMap.keySet().forEach(key -> headerMap.get(key).forEach(value -> headerList.add(key + ":" + value)));
|
||||
|
||||
if (logger != null) {
|
||||
logger.logResponse(Integer.toString(response.code()), headerList, bodyBytes);
|
||||
logger.logResponse(Integer.toString(response.code()), headerList, bodyBytes, 0);
|
||||
}
|
||||
|
||||
// Reading byte[] clears body. Need to recreate.
|
||||
|
|
|
@ -85,7 +85,7 @@ public class HTMLClientLogger extends BaseLogger implements ToolingClientLogger
|
|||
}
|
||||
|
||||
@Override
|
||||
public void logResponse(String outcome, List<String> headers, byte[] body) {
|
||||
public void logResponse(String outcome, List<String> headers, byte[] body, long start) {
|
||||
if (DEBUG) {
|
||||
System.out.println(" txlog resp: " + outcome + " " + present(body));
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class TextClientLogger extends BaseLogger implements ToolingClientLogger
|
|||
}
|
||||
|
||||
@Override
|
||||
public void logResponse(String outcome, List<String> headers, byte[] body) {
|
||||
public void logResponse(String outcome, List<String> headers, byte[] body, long start) {
|
||||
if (file == null)
|
||||
return;
|
||||
file.println("\r\n\r\nResponse: \r\n");
|
||||
|
|
|
@ -59,7 +59,7 @@ public class FhirLoggingInterceptor implements Interceptor {
|
|||
headerMap.keySet().forEach(key -> headerMap.get(key).forEach(value -> headerList.add(key + ":" + value)));
|
||||
|
||||
if (logger != null) {
|
||||
logger.logResponse(Integer.toString(response.code()), headerList, bodyBytes);
|
||||
logger.logResponse(Integer.toString(response.code()), headerList, bodyBytes, 0);
|
||||
}
|
||||
|
||||
// Reading byte[] clears body. Need to recreate.
|
||||
|
|
|
@ -134,6 +134,6 @@ class ClientTest {
|
|||
server.takeRequest();
|
||||
Mockito.verify(mockLogger, Mockito.times(1)).logRequest(Mockito.anyString(), Mockito.anyString(), Mockito.anyList(),
|
||||
Mockito.any());
|
||||
Mockito.verify(mockLogger, Mockito.times(1)).logResponse(Mockito.anyString(), Mockito.anyList(), Mockito.any());
|
||||
Mockito.verify(mockLogger, Mockito.times(1)).logResponse(Mockito.anyString(), Mockito.anyList(), Mockito.any(), 0);
|
||||
}
|
||||
}
|
|
@ -87,7 +87,7 @@ public class HTMLClientLogger extends BaseLogger implements ToolingClientLogger
|
|||
}
|
||||
|
||||
@Override
|
||||
public void logResponse(String outcome, List<String> headers, byte[] body) {
|
||||
public void logResponse(String outcome, List<String> headers, byte[] body, long start) {
|
||||
if (DEBUG) {
|
||||
System.out.println(" txlog resp: " +outcome+" "+present(body));
|
||||
}
|
||||
|
|
|
@ -76,10 +76,10 @@ public class TextClientLogger extends BaseLogger implements ToolingClientLogger
|
|||
}
|
||||
|
||||
@Override
|
||||
public void logResponse(String outcome, List<String> headers, byte[] body) {
|
||||
public void logResponse(String outcome, List<String> headers, byte[] body, long length) {
|
||||
if (file == null)
|
||||
return;
|
||||
file.println("\r\n\r\nResponse: \r\n");
|
||||
file.println("\r\n\r\nResponse ("+Utilities.describeDuration(length)+"): \r\n");
|
||||
file.println(outcome);
|
||||
for (String s : headers)
|
||||
file.println(s);
|
||||
|
|
|
@ -59,7 +59,8 @@ public class FhirLoggingInterceptor implements Interceptor {
|
|||
headerMap.keySet().forEach(key -> headerMap.get(key).forEach(value -> headerList.add(key + ":" + value)));
|
||||
|
||||
if (logger != null) {
|
||||
logger.logResponse(Integer.toString(response.code()), headerList, bodyBytes);
|
||||
long responseTimeInMillis = response.receivedResponseAtMillis() - response.sentRequestAtMillis();
|
||||
logger.logResponse(Integer.toString(response.code()), headerList, bodyBytes, responseTimeInMillis);
|
||||
}
|
||||
|
||||
// Reading byte[] clears body. Need to recreate.
|
||||
|
|
|
@ -172,6 +172,6 @@ class ClientTest {
|
|||
Mockito.verify(mockLogger, Mockito.times(1))
|
||||
.logRequest(Mockito.anyString(), Mockito.anyString(), Mockito.anyList(), Mockito.any());
|
||||
Mockito.verify(mockLogger, Mockito.times(1))
|
||||
.logResponse(Mockito.anyString(), Mockito.anyList(), Mockito.any());
|
||||
.logResponse(Mockito.anyString(), Mockito.anyList(), Mockito.any(), Mockito.anyLong());
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@ import java.util.List;
|
|||
public interface ToolingClientLogger {
|
||||
|
||||
void logRequest(String method, String url, List<String> headers, byte[] body);
|
||||
void logResponse(String outcome, List<String> headers, byte[] body);
|
||||
void logResponse(String outcome, List<String> headers, byte[] body, long length);
|
||||
String getLastId();
|
||||
void clearLastId();
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public class CacheVerificationLogger implements ToolingClientLogger {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void logResponse(String outcome, List<String> headers, byte[] body) {
|
||||
public void logResponse(String outcome, List<String> headers, byte[] body, long start) {
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue