diff --git a/spring-boot-jaeger-example/pom.xml b/spring-boot-jaeger-example/pom.xml index d1e8c32..c881064 100644 --- a/spring-boot-jaeger-example/pom.xml +++ b/spring-boot-jaeger-example/pom.xml @@ -97,7 +97,7 @@ ${hystrix.version} - + + <!– OpenTracing impl - Jaeger –> com.uber.jaeger jaeger-core + --> + + + + org.jboss.snowdrop + spring-cloud-starter-kubernetes-jaeger + 0.1.0-SNAPSHOT + io.swagger diff --git a/spring-boot-jaeger-example/src/main/java/org/jboss/snowdrop/TracingConfiguration.java b/spring-boot-jaeger-example/src/main/java/org/jboss/snowdrop/TracingConfiguration.java index b74a239..03f290c 100644 --- a/spring-boot-jaeger-example/src/main/java/org/jboss/snowdrop/TracingConfiguration.java +++ b/spring-boot-jaeger-example/src/main/java/org/jboss/snowdrop/TracingConfiguration.java @@ -3,27 +3,18 @@ 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 @@ -31,30 +22,9 @@ @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() { diff --git a/spring-boot-jaeger-example/src/main/resources/application.properties b/spring-boot-jaeger-example/src/main/resources/application.properties index a770769..910eac0 100644 --- a/spring-boot-jaeger-example/src/main/resources/application.properties +++ b/spring-boot-jaeger-example/src/main/resources/application.properties @@ -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 \ No newline at end of file +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 \ No newline at end of file