public void DefaultTraceParams()
 {
     Assert.Equal(Samplers.GetProbabilitySampler(1e-4), TraceParams.Default.Sampler);
     Assert.Equal(32, TraceParams.Default.MaxNumberOfAttributes);
     Assert.Equal(32, TraceParams.Default.MaxNumberOfAnnotations);
     Assert.Equal(128, TraceParams.Default.MaxNumberOfMessageEvents);
     Assert.Equal(128, TraceParams.Default.MaxNumberOfLinks);
 }
Beispiel #2
0
        public void ProbabilitySampler_DifferentProbabilities_SampledParentLink()
        {
            ISampler neverSample = Samplers.GetProbabilitySampler(0.0);

            AssertSamplerSamplesWithProbability(
                neverSample, notSampledSpanContext, new List <ISpan>()
            {
                sampledSpan
            }, 1.0);
            ISampler alwaysSample = Samplers.GetProbabilitySampler(1.0);

            AssertSamplerSamplesWithProbability(
                alwaysSample, notSampledSpanContext, new List <ISpan>()
            {
                sampledSpan
            }, 1.0);
            ISampler fiftyPercentSample = Samplers.GetProbabilitySampler(0.5);

            AssertSamplerSamplesWithProbability(
                fiftyPercentSample, notSampledSpanContext, new List <ISpan>()
            {
                sampledSpan
            }, 1.0);
            ISampler twentyPercentSample = Samplers.GetProbabilitySampler(0.2);

            AssertSamplerSamplesWithProbability(
                twentyPercentSample, notSampledSpanContext, new List <ISpan>()
            {
                sampledSpan
            }, 1.0);
            ISampler twoThirdsSample = Samplers.GetProbabilitySampler(2.0 / 3.0);

            AssertSamplerSamplesWithProbability(
                twoThirdsSample, notSampledSpanContext, new List <ISpan>()
            {
                sampledSpan
            }, 1.0);
        }
Beispiel #3
0
        public void ProbabilitySampler_ToString()
        {
            var result = Samplers.GetProbabilitySampler(0.5).ToString();

            Assert.Contains($"0{CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator}5", result);
        }
Beispiel #4
0
 public void ProbabilitySampler_getDescription()
 {
     Assert.Equal(String.Format("ProbabilitySampler({0:F6})", 0.5), Samplers.GetProbabilitySampler(0.5).Description);
 }
Beispiel #5
0
        public void ProbabilitySampler_SampleBasedOnTraceId()
        {
            ISampler defaultProbability = Samplers.GetProbabilitySampler(0.0001);
            // This traceId will not be sampled by the ProbabilitySampler because the first 8 bytes as long
            // is not less than probability * Long.MAX_VALUE;
            ITraceId notSampledtraceId =
                TraceId.FromBytes(
                    new byte[] {
                0x8F,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
            });

            Assert.False(
                defaultProbability.ShouldSample(
                    null,
                    false,
                    notSampledtraceId,
                    SpanId.GenerateRandomId(random),
                    SPAN_NAME,
                    new List <ISpan>()));
            // This traceId will be sampled by the ProbabilitySampler because the first 8 bytes as long
            // is less than probability * Long.MAX_VALUE;
            ITraceId sampledtraceId =
                TraceId.FromBytes(
                    new byte[] {
                0x00,
                0x00,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
            });

            Assert.True(
                defaultProbability.ShouldSample(
                    null,
                    false,
                    sampledtraceId,
                    SpanId.GenerateRandomId(random),
                    SPAN_NAME,
                    new List <ISpan>()));
        }
Beispiel #6
0
 public void ProbabilitySampler_OutOfRangeLowProbability()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Samplers.GetProbabilitySampler(-0.00001));
 }
Beispiel #7
0
 public void ProbabilitySampler_ToString()
 {
     Assert.Contains("0.5", Samplers.GetProbabilitySampler(0.5).ToString());
 }