@Override public void onComplete(AsyncEvent e) { if (complete) return; handler.handleSend(adaptResponse(e), null, span); complete = true; }
@Override public void onError(AsyncEvent e) { if (complete) return; handler.handleSend(adaptResponse(e), e.getThrowable(), span); complete = true; }
@Override public Object run() { if (log.isDebugEnabled()) { log.debug("Marking current span as handled"); } HttpServletResponse response = RequestContext.getCurrentContext().getResponse(); Throwable exception = RequestContext.getCurrentContext().getThrowable(); Span currentSpan = this.tracer.currentSpan(); this.handler.handleSend(response, exception, currentSpan); if (log.isDebugEnabled()) { log.debug("Handled send of " + currentSpan); } return null; }
@Override public void onTimeout(AsyncEvent e) { if (complete) return; span.tag("error", String.format("Timed out after %sms", e.getAsyncContext().getTimeout())); handler.handleSend(adaptResponse(e), null, span); complete = true; }
public Filter afterAfter() { return (request, response) -> { Span span = tracer.currentSpan(); if (span == null) return; ((Tracer.SpanInScope) request.attribute(Tracer.SpanInScope.class.getName())).close(); handler.handleSend(ADAPTER.adaptResponse(request.raw(), response.raw()), null, span); }; }
public ExceptionHandler exception(ExceptionHandler delegate) { return (exception, request, response) -> { Span span = tracer.currentSpan(); if (span != null) { ((Tracer.SpanInScope) request.attribute(Tracer.SpanInScope.class.getName())).close(); handler.handleSend(ADAPTER.adaptResponse(request.raw(), response.raw()), exception, span); } delegate.handle(exception, request, response); }; } }
servlet.handleAsync(handler, httpRequest, httpResponse, span); } else { // we have a synchronous response, so we can finish the span handler.handleSend(ADAPTER.adaptResponse(httpRequest, httpResponse), error, span);
@Override public void handle(Void aVoid) { if (!finished.compareAndSet(false, true)) return; VertxHttpServerAdapter.setCurrentMethodAndPath( context.request().rawMethod(), context.currentRoute().getPath() ); try { serverHandler.handleSend(context.response(), context.failure(), span); } finally { VertxHttpServerAdapter.setCurrentMethodAndPath(null, null); } } }
private void terminateSpan(@Nullable Throwable t) { String httpRoute = null; Object attribute = this.exchange .getAttribute(HandlerMapping.BEST_MATCHING_HANDLER_ATTRIBUTE); if (attribute instanceof HandlerMethod) { HandlerMethod handlerMethod = (HandlerMethod) attribute; addClassMethodTag(handlerMethod, this.span); addClassNameTag(handlerMethod, this.span); Object pattern = this.exchange .getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE); httpRoute = pattern != null ? pattern.toString() : ""; } addResponseTagsForSpanWithoutParent(this.exchange, this.exchange.getResponse(), this.span); DecoratedServerHttpResponse delegate = new DecoratedServerHttpResponse( this.exchange.getResponse(), this.exchange.getRequest().getMethodValue(), httpRoute); this.handler.handleSend(delegate, t, this.span); if (log.isDebugEnabled()) { log.debug("Handled send of " + this.span); } }
@Override public void onResponse(Span span, Response response, Throwable error) { handler.handleSend(response, error, span); }
event.getContainerRequest().setProperty("http.route", maybeHttpRoute); serverHandler.handleSend(event, event.getException(), span); break; default:
@Override public void onResponse(Span span, Response response, Throwable error) { handler.handleSend(response, error, span); }
@Override public void onResponse(Span span, Response response, Throwable error) { handler.handleSend(response, error, span); }
@Override public Object run() { if (log.isDebugEnabled()) { log.debug("Marking current span as handled"); } HttpServletResponse response = RequestContext.getCurrentContext().getResponse(); Throwable exception = RequestContext.getCurrentContext().getThrowable(); Span currentSpan = this.tracer.currentSpan(); this.handler.handleSend(response, exception, currentSpan); if (log.isDebugEnabled()) { log.debug("Handled send of " + currentSpan); } return null; }
public Filter afterAfter() { return (request, response) -> { Span span = tracer.currentSpan(); if (span == null) return; ((Tracer.SpanInScope) request.attribute(Tracer.SpanInScope.class.getName())).close(); handler.handleSend(ADAPTER.adaptResponse(request.raw(), response.raw()), null, span); }; }
public ExceptionHandler exception(ExceptionHandler delegate) { return (exception, request, response) -> { Span span = tracer.currentSpan(); if (span != null) { ((Tracer.SpanInScope) request.attribute(Tracer.SpanInScope.class.getName())).close(); handler.handleSend(ADAPTER.adaptResponse(request.raw(), response.raw()), exception, span); } delegate.handle(exception, request, response); }; } }
private void terminateSpan(@Nullable Throwable t) { String httpRoute = null; Object attribute = this.exchange .getAttribute(HandlerMapping.BEST_MATCHING_HANDLER_ATTRIBUTE); if (attribute instanceof HandlerMethod) { HandlerMethod handlerMethod = (HandlerMethod) attribute; addClassMethodTag(handlerMethod, this.span); addClassNameTag(handlerMethod, this.span); Object pattern = this.exchange .getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE); httpRoute = pattern != null ? pattern.toString() : ""; } addResponseTagsForSpanWithoutParent(this.exchange, this.exchange.getResponse(), this.span); DecoratedServerHttpResponse delegate = new DecoratedServerHttpResponse( this.exchange.getResponse(), this.exchange.getRequest().getMethodValue(), httpRoute); this.handler.handleSend(delegate, t, this.span); if (log.isDebugEnabled()) { log.debug("Handled send of " + this.span); } }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { if (!exchange.isComplete()) { Span span = serverHandler.handleReceive(extractor, exchange.getRequestHeaders(), exchange); exchange.addExchangeCompleteListener((exch, nextListener) -> { try { nextListener.proceed(); } finally { serverHandler.handleSend(exch, exch.getAttachment(ExceptionHandler.THROWABLE), span); } }); try (Scope scope = currentTraceContext.newScope(span.context())) { next.handleRequest(exchange); } catch (Exception | Error e) { // move the error to where the complete listener can see it exchange.putAttachment(ExceptionHandler.THROWABLE, e); throw e; } } else { next.handleRequest(exchange); } } }
handler.handleSend(response, null, scope.getSpan()); } finally { scope.close();
handler.handleSend(response, null, scope.getSpan()); } finally { scope.close();