Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Spring Cloud Sleuth | 1,677 | 1,242 | 28 | 5 days ago | 65 | June 29, 2022 | 31 | apache-2.0 | Java | |
Distributed tracing for spring cloud | ||||||||||
Java Spring Cloud | 356 | 28 | 10 | a year ago | 52 | October 30, 2020 | 52 | apache-2.0 | Java | |
Distributed tracing for Spring Boot, Cloud and other Spring projects | ||||||||||
Java Specialagent | 153 | 1 | 4 | 2 years ago | 34 | July 15, 2020 | 42 | apache-2.0 | Java | |
Automatic instrumentation for 3rd-party libraries in Java applications with OpenTracing. | ||||||||||
Java Kafka Client | 102 | 7 | 5 | 2 years ago | 35 | October 28, 2020 | 6 | apache-2.0 | Java | |
OpenTracing Instrumentation for Apache Kafka Client | ||||||||||
Java Spring Web | 94 | 5 | 11 | 2 years ago | 15 | October 13, 2020 | 18 | apache-2.0 | Java | |
OpenTracing Spring Web instrumentation | ||||||||||
Invesdwin Instrument | 86 | a month ago | lgpl-3.0 | Java | ||||||
An instrumentation java agent that is able to inject itself into the running process | ||||||||||
Java Redis Client | 23 | 2 | 7 | 2 years ago | 32 | July 23, 2020 | 4 | apache-2.0 | Java | |
OpenTracing Instrumentation for Redis Client | ||||||||||
Java Spring Rabbitmq | 16 | a year ago | 7 | apache-2.0 | Java | |||||
OpenTracing RabbitMQ instrumentation | ||||||||||
Java Reactor | 11 | 1 | 3 years ago | 5 | August 11, 2020 | apache-2.0 | Java | |||
OpenTracing instrumentation for Reactor | ||||||||||
Spring Cloud Sleuth Amqp | 8 | 1 | 1 | 4 years ago | 7 | April 25, 2018 | 6 | apache-2.0 | Java | |
Implementation of spring-rabbit instrumentation for spring-cloud-sleuth |
This library provides instrumentation for Spring Web applications (Boot, MVC and WebFlux). It creates tracing data for
server requests and also client requests (RestTemplate
, AsyncRestTemplate
and WebClient
).
As it was mentioned above, this library traces only inbound/outbound HTTP requests. If you would like to
get automatically traced different set of technologies e.g. spring-cloud-netflix
, JMS or even more then
use project opentracing-spring-cloud instead.
For reactive applications, it is especially recommended to use reactor
tracing from
opentracing-spring-cloud, as that will ensure
that the Span
is activated in reactor handler functions. (Without that, one would have to extract the
Span
from the subscriber context.)
Server span is started in Web Servlet Filter,
then tracing interceptor adds spring related tags and logs. There are use case when spring boot invokes a handler after
a request processing in filter finished, in this case interceptor starts a new span as followsFrom
which references the initial span created in the servlet filter.
Server span is started in TracingWebFilter
(upon subscription), then onNext()
, onError()
, etc. handlers add Spring WebFlux related tags and logs.
Versions 1.x.y, 2.x.y, ... of the library are meant to target Spring Framework 5.x and Spring Boot 2.x while versions 0.x.y are meant to be used with Spring Framework 4.3 and Spring Boot 1.5
If you are using Spring Boot the easiest way how to configure OpenTracing instrumentation is to use auto-configuration:
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-web-starter</artifactId>
</dependency>
Just provide an OpenTracing tracer bean and all required configuration is automatically
done for you. It also instruments all RestTemplate
, AsyncRestTemplate
, WebClient
and WebClient.Builder
beans.
Configuration needs to add TracingFilter
and TracingHandlerInterceptor
. Both of these classes
are required!
Tracing interceptor can be instantiated manually or injected via CDI, but
it needs bean of type Tracer
configured.
Java based configuration:
@Configuration
@Import({TracingHandlerInterceptor.class})
public class MVCConfiguration extends WebMvcConfigurerAdapter {
@Autowired
private Tracer tracer;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new TracingHandlerInterceptor(tracer));
}
@Bean
public FilterRegistrationBean tracingFilter() {
TracingFilter tracingFilter = new TracingFilter(tracer);
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(tracingFilter);
filterRegistrationBean.addUrlPatterns("/*");
filterRegistrationBean.setOrder(Integer.MIN_VALUE);
filterRegistrationBean.setAsyncSupported(true);
return filterRegistrationBean;
}
}
XML based configuration can be used too. Filter can be also directly defined in web.xml
.
Configuration needs to add the TracingWebFilter
bean.
@Configuration
class TracingConfiguration {
@Bean
public TracingWebFilter tracingWebFilter(Tracer tracer) {
return new TracingWebFilter(
tracer,
Integer.MIN_VALUE, // Order
Pattern.compile(""), // Skip pattern
Collections.emptyList(), // URL patterns, empty list means all
Arrays.asList(new WebFluxSpanDecorator.StandardTags(), new WebFluxSpanDecorator.WebFluxTags())
);
}
}
RestTemplate restTemplate = new RestTemplate();
restTemplate.setInterceptors(Collections.singletonList(new TracingRestTemplateInterceptor(tracer)));
// the same applies for AsyncRestTemplate
WebClient webClient = WebClient.builder()
.filter(new TracingExchangeFilterFunction(tracer, Collections.singletonList(new WebClientSpanDecorator.StandardTags())))
.build();
@RequestMapping("/hello")
public String hello(HttpServletRequest request) {
Span serverSpan = tracer.activeSpan();
Span span = tracer.buildSpan("localSpan")
.asChildOf(serverSpan.context())
.start();
try {
// Traced work happens between start() and deactivate();
return "Hello world!";
} finally {
span.finish();
}
}
./mvnw clean install
Follow instructions in RELEASE