use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.
the class RequestTraceTest method testStarting.
@Test
public void testStarting() {
assertFalse(trace.isStarted());
RequestTraceSpan re = new RequestTraceSpan(EventType.TRACE_START, "StartEvent");
trace.addEvent(re);
assertTrue(trace.isStarted());
assertEquals(1, trace.getTraceSpans().size());
assertTrue(trace.getTraceSpans().contains(re));
}
use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.
the class RequestTraceTest method testEnding.
@Test
public void testEnding() throws InterruptedException {
assertFalse(trace.isStarted());
RequestTraceSpan re = new RequestTraceSpan(EventType.TRACE_START, "StartEvent");
trace.addEvent(re);
assertEquals(0, trace.getElapsedTime());
Thread.sleep(10);
trace.endTrace();
// add one after trace end
re = new RequestTraceSpan("TestEvent");
trace.addEvent(re);
assertTrue(trace.getElapsedTime() > 0);
assertEquals("Trace should not add events after end.", 1, trace.getTraceSpans().size());
}
use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.
the class RequestTraceTest method testAddEventWithoutStarting.
/**
* Test of addEvent method, of class RequestTrace.
*/
@Test
public void testAddEventWithoutStarting() {
trace = new RequestTrace();
RequestTraceSpan re = new RequestTraceSpan("TestEvent");
trace.addEvent(re);
assertFalse(trace.isStarted());
assertFalse(trace.getTraceSpans().contains(this));
assertEquals(0, trace.getTraceSpans().size());
}
use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.
the class StandardWrapper method constructServletRequestSpan.
private RequestTraceSpan constructServletRequestSpan(HttpServletRequest httpServletRequest, Servlet serv) {
RequestTraceSpan span = new RequestTraceSpan("processServletRequest");
span.addSpanTag("URL", httpServletRequest.getRequestURL().toString());
Enumeration<String> headerNames = httpServletRequest.getHeaderNames();
while (headerNames.hasMoreElements()) {
String headerName = headerNames.nextElement();
span.addSpanTag(headerName, list(httpServletRequest.getHeaders(headerName)).toString());
}
span.addSpanTag("Method", httpServletRequest.getMethod());
span.addSpanTag("QueryString", httpServletRequest.getQueryString());
span.addSpanTag("Class", serv.getClass().getCanonicalName());
return span;
}
use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.
the class StandardWrapper method service.
// START IASRI 4665318
/**
* Wrapper for the service method on the actual servlet
* @param request The request sent
* @param response
* @param servlet The servlet to process
* @throws IOException
* @throws ServletException
* @see Servlet#service(ServletRequest, ServletResponse)
*/
void service(ServletRequest request, ServletResponse response, Servlet servlet) throws IOException, ServletException {
InstanceSupport supp = getInstanceSupport();
try {
supp.fireInstanceEvent(BEFORE_SERVICE_EVENT, servlet, request, response);
if (!isAsyncSupported()) {
RequestFacadeHelper reqFacHelper = RequestFacadeHelper.getInstance(request);
if (reqFacHelper != null) {
reqFacHelper.disableAsyncSupport();
}
}
if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
if (SecurityUtil.executeUnderSubjectDoAs()) {
final ServletRequest req = request;
final ServletResponse res = response;
Principal principal = ((HttpServletRequest) req).getUserPrincipal();
Object[] serviceType = new Object[2];
serviceType[0] = req;
serviceType[1] = res;
SecurityUtil.doAsPrivilege("service", servlet, classTypeUsedInService, serviceType, principal);
} else {
RequestTraceSpan span = null;
if (requestTracing.isRequestTracingEnabled()) {
if (servlet instanceof ServletContainer) {
span = constructWebServiceRequestSpan((HttpServletRequest) request);
} else if (servlet instanceof Servlet) {
span = constructServletRequestSpan((HttpServletRequest) request, servlet);
}
}
try {
if (isJspServlet) {
isInSuppressFFNFThread.set(true);
}
servlet.service((HttpServletRequest) request, (HttpServletResponse) response);
} finally {
if (requestTracing.isRequestTracingEnabled() && span != null) {
requestTracing.traceSpan(span);
}
isInSuppressFFNFThread.set(false);
}
}
} else {
servlet.service(request, response);
}
supp.fireInstanceEvent(AFTER_SERVICE_EVENT, servlet, request, response);
} catch (IOException e) {
// Set response status before firing event, see IT 10022
if (response instanceof HttpServletResponse) {
((HttpServletResponse) response).setStatus(SC_INTERNAL_SERVER_ERROR);
}
supp.fireInstanceEvent(AFTER_SERVICE_EVENT, servlet, request, response, e);
throw e;
} catch (ServletException e) {
// Set response status before firing event, see IT 10022
if (response instanceof HttpServletResponse) {
((HttpServletResponse) response).setStatus(SC_INTERNAL_SERVER_ERROR);
}
supp.fireInstanceEvent(AFTER_SERVICE_EVENT, servlet, request, response, e);
throw e;
} catch (RuntimeException e) {
// Set response status before firing event, see IT 10022
if (response instanceof HttpServletResponse) {
((HttpServletResponse) response).setStatus(SC_INTERNAL_SERVER_ERROR);
}
supp.fireInstanceEvent(AFTER_SERVICE_EVENT, servlet, request, response, e);
throw e;
} catch (Error e) {
// Set response status before firing event, see IT 10022
if (response instanceof HttpServletResponse) {
((HttpServletResponse) response).setStatus(SC_INTERNAL_SERVER_ERROR);
}
supp.fireInstanceEvent(AFTER_SERVICE_EVENT, servlet, request, response, e);
throw e;
} catch (Throwable e) {
// Set response status before firing event, see IT 10022
((HttpServletResponse) response).setStatus(SC_INTERNAL_SERVER_ERROR);
supp.fireInstanceEvent(AFTER_SERVICE_EVENT, servlet, request, response, e);
throw new ServletException(rb.getString(SERVLET_EXECUTION_EXCEPTION), e);
}
}
Aggregations