Java Code Examples for com.dianping.cat.Cat#logRemoteCallServer()

The following examples show how to use com.dianping.cat.Cat#logRemoteCallServer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CatServletFilter.java    From cat_lab with MIT License 5 votes vote down vote up
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;

    String url = request.getRequestURL().toString();
    for (String urlPattern : urlPatterns) {
        if (url.startsWith(urlPattern)) {
            url = urlPattern;
        }
    }

    CatContext catContext = new CatContext();
    catContext.addProperty(Cat.Context.ROOT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_ROOT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.PARENT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_PARENT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.CHILD, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_CHILD_MESSAGE_ID));
    Cat.logRemoteCallServer(catContext);
    
    Transaction t = Cat.newTransaction(CatConstants.TYPE_SERVICE, url);

    try {

        Cat.logEvent("Service.method", request.getMethod(), Message.SUCCESS, request.getRequestURL().toString());
        Cat.logEvent("Service.client", request.getRemoteHost());

        filterChain.doFilter(servletRequest, servletResponse);

        t.setStatus(Transaction.SUCCESS);
    } catch (Exception ex) {
        t.setStatus(ex);
        Cat.logError(ex);
        throw ex;
    } finally {
        t.complete();
    }
}
 
Example 2
Source File: CatServletFilter.java    From cat_lab with MIT License 5 votes vote down vote up
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;

    String url = request.getRequestURL().toString();
    for (String urlPattern : urlPatterns) {
        if (url.startsWith(urlPattern)) {
            url = urlPattern;
        }
    }

    CatContext catContext = new CatContext();
    catContext.addProperty(Cat.Context.ROOT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_ROOT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.PARENT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_PARENT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.CHILD, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_CHILD_MESSAGE_ID));
    Cat.logRemoteCallServer(catContext);
    
    Transaction t = Cat.newTransaction(CatConstants.TYPE_URL, url);

    try {

        Cat.logEvent("Service.method", request.getMethod(), Message.SUCCESS, request.getRequestURL().toString());
        Cat.logEvent("Service.client", request.getRemoteHost());

        filterChain.doFilter(servletRequest, servletResponse);

        t.setStatus(Transaction.SUCCESS);
    } catch (Exception ex) {
        t.setStatus(ex);
        Cat.logError(ex);
        throw ex;
    } finally {
        t.complete();
    }
}
 
Example 3
Source File: CatServletFilter.java    From cat_lab with MIT License 5 votes vote down vote up
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;

    String url = request.getRequestURL().toString();
    for (String urlPattern : urlPatterns) {
        if (url.startsWith(urlPattern)) {
            url = urlPattern;
        }
    }

    CatContext catContext = new CatContext();
    catContext.addProperty(Cat.Context.ROOT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_ROOT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.PARENT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_PARENT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.CHILD, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_CHILD_MESSAGE_ID));
    Cat.logRemoteCallServer(catContext);
    
    Transaction t = Cat.newTransaction(CatConstants.TYPE_SERVICE, url);

    try {

        Cat.logEvent("Service.method", request.getMethod(), Message.SUCCESS, request.getRequestURL().toString());
        Cat.logEvent("Service.client", request.getRemoteHost());

        filterChain.doFilter(servletRequest, servletResponse);

        t.setStatus(Transaction.SUCCESS);
    } catch (Exception ex) {
        t.setStatus(ex);
        Cat.logError(ex);
        throw ex;
    } finally {
        t.complete();
    }
}
 
Example 4
Source File: CatServletFilter.java    From cat_lab with MIT License 5 votes vote down vote up
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;

    String url = request.getRequestURL().toString();
    for (String urlPattern : urlPatterns) {
        if (url.startsWith(urlPattern)) {
            url = urlPattern;
        }
    }

    CatContext catContext = new CatContext();
    catContext.addProperty(Cat.Context.ROOT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_ROOT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.PARENT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_PARENT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.CHILD, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_CHILD_MESSAGE_ID));
    Cat.logRemoteCallServer(catContext);
    
    Transaction t = Cat.newTransaction(CatConstants.TYPE_SERVICE, url);
    try {

        Cat.logEvent("Service.method", request.getMethod(), Message.SUCCESS, request.getRequestURL().toString());
        Cat.logEvent("Service.client", request.getRemoteHost());

        filterChain.doFilter(servletRequest, servletResponse);

        t.setStatus(Transaction.SUCCESS);
    } catch (Exception ex) {
        t.setStatus(ex);
        Cat.logError(ex);
        throw ex;
    } finally {
        t.complete();
    }
}
 
Example 5
Source File: CatServletFilter.java    From s2g-zuul with MIT License 5 votes vote down vote up
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;

    String url = request.getRequestURL().toString();
    for (String urlPattern : urlPatterns) {
        if (url.startsWith(urlPattern)) {
            url = urlPattern;
        }
    }

   Transaction t = Cat.newTransaction("Service", url);

    try {

        PropertyContext propertyContext = new PropertyContext();
        propertyContext.addProperty(Cat.Context.ROOT, request.getHeader(Constants.CAT_ROOT_MESSAGE_ID));
        propertyContext.addProperty(Cat.Context.PARENT, request.getHeader(Constants.CAT_PARENT_MESSAGE_ID));
        propertyContext.addProperty(Cat.Context.CHILD, request.getHeader(Constants.CAT_CHILD_MESSAGE_ID));
        Cat.logRemoteCallServer(propertyContext);

        Cat.logEvent("Service.method", request.getMethod(), Message.SUCCESS, request.getRequestURL().toString());
        Cat.logEvent("Service.client", request.getRemoteHost());

        filterChain.doFilter(servletRequest, servletResponse);

        t.setStatus(Transaction.SUCCESS);
    } catch (Exception ex) {
        t.setStatus(ex);
        Cat.logError(ex);
        throw ex;
    } finally {
        t.complete();
    }
}
 
