Search in sources :

Example 16 with RequestTraceSpan

use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.

the class FallbackPolicy method fallback.

/**
 * Performs the fallback operation defined by the @Fallback annotation.
 * @param invocationContext The failing invocation context
 * @return The result of the executed fallback method
 * @throws Exception If the fallback method itself fails.
 */
public Object fallback(InvocationContext invocationContext) throws Exception {
    Object fallbackInvocationContext = null;
    FaultToleranceService faultToleranceService = Globals.getDefaultBaseServiceLocator().getService(FaultToleranceService.class);
    InvocationManager invocationManager = Globals.getDefaultBaseServiceLocator().getService(InvocationManager.class);
    faultToleranceService.startFaultToleranceSpan(new RequestTraceSpan("executeFallbackMethod"), invocationManager, invocationContext);
    try {
        if (fallbackMethod != null && !fallbackMethod.isEmpty()) {
            logger.log(Level.FINE, "Using fallback method: {0}", fallbackMethod);
            fallbackInvocationContext = invocationContext.getMethod().getDeclaringClass().getDeclaredMethod(fallbackMethod, invocationContext.getMethod().getParameterTypes()).invoke(invocationContext.getTarget(), invocationContext.getParameters());
        } else {
            logger.log(Level.FINE, "Using fallback class: {0}", fallbackClass.getName());
            ExecutionContext executionContext = new FaultToleranceExecutionContext(invocationContext.getMethod(), invocationContext.getParameters());
            fallbackInvocationContext = fallbackClass.getDeclaredMethod(FALLBACK_HANDLER_METHOD_NAME, ExecutionContext.class).invoke(CDI.current().select(fallbackClass).get(), executionContext);
        }
    } finally {
        faultToleranceService.endFaultToleranceSpan();
    }
    return fallbackInvocationContext;
}
Also used : ExecutionContext(org.eclipse.microprofile.faulttolerance.ExecutionContext) InvocationManager(org.glassfish.api.invocation.InvocationManager) RequestTraceSpan(fish.payara.notification.requesttracing.RequestTraceSpan) FaultToleranceService(fish.payara.microprofile.faulttolerance.FaultToleranceService)

Example 17 with RequestTraceSpan

use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.

the class RequestTracingCdiInterceptor method traceCdiCall.

@AroundInvoke
public Object traceCdiCall(InvocationContext ctx) throws Exception {
    RequestTracingService requestTracing = Globals.getDefaultHabitat().getService(RequestTracingService.class);
    Object proceed = null;
    if (requestTracing != null && requestTracing.isRequestTracingEnabled()) {
        RequestTraceSpan span = new RequestTraceSpan("executeCdiMethod");
        span.addSpanTag("TargetClass", ctx.getTarget().getClass().getName());
        span.addSpanTag("MethodName", ctx.getMethod().getName());
        proceed = ctx.proceed();
        requestTracing.traceSpan(span);
    } else {
        proceed = ctx.proceed();
    }
    return proceed;
}
Also used : RequestTraceSpan(fish.payara.notification.requesttracing.RequestTraceSpan) RequestTracingService(fish.payara.nucleus.requesttracing.RequestTracingService) AroundInvoke(javax.interceptor.AroundInvoke)

Example 18 with RequestTraceSpan

use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.

the class EjbWebServiceServlet method constructWsRequestSpan.

private RequestTraceSpan constructWsRequestSpan(HttpServletRequest httpServletRequest, EjbRuntimeEndpointInfo ejbEndpoint) {
    RequestTraceSpan span = new RequestTraceSpan("processSoapWebserviceRequest");
    span.addSpanTag("URI", ejbEndpoint.getEndpoint().getEndpointAddressUri());
    span.addSpanTag("URL", httpServletRequest.getRequestURL().toString());
    Enumeration<String> headerNames = httpServletRequest.getHeaderNames();
    while (headerNames.hasMoreElements()) {
        String headerName = headerNames.nextElement();
        List<String> headers = Collections.list(httpServletRequest.getHeaders(headerName));
        span.addSpanTag(headerName, headers.toString());
    }
    span.addSpanTag("Method", httpServletRequest.getMethod());
    return span;
}
Also used : RequestTraceSpan(fish.payara.notification.requesttracing.RequestTraceSpan)

