Skip to content

Commit

Permalink
SLING-5459 - Recording of tracer logs
Browse files Browse the repository at this point in the history
Tracer servlet would now send a protocol version version against header 'Sling-Tracer-Protocol-Version'. For now its value is 1. This would allow client to determine if they can work against this server or not

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1728082 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
chetanmeh committed Feb 2, 2016
1 parent 2127500 commit 54886fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -46,6 +46,10 @@ class TracerLogServlet extends SimpleWebConsolePlugin implements TraceLogRecorde

public static final String HEADER_TRACER_REQUEST_ID = "Sling-Tracer-Request-Id";

public static final String HEADER_TRACER_PROTOCOL_VERSION = "Sling-Tracer-Protocol-Version";

public static final int TRACER_PROTOCOL_VERSION = 1;

private final Cache<String, JSONRecording> cache;

public TracerLogServlet(BundleContext context) {
Expand Down Expand Up @@ -161,8 +165,8 @@ public Recording startRecording(HttpServletRequest request, HttpServletResponse
request.setAttribute(ATTR_REQUEST_ID, requestId);

response.setHeader(HEADER_TRACER_REQUEST_ID, requestId);
//TODO Show we also sent tracer version to enable client determine
//is server is capable of given version
response.setHeader(HEADER_TRACER_PROTOCOL_VERSION, String.valueOf(TRACER_PROTOCOL_VERSION));

return recording;
}

Expand Down
Expand Up @@ -98,6 +98,8 @@ public void jsonRendering() throws Exception{

ArgumentCaptor<String> requestIdCaptor = ArgumentCaptor.forClass(String.class);
verify(response).setHeader(eq(TracerLogServlet.HEADER_TRACER_REQUEST_ID), requestIdCaptor.capture());
verify(response).setHeader(TracerLogServlet.HEADER_TRACER_PROTOCOL_VERSION,
String.valueOf(TracerLogServlet.TRACER_PROTOCOL_VERSION));

StringWriter sw = new StringWriter();
when(response.getWriter()).thenReturn(new PrintWriter(sw));
Expand Down

0 comments on commit 54886fc

Please sign in to comment.