Skip to content

Commit

Permalink
Refactor project to use spring boot jaeger
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoulliard committed Jul 4, 2017
1 parent 4c6e707 commit c7c4552
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 40 deletions.
13 changes: 10 additions & 3 deletions spring-boot-jaeger-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<version>${hystrix.version}</version>
</dependency>

<!-- OpenTracing -->
<!-- &lt;!&ndash; OpenTracing &ndash;&gt;
<dependency>
<groupId>io.opentracing</groupId>
<artifactId>opentracing-noop</artifactId>
Expand All @@ -106,13 +106,20 @@
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-web-autoconfigure</artifactId>
</dependency>

<!-- OpenTracing implementation - Jaeger -->
&lt;!&ndash; OpenTracing impl - Jaeger &ndash;&gt;
<dependency>
<groupId>com.uber.jaeger</groupId>
<artifactId>jaeger-core</artifactId>
</dependency>-->

<!-- Spring Boot Starter - OpenTracing / Jaeger -->
<dependency>
<groupId>org.jboss.snowdrop</groupId>
<artifactId>spring-cloud-starter-kubernetes-jaeger</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>


<!-- Swagger -->
<dependency>
<groupId>io.swagger</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,28 @@
import java.util.Collections;
import java.util.regex.Pattern;

import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.uber.jaeger.metrics.Metrics;
import com.uber.jaeger.metrics.NullStatsReporter;
import com.uber.jaeger.metrics.StatsFactoryImpl;
import com.uber.jaeger.reporters.RemoteReporter;
import com.uber.jaeger.samplers.ProbabilisticSampler;
import com.uber.jaeger.senders.Sender;
import com.uber.jaeger.senders.UdpSender;

import feign.Logger;
import feign.httpclient.ApacheHttpClient;
import feign.hystrix.HystrixFeign;
import feign.jackson.JacksonDecoder;
import feign.opentracing.TracingClient;
import feign.opentracing.hystrix.TracingConcurrencyStrategy;
import io.opentracing.NoopTracerFactory;
import io.opentracing.Tracer;
import io.opentracing.contrib.spring.web.autoconfig.WebTracingConfiguration;
import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* @author Pavol Loffay
*/
@Configuration
public class TracingConfiguration {
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TracingConfiguration.class);
private static final String SERVICE_NAME = "ola";

@Bean
public Tracer tracer() {
String jaegerURL = System.getenv("JAEGER_SERVER_HOSTNAME");
if (jaegerURL != null) {
log.info("Using Jaeger tracer");
return jaegerTracer(jaegerURL);
}

log.info("Using Noop tracer");
return NoopTracerFactory.create();
}


private Tracer jaegerTracer(String url) {
Sender sender = new UdpSender(url, 0, 0);
return new com.uber.jaeger.Tracer.Builder(SERVICE_NAME,
new RemoteReporter(sender, 100, 50,
new Metrics(new StatsFactoryImpl(new NullStatsReporter()))),
new ProbabilisticSampler(1.0))
.build();
}

@Autowired
public Tracer tracer;

@Bean
public WebTracingConfiguration webTracingConfiguration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ keycloak.cors = true
keycloak.credentials.secret = 11111111-1111-1111-1111-111111111111
keycloak.securityConstraints[0].securityCollections[0].name = spring secured api
keycloak.securityConstraints[0].securityCollections[0].authRoles[0] = USERS
keycloak.securityConstraints[0].securityCollections[0].patterns[0] = /api/ola-secured
keycloak.securityConstraints[0].securityCollections[0].patterns[0] = /api/ola-secured

spring.cloud.kubernetes.jaeger.discovery.tracerServerName = jaeger-all-in-one
spring.cloud.kubernetes.jaeger.discovery.serviceName = ola

0 comments on commit c7c4552

Please sign in to comment.