io.opentracing.contrib.web.servlet.filter.ServletFilterSpanDecorator Java Examples
The following examples show how to use
io.opentracing.contrib.web.servlet.filter.ServletFilterSpanDecorator.
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: Configuration.java From java-specialagent with Apache License 2.0 | 6 votes |
static List<ServletFilterSpanDecorator> parseSpanDecorators(final String spanDecoratorsArgs) { final List<ServletFilterSpanDecorator> result = new ArrayList<>(); if (spanDecoratorsArgs != null) { final String[] parts = spanDecoratorsArgs.split(DECORATOR_SEPARATOR); for (final String part : parts) { final ServletFilterSpanDecorator decorator = newSpanDecoratorInstance(part); if (decorator != null) result.add(decorator); } } if (result.isEmpty()) result.add(ServletFilterSpanDecorator.STANDARD_TAGS); result.add(new ServletFilterHeaderSpanDecorator(HttpHeaderTagParser.parse(), null)); return result; }
Example #2
Source File: Configuration.java From java-specialagent with Apache License 2.0 | 6 votes |
private static ClassLoader getDecoratorClassLoader() { if (decoratorClassLoader != null) return decoratorClassLoader; final String spanDecoratorsClassPath = System.getProperty(SPAN_DECORATORS_CLASSPATH); if (spanDecoratorsClassPath == null || spanDecoratorsClassPath.isEmpty()) return decoratorClassLoader = ServletFilterSpanDecorator.class.getClassLoader(); final String[] parts = spanDecoratorsClassPath.split(File.pathSeparator); final URL[] urls = new URL[parts.length]; for (int i = 0; i < parts.length; ++i) { final String part = parts[i]; try { urls[i] = new URL("file", "", part.endsWith(".jar") || part.endsWith("/") ? part : part + "/"); } catch (final MalformedURLException e) { logger.log(Level.WARNING, part + "is not a valid URL"); } } return decoratorClassLoader = new URLClassLoader(urls, ServletFilterSpanDecorator.class.getClassLoader()); }
Example #3
Source File: Configuration.java From java-specialagent with Apache License 2.0 | 5 votes |
private static ServletFilterSpanDecorator newSpanDecoratorInstance(final String className) { try { final Class<?> decoratorClass = getDecoratorClassLoader().loadClass(className); if (ServletFilterSpanDecorator.class.isAssignableFrom(decoratorClass)) return (ServletFilterSpanDecorator)decoratorClass.newInstance(); logger.log(Level.WARNING, className + " is not a subclass of " + ServletFilterSpanDecorator.class.getName()); } catch (final ClassNotFoundException | IllegalAccessException | InstantiationException e) { logger.log(Level.SEVERE, e.getMessage(), e); } return null; }
Example #4
Source File: TracingFilterUtil.java From java-specialagent with Apache License 2.0 | 5 votes |
public static Span buildSpan(final HttpServletRequest httpRequest, final Tracer tracer, final List<ServletFilterSpanDecorator> spanDecorators) { final SpanContext extractedContext = tracer.extract(Format.Builtin.HTTP_HEADERS, new HttpServletRequestExtractAdapter(httpRequest)); final Span span = tracer.buildSpan(httpRequest.getMethod()) .asChildOf(extractedContext) .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER) .start(); httpRequest.setAttribute(SERVER_SPAN_CONTEXT, span.context()); for (final ServletFilterSpanDecorator spanDecorator: spanDecorators) spanDecorator.onRequest(httpRequest, span); return span; }
Example #5
Source File: InterceptUtilTest.java From java-specialagent with Apache License 2.0 | 5 votes |
private static void testDecorators(final String spanDecoratorsArgs, final Class<?> ... expecteds) { final List<ServletFilterSpanDecorator> decorators = Configuration.parseSpanDecorators(spanDecoratorsArgs); assertEquals(expecteds.length, decorators.size()); final List<Class<?>> list = Arrays.asList(expecteds); for (final ServletFilterSpanDecorator decorator : decorators) assertTrue(list.contains(decorator.getClass())); }
Example #6
Source File: StandardSpanDecoratorTest.java From opentracing-toolbox with MIT License | 5 votes |
@Bean @SuppressWarnings({"rawtypes", "unchecked"}) // generic as of Spring Boot 2 public FilterRegistrationBean tracingFilter( final Tracer tracer, final List<ServletFilterSpanDecorator> decorators) { final TracingFilter filter = new TracingFilter(tracer, decorators, null); final FilterRegistrationBean bean = new FilterRegistrationBean(filter); bean.setAsyncSupported(true); return bean; }
Example #7
Source File: OpenTracingServletExtensionAutoConfigurationTest.java From opentracing-toolbox with MIT License | 5 votes |
@Bean @SuppressWarnings({"rawtypes", "unchecked"}) // generic as of Spring Boot 2 public FilterRegistrationBean tracingFilter( final Tracer tracer, final List<ServletFilterSpanDecorator> decorators) { final TracingFilter filter = new TracingFilter(tracer, decorators, null); final FilterRegistrationBean bean = new FilterRegistrationBean(filter); bean.setAsyncSupported(true); return bean; }
Example #8
Source File: StandardSpanDecoratorTest.java From opentracing-toolbox with MIT License | 4 votes |
@Bean public ServletFilterSpanDecorator staticSpanDecorator() { return new StaticSpanDecorator(singletonMap("test", "true")); }
Example #9
Source File: ServletApiV3.java From java-specialagent with Apache License 2.0 | 4 votes |
public static void addListenerToAsyncContext(final HttpServletRequest request, final Span span, final List<ServletFilterSpanDecorator> spanDecorators) { if (isApiV3) request.getAsyncContext().addListener(new TracingAsyncListener(span, spanDecorators)); }
Example #10
Source File: StandardSpanDecoratorTest.java From opentracing-toolbox with MIT License | 4 votes |
@Bean public ServletFilterSpanDecorator httpUrlSpanDecorator() { return new HttpUrlSpanDecorator(); }
Example #11
Source File: StandardSpanDecoratorTest.java From opentracing-toolbox with MIT License | 4 votes |
@Bean public ServletFilterSpanDecorator standardSpanDecorator() { return new StandardSpanDecorator(); }
Example #12
Source File: ServiceLoaderSpanDecorator.java From opentracing-toolbox with MIT License | 4 votes |
public ServiceLoaderSpanDecorator() { super(CompositeSpanDecorator.composite(load(ServletFilterSpanDecorator.class))); }
Example #13
Source File: CompositeSpanDecorator.java From opentracing-toolbox with MIT License | 4 votes |
static ServletFilterSpanDecorator composite( final Iterable<ServletFilterSpanDecorator> decorators) { return new CompositeSpanDecorator(decorators); }
Example #14
Source File: CompositeSpanDecorator.java From opentracing-toolbox with MIT License | 4 votes |
static ServletFilterSpanDecorator composite( final ServletFilterSpanDecorator... decorators) { return composite(Arrays.asList(decorators)); }
Example #15
Source File: OpenTracingServletExtensionAutoConfiguration.java From opentracing-toolbox with MIT License | 4 votes |
@API(status = INTERNAL) @Bean @ConditionalOnMissingBean(ServletFilterSpanDecorator.class) public ServletFilterSpanDecorator standardServletFilterSpanDecorator() { return new StandardSpanDecorator(); }
Example #16
Source File: SpringMVCConfiguration.java From java-spring-web with Apache License 2.0 | 4 votes |
@Override public void contextInitialized(ServletContextEvent sce) { sce.getServletContext().setAttribute(TracingFilter.SPAN_DECORATORS, Collections.singletonList(ServletFilterSpanDecorator.STANDARD_TAGS)); sce.getServletContext().setAttribute(TracingFilter.SKIP_PATTERN, Pattern.compile("/health")); }
Example #17
Source File: ServerTracingAutoConfiguration.java From java-spring-web with Apache License 2.0 | 4 votes |
public ServerTracingAutoConfiguration(ObjectProvider<List<ServletFilterSpanDecorator>> servletFilterSpanDecorator, ObjectProvider<List<HandlerInterceptorSpanDecorator>> interceptorSpanDecorator) { this.servletFilterSpanDecorator = servletFilterSpanDecorator; this.interceptorSpanDecorator = interceptorSpanDecorator; }
Example #18
Source File: TracingFilterUtil.java From java-specialagent with Apache License 2.0 | 4 votes |
public static void onError(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse, final Throwable t, final Span span, final List<ServletFilterSpanDecorator> spanDecorators) { for (final ServletFilterSpanDecorator spanDecorator : spanDecorators) spanDecorator.onError(httpRequest, httpResponse, t, span); }
Example #19
Source File: TracingFilterUtil.java From java-specialagent with Apache License 2.0 | 4 votes |
public static void onResponse(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse, final Span span, final List<ServletFilterSpanDecorator> spanDecorators) { for (final ServletFilterSpanDecorator spanDecorator : spanDecorators) spanDecorator.onResponse(httpRequest, httpResponse, span); }