Search in sources :

Example 6 with RequestTraceSpan

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

the class RealmAdapter method doTraced.

private boolean doTraced(ServerAuthConfig serverAuthConfig, Context context, RequestFacade requestFacade, IOSupplier<Boolean> supplier) throws IOException {
    RequestTraceSpan span = null;
    boolean result;
    try {
        span = new RequestTraceSpan("authenticateJaspic");
        span.addSpanTag("AppContext", serverAuthConfig.getAppContext());
        span.addSpanTag("Context", context.getPath());
        result = supplier.get();
        span.addSpanTag("AuthResult", Boolean.toString(result));
        Principal principal = requestFacade.getPrincipal();
        String principalName = "null";
        if (principal != null) {
            principalName = principal.getName();
        }
        span.addSpanTag("Principal", principalName);
    } finally {
        if (span != null) {
            requestTracing.traceSpan(span);
        }
    }
    return result;
}
Also used : RequestTraceSpan(fish.payara.notification.requesttracing.RequestTraceSpan) WebPrincipal(com.sun.enterprise.security.web.integration.WebPrincipal) Principal(java.security.Principal)

Example 7 with RequestTraceSpan

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

the class MessageBeanListenerImpl method deliverMessage.

@Override
public Object deliverMessage(Object[] params) throws Throwable {
    if (stuckThreadsStore != null) {
        stuckThreadsStore.registerThread(Thread.currentThread().getId());
    }
    RequestTraceSpan span = null;
    if (requestTracing != null && requestTracing.isRequestTracingEnabled()) {
        span = new RequestTraceSpan(EventType.TRACE_START, "deliverMdb");
        span.addSpanTag("MDB Class", container_.getEjbDescriptor().getEjbClassName());
        span.addSpanTag("Message Count", Long.toString(container_.getMessageCount()));
        span.addSpanTag("JNDI", container_.getEjbDescriptor().getJndiName());
        try {
            javax.jms.Message msg = (javax.jms.Message) params[0];
            span.addSpanTag("JMS Type", msg.getJMSType());
            span.addSpanTag("JMS CorrelationID", msg.getJMSCorrelationID());
            span.addSpanTag("JMS MessageID", msg.getJMSMessageID());
            span.addSpanTag("JMS Destination", getDestinationName(msg.getJMSDestination()));
            span.addSpanTag("JMS ReplyTo", getDestinationName(msg.getJMSReplyTo()));
            // check RT conversation ID
            UUID conversationID = (UUID) msg.getObjectProperty("#BAF-CID");
            if (conversationID != null) {
                // reset the conversation ID to match the received ID to
                // propagate the conversation across the message send
                requestTracing.setTraceId(conversationID);
            }
        } catch (ClassCastException cce) {
        }
        requestTracing.startTrace(span);
    }
    try {
        return container_.deliverMessage(params);
    } finally {
        if (requestTracing != null && requestTracing.isRequestTracingEnabled()) {
            requestTracing.endTrace();
        }
        if (stuckThreadsStore != null) {
            stuckThreadsStore.deregisterThread(Thread.currentThread().getId());
        }
    }
}
Also used : RequestTraceSpan(fish.payara.notification.requesttracing.RequestTraceSpan) UUID(java.util.UUID)

Example 8 with RequestTraceSpan

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

the class EjbWebServiceServlet method service.

