/// <summary> /// Instantiate a rate limited IZipkinSender which use an underlying IZipkinSender to send data. /// The average sending rate is given by maxSendRequest / duration, instantaneous rate can be much higher. /// </summary> /// <param name="sender">The underlying IZipkinSender</param> /// <param name="maxSendRequest">The maximum send requests per duration aka the bucket size</param> /// <param name="duration">TimeSpan necessary to refill the bucket</param> public RateLimiterZipkinSender(IZipkinSender sender, int maxSendRequest = 15, TimeSpan?duration = null) { _underlyingSender = sender; MaxSendRequests = maxSendRequest; Duration = duration ?? TimeSpan.FromSeconds(1); _logPeriod = TimeSpan.FromTicks(Duration.Ticks * 10); _requestsReceived = 0; _throttledRequests = 0; _currentLogPeriod = new Stopwatch(); _bucket = MaxSendRequests; _timeSinceLastRequest = Stopwatch.StartNew(); Rate = MaxSendRequests / Duration.TotalMilliseconds; }
public ZipkinTracer(IZipkinSender sender, ISpanSerializer spanSerializer, IStatistics statistics = null) { if (sender == null) { throw new ArgumentNullException("sender", "You have to specify a non-null sender for Zipkin tracer."); } Statistics = statistics ?? new Statistics(); _spanSender = sender; if (spanSerializer == null) { throw new ArgumentNullException("spanSerializer", "You have to specify a non-null span serializer for Zipkin tracer."); } _spanSerializer = spanSerializer; _flushTimer = new Timer(_ => FlushOldSpans(TimeUtils.UtcNow), null, TimeToLive, TimeToLive); }
internal ZipkinTracerReporter(IZipkinSender sender, ISpanSerializer spanSerializer, IStatistics statistics) { if (sender == null) { throw new ArgumentNullException(nameof(sender), "You have to specify a non-null sender."); } if (spanSerializer == null) { throw new ArgumentNullException(nameof(spanSerializer), "You have to specify a non-null span serializer."); } if (statistics == null) { throw new ArgumentNullException(nameof(statistics), "You have to specify a non-null statistics."); } _sender = sender; _spanSerializer = spanSerializer; _statistics = statistics; }
public ZipkinTracer(IZipkinSender sender, ISpanSerializer spanSerializer, IStatistics statistics) : this(new ZipkinTracerReporter(sender, spanSerializer, statistics), statistics) { }
public ZipkinTracer(IZipkinSender sender, ISpanSerializer spanSerializer) : this(sender, spanSerializer, new Statistics()) { }
public void ShouldThrowWithNullSender() { IZipkinSender sender = null; Assert.Throws <ArgumentNullException>(() => { var tracer = new ZipkinTracer(sender, Mock.Of <ISpanSerializer>()); }); }
public ZipkinTracer(IZipkinSender sender, IStatistics statistics = null) : this(sender, new ThriftSpanSerializer(), statistics) { }