@Test public void testSample51Percent() throws Exception { tracingPlugin.getDefaultRateLimitSpansPercentOption().update(0.51, SimpleSource.NAME); int reports = 0; for (int i = 0; i < 100; i++) { final PreExecutionInterceptorContext context = new PreExecutionInterceptorContext(spanContext); interceptor.interceptReport(context); if (context.isReport()) { reports++; } } assertThat(reports).isEqualTo(51); }
@Override public void interceptReport(PreExecutionInterceptorContext context) { final SpanContextInformation spanContext = context.getSpanContext(); final BitSet sampleDecisions; final String operationType = spanContext.getOperationType(); if (sampleDecisionsByType.containsKey(operationType)) { sampleDecisions = sampleDecisionsByType.get(operationType); } else if (isRoot(context.getSpanContext().getSpanWrapper())) { sampleDecisions = defaultSampleDecisions; } else { return; } if (sampleDecisions != null && !isSampled(sampleDecisions, spanCounter)) { context.shouldNotReport(getClass()); } }
ProbabilisticSamplingPreExecutionInterceptor extends PreExecutionSpanInterceptor { @Override public void interceptReport(PreExecutionInterceptorContext context) { final SpanContextInformation spanContext = context.getSpanContext(); final BitSet sampleDecisions; final String operationType = spanContext.getOperationType(); if (sampleDecisionsByType.containsKey(operationType)) { sampleDecisions = sampleDecisionsByType.get(operationType); } else if (isRoot(context.getSpanContext().getSpanWrapper())) { sampleDecisions = defaultSampleDecisions; } else { return; } if (sampleDecisions != null && !isSampled(sampleDecisions, spanCounter)) { context.shouldNotReport(getClass()); } } }
ProbabilisticSamplingPreExecutionInterceptor extends PreExecutionSpanInterceptor { @Override public void interceptReport(PreExecutionInterceptorContext context) { final SpanContextInformation spanContext = context.getSpanContext(); final BitSet sampleDecisions; final String operationType = spanContext.getOperationType(); if (sampleDecisionsByType.containsKey(operationType)) { sampleDecisions = sampleDecisionsByType.get(operationType); } else if (isRoot(context.getSpanContext().getSpanWrapper())) { sampleDecisions = defaultSampleDecisions; } else { return; } if (sampleDecisions != null && !isSampled(sampleDecisions, spanCounter)) { context.shouldNotReport(getClass()); } }  }
ProbabilisticSamplingPreExecutionInterceptor extends PreExecutionSpanInterceptor { @Override public void interceptReport(PreExecutionInterceptorContext context) { final SpanContextInformation spanContext = context.getSpanContext(); final BitSet sampleDecisions; final String operationType = spanContext.getOperationType(); if (sampleDecisionsByType.containsKey(operationType)) { sampleDecisions = sampleDecisionsByType.get(operationType); } else if (isRoot(context.getSpanContext().getSpanWrapper())) { sampleDecisions = defaultSampleDecisions; } else { return; } if (sampleDecisions != null && !isSampled(sampleDecisions, spanCounter)) { context.shouldNotReport(getClass()); } }  @Override void init(ConfigurationRegistry configuration); @Override void interceptReport(PreExecutionInterceptorContext context); }
ProbabilisticSamplingPreExecutionInterceptor extends PreExecutionSpanInterceptor { @Override public void interceptReport(PreExecutionInterceptorContext context) { final SpanContextInformation spanContext = context.getSpanContext(); final BitSet sampleDecisions; final String operationType = spanContext.getOperationType(); if (sampleDecisionsByType.containsKey(operationType)) { sampleDecisions = sampleDecisionsByType.get(operationType); } else if (isRoot(context.getSpanContext().getSpanWrapper())) { sampleDecisions = defaultSampleDecisions; } else { return; } if (sampleDecisions != null && !isSampled(sampleDecisions, spanCounter)) { context.shouldNotReport(getClass()); } }  @Override void init(ConfigurationRegistry configuration); @Override void interceptReport(PreExecutionInterceptorContext context);  }