Add Span to Sampler method params

Also allows us to actually create a PercentageBasedSampler (I
don't think anyone tried it before) without resorting to
lazy beans and proxies.

Another freature added here is a default percentage sampler
if we know that spans need to be exported (zipkin or stream
is present).

Fixes gh-138
This commit is contained in:
Dave Syer
2016-02-01 17:00:00 +00:00
parent 065338118b
commit 70b18054e1
16 changed files with 73 additions and 97 deletions

View File

@@ -16,17 +16,16 @@
package sample;
import lombok.extern.slf4j.Slf4j;
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.cloud.sleuth.zipkin.ZipkinSpanReporter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;
import lombok.extern.slf4j.Slf4j;
/**
* @author Spencer Gibb
*/
@@ -36,14 +35,6 @@ import org.springframework.scheduling.annotation.EnableAsync;
@Slf4j
public class SampleZipkinApplication {
/**
* Sleuth will not report trace data unless you define a sampler like below.
*/
@Bean
public Sampler defaultSampler() {
return new AlwaysSampler();
}
public static void main(String[] args) {
SpringApplication.run(SampleZipkinApplication.class, args);
}

View File

@@ -12,4 +12,4 @@ spring:
sample:
zipkin:
# When enabled=false, traces log to the console. Comment to send to zipkin
enabled: true
enabled: false