@Override public <Req> void request(HttpAdapter<Req, ?> adapter, Req req, SpanCustomizer customizer) { customizer.name(adapter.method(req).toLowerCase() + " " + adapter.path(req)); customizer.tag("http.url", adapter.url(req)); // just the path is logged by default customizer.tag("context.visible", String.valueOf(currentTraceContext.get() != null)); customizer.tag("request_customizer.is_span", (customizer instanceof brave.Span) + ""); }
/** {@inheritDoc} */ @Override public SpanCustomizer annotate(String value) { return tracer.currentSpanCustomizer().annotate(value); } }
/** Override the customize the span based on the start of a request. */ protected <ReqT, RespT> void onStart(MethodDescriptor<ReqT, RespT> method, CallOptions options, Metadata headers, SpanCustomizer span) { span.name(spanName(method)); } }
/** {@inheritDoc} */ @Override public SpanCustomizer name(String name) { return tracer.currentSpanCustomizer().name(name); }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { ((brave.SpanCustomizer) request.getAttribute("brave.SpanCustomizer")).tag("foo", "bar"); chain.doFilter(request, response); }
/** * Override to change what data from the http request are parsed into the span representing it. By * default, this sets the span name to the http method and tags "http.method" and "http.path". * * <p>If you only want to change the span name, you can override {@link #spanName(HttpAdapter, * Object)} instead. * * @see #spanName(HttpAdapter, Object) */ // Eventhough the default span name is the method, we have no way of knowing that a user hasn't // overwritten the name to something else. If that occurs during response parsing, it is too late // to go back and get the http method. Adding http method by default ensures span naming doesn't // prevent basic HTTP info from being visible. A cost of this is another tag, but it is small with // very limited cardinality. Moreover, users who care strictly about size can override this. public <Req> void request(HttpAdapter<Req, ?> adapter, Req req, SpanCustomizer customizer) { customizer.name(spanName(adapter, req)); String method = adapter.method(req); if (method != null) customizer.tag("http.method", method); String path = adapter.path(req); if (path != null) customizer.tag("http.path", path); }
@Override public void parse(MethodInvocation pjp, NewSpan newSpan, SpanCustomizer span) { String name = newSpan == null || StringUtils.isEmpty(newSpan.name()) ? pjp.getMethod().getName() : newSpan.name(); String changedName = SpanNameUtil.toLowerHyphen(name); if (log.isDebugEnabled()) { log.debug("For the class [" + pjp.getThis().getClass() + "] method " + "[" + pjp.getMethod().getName() + "] will name the span [" + changedName + "]"); } span.name(changedName); }
/** Same behaviour as {@link brave.SpanCustomizer#annotate(String)} */ protected final void annotate(Object span, String value) { if (span instanceof SpanCustomizer) { ((SpanCustomizer) span).annotate(value); } else if (span instanceof ScopedSpan) { ((ScopedSpan) span).annotate(value); } }
@Override public <Req> void request(HttpAdapter<Req, ?> adapter, Req req, SpanCustomizer customizer) { customizer.tag("http.url", adapter.url(req)); // just the path is logged by default customizer.tag("context.visible", String.valueOf(currentTraceContext.get() != null)); customizer.tag("request_customizer.is_span", (customizer instanceof brave.Span) + ""); }
statusCode = adapter.statusCodeAsInt(res); String nameFromRoute = spanNameFromRoute(adapter, res, statusCode); if (nameFromRoute != null) customizer.name(nameFromRoute); String maybeStatus = maybeStatusAsString(statusCode, 299); if (maybeStatus != null) customizer.tag("http.status_code", maybeStatus);
/** Override the customize the span based on the start of a request. */ protected <ReqT, RespT> void onStart(ServerCall<ReqT, RespT> call, Metadata headers, SpanCustomizer span) { span.name(spanName(call.getMethodDescriptor())); } }
/** Same behaviour as {@link brave.SpanCustomizer#annotate(String)} */ protected final void annotate(Object span, String value) { if (span instanceof SpanCustomizer) { ((SpanCustomizer) span).annotate(value); } else if (span instanceof ScopedSpan) { ((ScopedSpan) span).annotate(value); } }
/** * Invoked prior to request invocation during {@link ContainerRequestFilter#filter(ContainerRequestContext)} * where the resource info was injected from context. * * <p>Adds the tags {@link #RESOURCE_CLASS} and {@link #RESOURCE_METHOD}. Override or use {@link #NOOP} * to change this behavior. */ protected void resourceInfo(ResourceInfo resourceInfo, SpanCustomizer customizer) { customizer.tag(RESOURCE_CLASS, resourceInfo.getResourceClass().getSimpleName()); customizer.tag(RESOURCE_METHOD, resourceInfo.getResourceMethod().getName()); }
@Override public <Req> void request(HttpAdapter<Req, ?> adapter, Req req, SpanCustomizer customizer) { customizer.name(adapter.method(req).toLowerCase() + " " + adapter.path(req)); customizer.tag("http.url", adapter.url(req)); // just the path is logged by default customizer.tag("context.visible", String.valueOf(currentTraceContext.get() != null)); customizer.tag("request_customizer.is_span", (customizer instanceof brave.Span) + ""); }
/** Override the customize the span based on the start of a request. */ protected <ReqT, RespT> void onStart(MethodDescriptor<ReqT, RespT> method, CallOptions options, Metadata headers, SpanCustomizer span) { span.name(spanName(method)); } }
/** {@inheritDoc} */ @Override public SpanCustomizer annotate(String value) { return tracer.currentSpanCustomizer().annotate(value); } }
@Override public <Resp> void response(HttpAdapter<?, Resp> adapter, Resp res, Throwable error, SpanCustomizer customizer) { super.response(adapter, res, error, customizer); customizer.tag("response_customizer.is_span", (customizer instanceof brave.Span) + ""); } }).build();
void onRequest(Exchange exchange, SpanCustomizer span) { span.name(spanName); span.tag("camel.client.endpoint.url", url); span.tag("camel.client.exchange.id", exchange.getExchangeId()); span.tag("camel.client.exchange.pattern", exchange.getPattern().name()); if (eventNotifier.isIncludeMessageBody() || eventNotifier.isIncludeMessageBodyStreams()) { boolean streams = eventNotifier.isIncludeMessageBodyStreams(); StreamCache cache = prepareBodyForLogging(exchange, streams); String body = MessageHelper.extractBodyForLogging(exchange.hasOut() ? exchange.getOut() : exchange.getIn(), "", streams, streams); span.tag("camel.client.exchange.message.request.body", body); if (cache != null) { cache.reset(); } } } }
/** {@inheritDoc} */ @Override public SpanCustomizer name(String name) { return tracer.currentSpanCustomizer().name(name); }