Use traceId as the judgment condition for sampling trace. (#5386)

This commit is contained in:
zifeihan 2020-08-26 16:45:02 +08:00 committed by GitHub
parent 77d94b4d2a
commit 720c1dd92f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -126,7 +126,7 @@ public class SegmentAnalysisListener implements FirstAnalysisListener, EntryAnal
@Override
public void parseSegment(SegmentObject segmentObject) {
if (sampleStatus.equals(SAMPLE_STATUS.UNKNOWN) || sampleStatus.equals(SAMPLE_STATUS.IGNORE)) {
if (sampler.shouldSample(segmentObject.getTraceSegmentId())) {
if (sampler.shouldSample(segmentObject.getTraceId())) {
sampleStatus = SAMPLE_STATUS.SAMPLED;
} else {
sampleStatus = SAMPLE_STATUS.IGNORE;

View File

@ -31,7 +31,7 @@ public class TraceSegmentSampler {
this.traceSampleRateWatcher = traceSampleRateWatcher;
}
public boolean shouldSample(String segmentId) {
return segmentId.hashCode() % 10000 < traceSampleRateWatcher.getSampleRate();
public boolean shouldSample(String traceId) {
return traceId.hashCode() % 10000 < traceSampleRateWatcher.getSampleRate();
}
}