Introduce sampling logic when incoming request has only trace and span ids

without this change when there were tracing headers without sampled decision, we always exported the span.
with this change if:

Trace Id and Span Id are set but there is no Sampled flag - delegate sampling decision to Sampler
Trace Id and Span Id and Sampled flag are set - pass the value from Sampled Flag

fixes gh-1115
This commit is contained in:
Marcin Grzejszczak
2018-10-25 23:26:12 +02:00
parent 6839a23183
commit 88d17f79f3
7 changed files with 166 additions and 17 deletions

View File

@@ -25,6 +25,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
@@ -186,5 +187,9 @@ public class MessagingApplicationTests extends AbstractIntegrationTest {
Reporter<Span> integrationTestZipkinSpanReporter() {
return new IntegrationTestZipkinSpanReporter();
}
@Bean AlwaysSampler sampler() {
return new AlwaysSampler();
}
}
}