All Projects → opentracing-contrib → Java Spring Web

opentracing-contrib / Java Spring Web

Licence: apache-2.0
OpenTracing Spring Web instrumentation

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Java Spring Web

Java Spring Cloud
Distributed tracing for Spring Boot, Cloud and other Spring projects
Stars: ✭ 326 (+266.29%)
Mutual labels:  spring-boot, spring, spring-cloud, tracing, opentracing
Spring Cloud Flycloud
🔥🔥🔥FlyClould 微服务实战项目框架,在该框架中,包括了用 Spring Cloud 构建微服务的一系列基本组件和框架,对于后台服务框架的搭建有很大的参考价值,大家可以参考甚至稍加修改可以直接应用于自己的实际的项目开发中,该项目没有采用Maven进行项目构建,Maven通过xml进行依赖管理,导致整个配置文件太过臃肿,另外灵活性也不是很强,所以我采用Gradle进行项目构建和依赖管理,在FlyTour项目中我们见证了Gradle的强大,通过简单的一些配置就可以轻松的实现组件化的功能。该项目共有11个Module工程。其中10个位微服务工程,这10个微服务工程构成了一个完整的微服务系统,微服务系统包含了8个基础服务,提供了一整套微服务治理功能,他们分别是配置中心module_c…
Stars: ✭ 1,514 (+1601.12%)
Mutual labels:  spring-boot, spring, spring-cloud, spring-mvc
Spring Cloud Microservices Development
Spring Cloud Microservices Development.《Spring Cloud 微服务架构开发实战》
Stars: ✭ 106 (+19.1%)
Mutual labels:  spring-boot, spring, spring-cloud, spring-mvc
Spring Cloud Sleuth
Distributed tracing for spring cloud
Stars: ✭ 1,531 (+1620.22%)
Mutual labels:  spring-boot, spring, spring-cloud, tracing
Java Specialagent
Automatic instrumentation for 3rd-party libraries in Java applications with OpenTracing.
Stars: ✭ 156 (+75.28%)
Mutual labels:  spring-boot, spring, tracing, opentracing
Spring Boot Demo
Spring Boot & Spring Cloud & Spring Security Demo Case(Spring学习示例实战项目)
Stars: ✭ 255 (+186.52%)
Mutual labels:  spring-boot, spring, spring-cloud, spring-mvc
Spring Boot Demo
spring boot demo 是一个Spring Boot、Spring Cloud的项目示例,根据市场主流的后端技术,共集成了30+个demo,未来将持续更新。该项目包含helloworld(快速入门)、web(ssh项目快速搭建)、aop(切面编程)、data-redis(redis缓存)、quartz(集群任务实现)、shiro(权限管理)、oauth2(四种认证模式)、shign(接口参数防篡改重放)、encoder(用户密码设计)、actuator(服务监控)、cloud-config(配置中心)、cloud-gateway(服务网关)等模块
Stars: ✭ 323 (+262.92%)
Mutual labels:  spring-boot, spring, spring-cloud, spring-mvc
Spring Boot Shopping Cart
Simple shopping cart web app made using Spring Boot + Thymeleaf
Stars: ✭ 85 (-4.49%)
Mutual labels:  spring-boot, spring, spring-mvc
Spring Mvc Thymeleaf Crud
Spring MVC CRUD Application with Thymeleaf, HTML5, CSS3 and Bootstrap
Stars: ✭ 14 (-84.27%)
Mutual labels:  spring-boot, spring, spring-mvc
Jbone
jbone基于Spring Cloud框架开发,旨在为中小企业提供稳定的微服务解决方案,为开发人员提供基础开发骨架,jbone包含微服务中所有常用组件,例如注册中心、服务管理、服务监控、JVM监控、内存分析、调用链跟踪、API网关等等。业务功能包括系统权限的统一管理、单点登录、CMS、电商平台、工作流平台、支付平台等等。
Stars: ✭ 961 (+979.78%)
Mutual labels:  spring-boot, spring, spring-cloud
Botwall4j
A botwall for Java web applications
Stars: ✭ 41 (-53.93%)
Mutual labels:  spring-boot, spring, spring-mvc
Spring Cloud Examples
Examples of microservice instrastructures
Stars: ✭ 11 (-87.64%)
Mutual labels:  spring-boot, spring, spring-cloud
Springbootunity
rabbitmq、redis、scheduled、socket、mongodb、Swagger2、spring data jpa、Thymeleaf、freemarker etc. (muti module spring boot project) (with spring boot framework,different bussiness scence with different technology。)
Stars: ✭ 845 (+849.44%)
Mutual labels:  spring-boot, spring, spring-mvc
Cloud Enabled Microservice
Tasks microservice (Spring Boot, MVC, Data, Lombok, Cloud, OAuth2, Config, Eureka, Zuul, Hystrix, Docker)
Stars: ✭ 14 (-84.27%)
Mutual labels:  spring-boot, spring-cloud, spring-mvc
Localstack Spring Boot
Spring Boot AutoConfiguration for LocalStack
Stars: ✭ 22 (-75.28%)
Mutual labels:  spring-boot, spring, spring-cloud
Spring Thrift Api Gateway
Gateway for Apache Thrift requests processing that is built on Spring Cloud stack
Stars: ✭ 38 (-57.3%)
Mutual labels:  spring-boot, spring, spring-cloud
Journaldev
JournalDev Projects
Stars: ✭ 897 (+907.87%)
Mutual labels:  spring-boot, spring, spring-mvc
Devops Service
DevOps Service is the core service of Choerodon. It integrated several open source tools to automate the DevOps process of planning, coding, building, testing, and deployment, operation, monitoring.
Stars: ✭ 36 (-59.55%)
Mutual labels:  spring-boot, spring, spring-cloud
Okta Blog Archive
Okta Developer Blog
Stars: ✭ 74 (-16.85%)
Mutual labels:  spring-boot, spring, spring-cloud
Springboard
Spring Boot based production grade starter kit.
Stars: ✭ 59 (-33.71%)
Mutual labels:  spring-boot, spring, spring-mvc

Build Status Released Version

OpenTracing Spring Web Instrumentation

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).

Comparison with opentracing-spring-cloud

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.)

How does the server tracing work?

Servlet

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.

Reactive

Server span is started in TracingWebFilter (upon subscription), then onNext(), onError(), etc. handlers add Spring WebFlux related tags and logs.

Library versions

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

Configuration

Spring Boot Auto-configuration

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.

Manual configuration

Servlet and MVC Server

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.

Reactive Server

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())
        );
    }
}

Client

RestTemplate restTemplate = new RestTemplate();
restTemplate.setInterceptors(Collections.singletonList(new TracingRestTemplateInterceptor(tracer)));

// the same applies for AsyncRestTemplate 

Reactive Client

WebClient webClient = WebClient.builder()
        .filter(new TracingExchangeFilterFunction(tracer, Collections.singletonList(new WebClientSpanDecorator.StandardTags())))
        .build();

Access server span

@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();
    }
}

Development

./mvnw clean install

Release

Follow instructions in RELEASE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].