opentelemetry-java-instrume.../instrumentation/spring/spring-webflux-5.0/library
Mateusz Rzeszutek 72ffb3b7c5
Make BaseTracer fields private (#2492)
* Make BaseTracer fields private

By making `tracer` private we're forcing all tracer implementation to use the `spanBuilder()` utility method and pass the parent context manually.
2021-03-05 10:54:00 -08:00
..
src/main/java/io/opentelemetry/instrumentation/spring/webflux/client Make BaseTracer fields private (#2492) 2021-03-05 10:54:00 -08:00
NOTICE.txt Reactor bugs (#1189) 2020-09-15 09:57:03 +09:00
README.md Update to latest snapshot. (#1524) 2020-10-29 18:54:09 -07:00
spring-webflux-5.0-library.gradle Remove support for java7 from buildscripts (#1229) 2020-09-23 15:40:21 +03:00

README.md

Manual Instrumentation for Spring Webflux

Provides OpenTelemetry instrumentation for Spring's WebClient.

Quickstart

Add these dependencies to your project.

Replace SPRING_VERSION with the version of spring you're using. Minimum version: 5.0

Replace OPENTELEMETRY_VERSION with the latest stable release. Minimum version: 0.8.0

For Maven add to your pom.xml:

<dependencies>
  <!-- opentelemetry instrumentation -->
  <dependency>
    <groupId>io.opentelemetry.instrumentation</groupId>
    <artifactId>opentelemetry-spring-webflux-5.0</artifactId>
    <version>OPENTELEMETRY_VERSION</version>
  </dependency>

   <!-- opentelemetry exporter -->
   <!-- replace this default exporter with your opentelemetry exporter (ex. otlp/zipkin/jaeger/..) -->
   <dependency>
    <groupId>io.opentelemetry</groupId>
    <artifactId>opentelemetry-exporters-logging</artifactId>
    <version>OPENTELEMETRY_VERSION</version>
  </dependency>

  <!-- required to instrument spring-webflux -->
  <!-- this artifact should already be present in your application -->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webflux</artifactId>
    <version>SPRING_VERSION</version>
  </dependency>

</dependencies>

For Gradle add to your dependencies:

// opentelemetry instrumentation
implementation 'io.opentelemetry.instrumentation:opentelemetry-spring-webflux-5.0:OPENTELEMETRY_VERSION'

// opentelemetry exporter
// replace this default exporter with your opentelemetry exporter (ex. otlp/zipkin/jaeger/..)
implementation 'io.opentelemetry:opentelemetry-exporters-logging:OPENTELEMETRY_VERSION'

// required to instrument spring-webmvc
// this artifact should already be present in your application
implementation 'org.springframework:spring-webflux:SPRING_VERSION'

Features

WebClientTracingFilter

WebClientTracingFilter adds OpenTelemetry client spans to requests sent using WebClient by implementing the ExchangeFilterFunction interface. An example is shown below:

Usage

import io.opentelemetry.instrumentation.spring.webflux.client.WebClientTracingFilter
import io.opentelemetry.api.trace.Tracer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;

@Configuration
public class WebClientConfig {

   @Bean
   public WebClient.Builder webClient(Tracer tracer) {

      WebClient webClient = WebClient.create();
      WebClientTracingFilter webClientTracingFilter = new WebClientTracingFilter(tracer);

      return webClient.mutate().filter(webClientTracingFilter);
   }
}

Starter Guide

Check out the opentelemetry quick start to learn more about OpenTelemetry instrumentation.