Example 19 with RequestTraceSpan

use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.

the class JAXWSServlet method doPost.

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    startedEvent(endpoint.getEndpointAddressPath());
    if (("Tester".equalsIgnoreCase(request.getQueryString())) && (!(HTTPBinding.HTTP_BINDING.equals(endpoint.getProtocolBinding())))) {
        Endpoint endpt = wsEngine_.getEndpoint(request.getServletPath());
        if (endpt != null && Boolean.parseBoolean(endpt.getDescriptor().getDebugging())) {
            WebServiceTesterServlet.invoke(request, response, endpt.getDescriptor());
            endedEvent(endpoint.getEndpointAddressPath());
            return;
        }
    }
    // lookup registered URLs and get the appropriate adapter;
    // pass control to the adapter
    RequestTraceSpan span = null;
    try {
        ServletAdapter targetEndpoint = (ServletAdapter) getEndpointFor(request);
        if (targetEndpoint != null) {
            if (requestTracing.isRequestTracingEnabled()) {
                span = constructWsRequestSpan(request, targetEndpoint.getAddress());
            }
            targetEndpoint.handle(getServletContext(), request, response);
        } else {
            throw new ServletException("Service not found");
        }
    } catch (Throwable t) {
        ServletException se = new ServletException();
        se.initCause(t);
        throw se;
    } finally {
        if (requestTracing.isRequestTracingEnabled() && span != null) {
            requestTracing.traceSpan(span);
        }
    }
    endedEvent(endpoint.getEndpointAddressPath());
}
Also used : ServletException(javax.servlet.ServletException) ServletAdapter(com.sun.xml.ws.transport.http.servlet.ServletAdapter) Endpoint(org.glassfish.webservices.monitoring.Endpoint) RequestTraceSpan(fish.payara.notification.requesttracing.RequestTraceSpan)

Example 20 with RequestTraceSpan

use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.

the class RequestTracingService method startTrace.

/**
 * Starts a new request trace
 * @return a unique identifier for the request trace
 */
public UUID startTrace(String traceName) {
    if (!isRequestTracingEnabled()) {
        return null;
    }
    // Check if the trace came from an admin listener. If it did, and 'applications only' is enabled, ignore the trace.
    if (executionOptions.getApplicationsOnlyEnabled() == true && Thread.currentThread().getName().matches("admin-thread-pool::admin-listener\\([0-9]+\\)")) {
        return null;
    }
    // Determine whether to sample the request, if sampleRateFirstEnabled is true
    if (executionOptions.getSampleRateFirstEnabled()) {
        if (!sampleFilter.sample()) {
            return null;
        }
    }
    RequestTraceSpan span = new RequestTraceSpan(EventType.TRACE_START, traceName);
    span.addSpanTag("Server", server.getName());
    span.addSpanTag("Domain", domain.getName());
    requestEventStore.storeEvent(span);
    return span.getId();
}
Also used : RequestTraceSpan(fish.payara.notification.requesttracing.RequestTraceSpan)

Aggregations

RequestTraceSpan (fish.payara.notification.requesttracing.RequestTraceSpan)30 Test (org.junit.Test)13 FaultToleranceService (fish.payara.microprofile.faulttolerance.FaultToleranceService)3 RequestTrace (fish.payara.notification.requesttracing.RequestTrace)3 UUID (java.util.UUID)3 InvocationManager (org.glassfish.api.invocation.InvocationManager)3 Principal (java.security.Principal)2 ServletException (javax.servlet.ServletException)2 Config (org.eclipse.microprofile.config.Config)2 Endpoint (org.glassfish.webservices.monitoring.Endpoint)2 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)1 WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)1 SecurityContext (com.sun.enterprise.security.SecurityContext)1 WebPrincipal (com.sun.enterprise.security.web.integration.WebPrincipal)1 ServletAdapter (com.sun.xml.ws.transport.http.servlet.ServletAdapter)1 RequestTracingService (fish.payara.nucleus.requesttracing.RequestTracingService)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 URL (java.net.URL)1 ChronoUnit (java.time.temporal.ChronoUnit)1