Example 6
Source File: CatServletFilter.java    From piggymetrics with MIT License 5 votes vote down vote up
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;

    String url = request.getRequestURL().toString();
    for (String urlPattern : urlPatterns) {
        if (url.startsWith(urlPattern)) {
            url = urlPattern;
        }
    }

    CatContext catContext = new CatContext();
    catContext.addProperty(Cat.Context.ROOT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_ROOT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.PARENT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_PARENT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.CHILD, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_CHILD_MESSAGE_ID));
    Cat.logRemoteCallServer(catContext);
    
    Transaction t = Cat.newTransaction("Service", url);

    try {

        Cat.logEvent("Service.method", request.getMethod(), Message.SUCCESS, request.getRequestURL().toString());
        Cat.logEvent("Service.client", request.getRemoteHost());

        filterChain.doFilter(servletRequest, servletResponse);

        t.setStatus(Transaction.SUCCESS);
    } catch (Exception ex) {
        t.setStatus(ex);
        Cat.logError(ex);
        throw ex;
    } finally {
        t.complete();
    }
}
 
Example 7
Source File: CatServletFilter.java    From piggymetrics with MIT License 5 votes vote down vote up
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;

    String url = request.getRequestURL().toString();
    for (String urlPattern : urlPatterns) {
        if (url.startsWith(urlPattern)) {
            url = urlPattern;
        }
    }

    CatContext catContext = new CatContext();
    catContext.addProperty(Cat.Context.ROOT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_ROOT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.PARENT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_PARENT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.CHILD, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_CHILD_MESSAGE_ID));
    Cat.logRemoteCallServer(catContext);
    
    Transaction t = Cat.newTransaction("Service", url);

    try {

        Cat.logEvent("Service.method", request.getMethod(), Message.SUCCESS, request.getRequestURL().toString());
        Cat.logEvent("Service.client", request.getRemoteHost());

        filterChain.doFilter(servletRequest, servletResponse);

        t.setStatus(Transaction.SUCCESS);
    } catch (Exception ex) {
        t.setStatus(ex);
        Cat.logError(ex);
        throw ex;
    } finally {
        t.complete();
    }
}
 
Example 8
Source File: CatServletFilter.java    From piggymetrics with MIT License 5 votes vote down vote up
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;

    String url = request.getRequestURL().toString();
    for (String urlPattern : urlPatterns) {
        if (url.startsWith(urlPattern)) {
            url = urlPattern;
        }
    }

    CatContext catContext = new CatContext();
    catContext.addProperty(Cat.Context.ROOT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_ROOT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.PARENT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_PARENT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.CHILD, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_CHILD_MESSAGE_ID));
    Cat.logRemoteCallServer(catContext);
    
    Transaction t = Cat.newTransaction("Service", url);

    try {

        Cat.logEvent("Service.method", request.getMethod(), Message.SUCCESS, request.getRequestURL().toString());
        Cat.logEvent("Service.client", request.getRemoteHost());

        filterChain.doFilter(servletRequest, servletResponse);

        t.setStatus(Transaction.SUCCESS);
    } catch (Exception ex) {
        t.setStatus(ex);
        Cat.logError(ex);
        throw ex;
    } finally {
        t.complete();
    }
}
 
Example 9
Source File: CatServletFilter.java    From piggymetrics with MIT License 5 votes vote down vote up
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;

    String url = request.getRequestURL().toString();
    for (String urlPattern : urlPatterns) {
        if (url.startsWith(urlPattern)) {
            url = urlPattern;
        }
    }

    CatContext catContext = new CatContext();
    catContext.addProperty(Cat.Context.ROOT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_ROOT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.PARENT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_PARENT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.CHILD, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_CHILD_MESSAGE_ID));
    Cat.logRemoteCallServer(catContext);
    
    Transaction t = Cat.newTransaction("Service", url);

    try {

        Cat.logEvent("Service.method", request.getMethod(), Message.SUCCESS, request.getRequestURL().toString());
        Cat.logEvent("Service.client", request.getRemoteHost());

        filterChain.doFilter(servletRequest, servletResponse);

        t.setStatus(Transaction.SUCCESS);
    } catch (Exception ex) {
        t.setStatus(ex);
        Cat.logError(ex);
        throw ex;
    } finally {
        t.complete();
    }
}
 
Example 10
Source File: CatServletFilter.java    From piggymetrics with MIT License 5 votes vote down vote up
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;

    String url = request.getRequestURL().toString();
    for (String urlPattern : urlPatterns) {
        if (url.startsWith(urlPattern)) {
            url = urlPattern;
        }
    }

    CatContext catContext = new CatContext();
    catContext.addProperty(Cat.Context.ROOT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_ROOT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.PARENT, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_PARENT_MESSAGE_ID));
    catContext.addProperty(Cat.Context.CHILD, request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_CHILD_MESSAGE_ID));
    Cat.logRemoteCallServer(catContext);
    
    Transaction t = Cat.newTransaction("Service", url);

    try {

        Cat.logEvent("Service.method", request.getMethod(), Message.SUCCESS, request.getRequestURL().toString());
        Cat.logEvent("Service.client", request.getRemoteHost());

        filterChain.doFilter(servletRequest, servletResponse);

        t.setStatus(Transaction.SUCCESS);
    } catch (Exception ex) {
        t.setStatus(ex);
        Cat.logError(ex);
        throw ex;
    } finally {
        t.complete();
    }
}