From fcd1ada1ecc387b07b80bc256ec54f50fea7a302 Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Mon, 3 Aug 2015 16:02:09 -0600 Subject: [PATCH] Allow sample to enable log collector with a property. Property is sleuth.sample.logging.collector.enabled=true --- docs/src/main/asciidoc/README.adoc | 2 +- .../cloud/sleuth/sample/SampleApplication.java | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/src/main/asciidoc/README.adoc b/docs/src/main/asciidoc/README.adoc index 54d4ffbf5..c48ee2a0a 100644 --- a/docs/src/main/asciidoc/README.adoc +++ b/docs/src/main/asciidoc/README.adoc @@ -32,7 +32,7 @@ logging: WARNING: The docker images for zipkin are old and don't work very well (the UI in particular). Zipkin is in a state of flux, but it should settle down soon when there is an actual release. Best results actually come from building from source and running the jar files (the query and collector services need command line arguments, so check the zipkin README for updates). -NOTE: You can see the zipkin spans without the UI (in logs) if you just provide a `@Bean` of type `LogSpanCollector` (there's one commented out in the sample). +NOTE: You can see the zipkin spans without the UI (in logs) if you run the sample with `sleuth.sample.logging.collector.enabled=true`. == Building diff --git a/spring-cloud-sleuth-sample/src/main/java/org/springframework/cloud/sleuth/sample/SampleApplication.java b/spring-cloud-sleuth-sample/src/main/java/org/springframework/cloud/sleuth/sample/SampleApplication.java index 6dbea2069..9d12efde8 100644 --- a/spring-cloud-sleuth-sample/src/main/java/org/springframework/cloud/sleuth/sample/SampleApplication.java +++ b/spring-cloud-sleuth-sample/src/main/java/org/springframework/cloud/sleuth/sample/SampleApplication.java @@ -1,7 +1,10 @@ package org.springframework.cloud.sleuth.sample; +import com.github.kristofa.brave.LoggingSpanCollectorImpl; +import com.github.kristofa.brave.SpanCollector; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.cloud.sleuth.Sampler; import org.springframework.cloud.sleuth.sampler.AlwaysSampler; import org.springframework.context.annotation.Bean; @@ -33,9 +36,10 @@ public class SampleApplication { } // Use this for debugging (or if there is no Zipkin collector running on port 9410) - // @Bean - // public SpanCollector spanCollector() { - // return new LoggingSpanCollectorImpl(); - // } + @Bean + @ConditionalOnProperty("sleuth.sample.logging.collector.enabled") + public SpanCollector spanCollector() { + return new LoggingSpanCollectorImpl(); + } }