@Override
protected void service(HttpServletRequest hreq, HttpServletResponse hresp) throws ServletException, IOException {
    String requestUriRaw = hreq.getRequestURI();
    String requestUri = (requestUriRaw.charAt(0) == '/') ? requestUriRaw.substring(1) : requestUriRaw;
    String query = hreq.getQueryString();
    WebServiceEjbEndpointRegistry wsejbEndpointRegistry = (WebServiceEjbEndpointRegistry) Globals.getDefaultHabitat().getService(WSEjbEndpointRegistry.class);
    EjbRuntimeEndpointInfo ejbEndpoint = wsejbEndpointRegistry.getEjbWebServiceEndpoint(requestUri, hreq.getMethod(), query);
    if (requestUri.contains(WebServiceEndpoint.PUBLISHING_SUBCONTEXT) && ejbEndpoint == null) {
        requestUri = requestUri.substring(0, requestUri.indexOf(WebServiceEndpoint.PUBLISHING_SUBCONTEXT) - 1);
        ejbEndpoint = wsejbEndpointRegistry.getEjbWebServiceEndpoint(requestUri, hreq.getMethod(), query);
    }
    if (ejbEndpoint != null) {
        /*
             * We can actually assert that ejbEndpoint is != null,
             * because this EjbWebServiceServlet would not have been
             * invoked otherwise
             */
        String scheme = hreq.getScheme();
        WebServiceEndpoint wse = ejbEndpoint.getEndpoint();
        if ("http".equals(scheme) && wse.isSecure()) {
            // redirect to correct protocol scheme if needed
            logger.log(Level.WARNING, LogUtils.INVALID_REQUEST_SCHEME, new Object[] { wse.getEndpointName(), "https", scheme });
            URL url = wse.composeEndpointAddress(new WsUtil().getWebServerInfoForDAS().getWebServerRootURL(true));
            StringBuilder sb = new StringBuilder(url.toExternalForm());
            if (query != null && query.trim().length() > 0) {
                sb.append("?");
                sb.append(query);
            }
            hresp.sendRedirect(hresp.encodeRedirectURL(sb.toString()));
        } else {
            boolean dispatch = true;
            // check if it is a tester servlet invocation
            if ("Tester".equalsIgnoreCase(query) && (!(HTTPBinding.HTTP_BINDING.equals(wse.getProtocolBinding())))) {
                Endpoint endpoint = WebServiceEngineImpl.getInstance().getEndpoint(hreq.getRequestURI());
                if ((endpoint.getDescriptor().isSecure()) || (endpoint.getDescriptor().getMessageSecurityBinding() != null)) {
                    String message = endpoint.getDescriptor().getWebService().getName() + "is a secured web service; Tester feature is not supported for secured services";
                    (new WsUtil()).writeInvalidMethodType(hresp, message);
                    return;
                }
                if (Boolean.parseBoolean(endpoint.getDescriptor().getDebugging())) {
                    dispatch = false;
                    WebServiceTesterServlet.invoke(hreq, hresp, endpoint.getDescriptor());
                }
            }
            if ("wsdl".equalsIgnoreCase(query) && (!(HTTPBinding.HTTP_BINDING.equals(wse.getProtocolBinding())))) {
                if (wse.getWsdlExposed() != null && !Boolean.parseBoolean(wse.getWsdlExposed())) {
                    hresp.sendError(HttpServletResponse.SC_NOT_FOUND);
                }
            }
            if (dispatch) {
                RequestTraceSpan span = null;
                try {
                    if (requestTracing.isRequestTracingEnabled()) {
                        span = constructWsRequestSpan(hreq, ejbEndpoint);
                    }
                    dispatchToEjbEndpoint(hreq, hresp, ejbEndpoint);
                } finally {
                    if (requestTracing.isRequestTracingEnabled() && span != null) {
                        requestTracing.traceSpan(span);
                    }
                }
            }
        }
    } else {
        hresp.sendError(HttpServletResponse.SC_NOT_FOUND);
    }
}
Also used : Endpoint(org.glassfish.webservices.monitoring.Endpoint) WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint) WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint) RequestTraceSpan(fish.payara.notification.requesttracing.RequestTraceSpan) WSEjbEndpointRegistry(org.glassfish.ejb.spi.WSEjbEndpointRegistry) URL(java.net.URL)

Example 9 with RequestTraceSpan

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

the class JAXWSServlet method constructWsRequestSpan.

private RequestTraceSpan constructWsRequestSpan(HttpServletRequest httpServletRequest, URI uri) {
    RequestTraceSpan span = new RequestTraceSpan("processSoapWebserviceRequest");
    span.addSpanTag("URI", uri.toString());
    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 10 with RequestTraceSpan

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

the class RequestTracingService method startTrace.

public UUID startTrace(UUID propagatedTraceId, UUID propagatedParentId, RequestTraceSpan.SpanContextRelationshipType propagatedRelationshipType, String traceName) {
    if (!isRequestTracingEnabled()) {
        return null;
    }
    RequestTraceSpan span = new RequestTraceSpan(EventType.PROPAGATED_TRACE, traceName, propagatedTraceId, propagatedParentId, propagatedRelationshipType);
    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