private bool GetSampled(SegmentContext parentSegmentContext, string operationName,
                                StringOrIntValue peer = default(StringOrIntValue))
        {
            if (parentSegmentContext != null)
            {
                return(parentSegmentContext.Sampled);
            }
            var sampledContext = new SamplingContext(operationName, peer, new StringOrIntValue(operationName),
                                                     default(StringOrIntValue));
            var sampler = _samplerChainBuilder.Build();

            return(sampler(sampledContext));
        }
        private bool GetSampled(ICarrier carrier, string operationName)
        {
            if (carrier.HasValue && carrier.Sampled.HasValue)
            {
                return(carrier.Sampled.Value);
            }

            SamplingContext samplingContext;

            if (carrier.HasValue)
            {
                samplingContext = new SamplingContext(operationName, carrier.NetworkAddress, carrier.EntryEndpoint,
                                                      carrier.ParentEndpoint);
            }
            else
            {
                samplingContext = new SamplingContext(operationName, default(StringOrIntValue), default(StringOrIntValue),
                                                      default(StringOrIntValue));
            }

            var sampler = _samplerChainBuilder.Build();

            return(sampler(samplingContext));
        }