Beispiel #1
0
        public void JaegerThriftSamplingStrategyResponse_FromThrift()
        {
            var opStrats = new List <JaegerThriftOperationSamplingStrategy>
            {
                new JaegerThriftOperationSamplingStrategy("operation1", new JaegerThriftProbabilisticSamplingStrategy(0.5)),
                new JaegerThriftOperationSamplingStrategy("operation2", new JaegerThriftProbabilisticSamplingStrategy(0.45))
            };
            var perOpStrats = new JaegerThriftPerOperationSamplingStrategies(0.33, 18, opStrats);

            var strat = new JaegerThriftSamplingStrategyResponse
            {
                ProbabilisticSampling = new JaegerThriftProbabilisticSamplingStrategy(0.85),
                RateLimitingSampling  = new JaegerThriftRateLimitingSamplingStrategy(25),
                OperationSampling     = perOpStrats
            };

            var from = strat.FromThrift();

            Assert.Equal(strat.ProbabilisticSampling.SamplingRate, from.ProbabilisticSampling.SamplingRate);
            Assert.Equal(strat.RateLimitingSampling.MaxTracesPerSecond, from.RateLimitingSampling.MaxTracesPerSecond);

            Assert.Equal(perOpStrats.DefaultSamplingProbability, from.OperationSampling.DefaultSamplingProbability);
            Assert.Equal(perOpStrats.DefaultLowerBoundTracesPerSecond, from.OperationSampling.DefaultLowerBoundTracesPerSecond);
            Assert.Equal(opStrats[0].Operation, from.OperationSampling.PerOperationStrategies[0].Operation);
            Assert.Equal(opStrats[0].ProbabilisticSampling.SamplingRate, from.OperationSampling.PerOperationStrategies[0].ProbabilisticSampling.SamplingRate);
            Assert.Equal(opStrats[1].Operation, from.OperationSampling.PerOperationStrategies[1].Operation);
            Assert.Equal(opStrats[1].ProbabilisticSampling.SamplingRate, from.OperationSampling.PerOperationStrategies[1].ProbabilisticSampling.SamplingRate);
        }
Beispiel #2
0
        public PerOperationSamplingStrategies DeepCopy()
        {
            var tmp6 = new PerOperationSamplingStrategies();

            tmp6.DefaultSamplingProbability       = this.DefaultSamplingProbability;
            tmp6.DefaultLowerBoundTracesPerSecond = this.DefaultLowerBoundTracesPerSecond;
            if ((PerOperationStrategies != null))
            {
                tmp6.PerOperationStrategies = this.PerOperationStrategies.DeepCopy();
            }
            if (__isset.defaultUpperBoundTracesPerSecond)
            {
                tmp6.DefaultUpperBoundTracesPerSecond = this.DefaultUpperBoundTracesPerSecond;
            }
            tmp6.__isset.defaultUpperBoundTracesPerSecond = this.__isset.defaultUpperBoundTracesPerSecond;
            return(tmp6);
        }
Beispiel #3
0
        public void JaegerThriftPerOperationSamplingStrategies_FromThrift()
        {
            var opStrats = new List <JaegerThriftOperationSamplingStrategy>
            {
                new JaegerThriftOperationSamplingStrategy("op1", new JaegerThriftProbabilisticSamplingStrategy(0.5)),
                new JaegerThriftOperationSamplingStrategy("op2", new JaegerThriftProbabilisticSamplingStrategy(0.45))
            };
            var strat = new JaegerThriftPerOperationSamplingStrategies(0.25, 10, opStrats);

            var from = strat.FromThrift();

            Assert.Equal(strat.DefaultSamplingProbability, from.DefaultSamplingProbability);
            Assert.Equal(strat.DefaultLowerBoundTracesPerSecond, from.DefaultLowerBoundTracesPerSecond);
            Assert.Equal(opStrats[0].Operation, from.PerOperationStrategies[0].Operation);
            Assert.Equal(opStrats[0].ProbabilisticSampling.SamplingRate, from.PerOperationStrategies[0].ProbabilisticSampling.SamplingRate);
            Assert.Equal(opStrats[1].Operation, from.PerOperationStrategies[1].Operation);
            Assert.Equal(opStrats[1].ProbabilisticSampling.SamplingRate, from.PerOperationStrategies[1].ProbabilisticSampling.SamplingRate);
        }
        public async Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                bool   isset_strategyType = false;
                TField field;
                await iprot.ReadStructBeginAsync(cancellationToken);

                while (true)
                {
                    field = await iprot.ReadFieldBeginAsync(cancellationToken);

                    if (field.Type == TType.Stop)
                    {
                        break;
                    }

                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.I32)
                        {
                            StrategyType = (SamplingStrategyType)await iprot.ReadI32Async(cancellationToken);

                            isset_strategyType = true;
                        }
                        else
                        {
                            await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.Struct)
                        {
                            ProbabilisticSampling = new ProbabilisticSamplingStrategy();
                            await ProbabilisticSampling.ReadAsync(iprot, cancellationToken);
                        }
                        else
                        {
                            await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.Struct)
                        {
                            RateLimitingSampling = new RateLimitingSamplingStrategy();
                            await RateLimitingSampling.ReadAsync(iprot, cancellationToken);
                        }
                        else
                        {
                            await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                        }
                        break;

                    case 4:
                        if (field.Type == TType.Struct)
                        {
                            OperationSampling = new PerOperationSamplingStrategies();
                            await OperationSampling.ReadAsync(iprot, cancellationToken);
                        }
                        else
                        {
                            await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                        }
                        break;

                    default:
                        await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);

                        break;
                    }

                    await iprot.ReadFieldEndAsync(cancellationToken);
                }

                await iprot.ReadStructEndAsync(cancellationToken);

                if (!isset_strategyType)
                {
                    throw new TProtocolException(TProtocolException.INVALID_DATA);
                }
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }