public void Spans_Without_Service_Tag_Are_Not_Queued() { var tracer = new ThresholdLoggingTracer(); var span = new Span(tracer, "operation", null, Stopwatch.GetTimestamp(), null, null); Assert.AreEqual(0, tracer.QueuedSpansCount); tracer.ReportSpan(span); Assert.AreEqual(0, tracer.QueuedSpansCount); }
public void Spans_With_Ignore_Tag_Are_Not_Queued() { var tracer = new ThresholdLoggingTracer(); var span = new Span(tracer, "operation", null, Stopwatch.GetTimestamp(), null, null); span.Tags.Add(CouchbaseTags.Ignore, true); Assert.AreEqual(0, tracer.QueuedSpansCount); tracer.ReportSpan(span); Assert.AreEqual(0, tracer.QueuedSpansCount); }
public void Can_Add_Span() { var tracer = new ThresholdLoggingTracer(); var span = new Span(tracer, "operation", null, Stopwatch.GetTimestamp(), null, null); span.Tags.Add(CouchbaseTags.Service, CouchbaseTags.ServiceKv); Assert.AreEqual(0, tracer.QueuedSpansCount); tracer.ReportSpan(span); Assert.AreEqual(1, tracer.QueuedSpansCount); }
public void ThresholdLoggingTracer_has_correct_default_values() { var tracer = new ThresholdLoggingTracer(); Assert.AreEqual(10000, tracer.Interval); Assert.AreEqual(10, tracer.SampleSize); Assert.AreEqual(500000, tracer.KvThreshold); Assert.AreEqual(1000000, tracer.ViewThreshold); Assert.AreEqual(1000000, tracer.N1qlThreshold); Assert.AreEqual(1000000, tracer.SearchThreshold); Assert.AreEqual(1000000, tracer.AnalyticsThreshold); }
public void Creating_span_with_ignore_flag_is_not_related_to_wrapping_span() { var tracer = new ThresholdLoggingTracer(); var mockOperation = new Mock <IOperation>(); using (var wrappingScope = tracer.BuildSpan("wrapping-span").StartActive()) { using (var scope = tracer.StartParentScope(mockOperation.Object, "bucket", ignoreActiveSpan: true)) { // should not be the same trace ID as wrapping span Assert.AreNotEqual(wrappingScope.Span.Context.TraceId, scope.Span.Context.TraceId); } } }
public async Task Can_Add_Span() { var tracer = new ThresholdLoggingTracer(); var span = new Span(tracer, "operation", null, Stopwatch.GetTimestamp(), null, null); span.Tags.Add(CouchbaseTags.Service, CouchbaseTags.ServiceKv); Assert.AreEqual(0, tracer.QueuedSpansCount); tracer.ReportSpan(span); await Task.Delay(TimeSpan.FromMilliseconds(100)); Assert.AreEqual(1, tracer.QueuedSpansCount); }
public void Spans_Are_Processed_After_Some_Time() { var tracer = new ThresholdLoggingTracer(500, 10, new Dictionary <string, int> { { "kv", 100 } }); var span = new Span(tracer, "operation", null, Stopwatch.GetTimestamp(), null, null); span.Tags.Add(CouchbaseTags.Service, CouchbaseTags.ServiceKv); tracer.ReportSpan(span); Assert.AreEqual(1, tracer.QueuedSpansCount); Thread.Sleep(TimeSpan.FromSeconds(2)); Assert.AreEqual(0, tracer.QueuedSpansCount); }
public async Task Test_logging_output() { var random = new Random(); var tracer = new ThresholdLoggingTracer { Interval = 100, KvThreshold = 50 }; foreach (var i in Enumerable.Range(1, 100)) { var parentSpan = tracer.BuildSpan("get") .WithTag(CouchbaseTags.OperationId, $"0x{i}") .WithTag(CouchbaseTags.Service, CouchbaseTags.ServiceKv) .Start(); using (tracer.BuildSpan(CouchbaseOperationNames.RequestEncoding) .AsChildOf(parentSpan) .StartActive()) { await Task.Delay(TimeSpan.FromMilliseconds(random.Next(1, 10))); } using (var scope = tracer.BuildSpan(CouchbaseOperationNames.DispatchToServer) .AsChildOf(parentSpan) .StartActive()) { scope.Span.SetPeerLatencyTag(random.Next(10, 100)); await Task.Delay(TimeSpan.FromMilliseconds(random.Next(1, 10))); } using (tracer.BuildSpan(CouchbaseOperationNames.ResponseDecoding).AsChildOf(parentSpan).StartActive()) { await Task.Delay(TimeSpan.FromMilliseconds(random.Next(1, 10))); } await Task.Delay(TimeSpan.FromMilliseconds(10)); parentSpan.Finish(); await Task.Delay(10); } await Task.Delay(5000); }
public void ThresholdLoggingTracer_has_correct_default_values() { var tracer = new ThresholdLoggingTracer(); Assert.AreEqual(10000, tracer.Interval); Assert.AreEqual(10, tracer.SampleSize); var serviceFloors = new Dictionary <string, int> { { "kv", 500000 }, // 500 milliseconds { "view", 1000000 }, // 1 second { "n1ql", 1000000 }, // 1 second { "search", 1000000 }, // 1 second { "analytics", 1000000 } // 1 second }; Assert.AreEqual(serviceFloors, tracer.ServiceFloors); }
public void ThresholdLoggingTracer_can_override_defaults() { const int interval = 5000; const int sampleSize = 20; var serviceFloors = new Dictionary <string, int> { { "kv", 250000 }, // 250 ms { "view", 250000 }, // 250 ms { "n1ql", 250000 }, // 250 ms { "search", 250000 }, // 250 ms { "analytics", 250000 } // 250 ms }; var tracer = new ThresholdLoggingTracer(interval, sampleSize, serviceFloors); Assert.AreEqual(interval, tracer.Interval); Assert.AreEqual(sampleSize, tracer.SampleSize); Assert.AreEqual(serviceFloors, tracer.ServiceFloors); }
public void Can_override_default_configuration_values() { var tracer = new ThresholdLoggingTracer { KvThreshold = 100, ViewThreshold = 110, N1qlThreshold = 120, SearchThreshold = 130, AnalyticsThreshold = 140, SampleSize = 150, Interval = 160 }; Assert.AreEqual(100, tracer.KvThreshold); Assert.AreEqual(110, tracer.ViewThreshold); Assert.AreEqual(120, tracer.N1qlThreshold); Assert.AreEqual(130, tracer.SearchThreshold); Assert.AreEqual(140, tracer.AnalyticsThreshold); Assert.AreEqual(150, tracer.SampleSize); Assert.AreEqual(160, tracer.Interval); }
public async Task Can_add_lots_of_spans_concurrently() { var tracer = new ThresholdLoggingTracer { KvThreshold = 1 // really low threshold so all spans are logged }; var tasks = Enumerable.Range(1, 1000).Select(x => { var span = tracer.BuildSpan(x.ToString()).WithTag(CouchbaseTags.Service, CouchbaseTags.ServiceKv).Start(); span.Finish(DateTimeOffset.UtcNow + TimeSpan.FromMilliseconds(1)); return(Task.FromResult(true)); }); // schedule all the tasks using threadpool await Task.WhenAll(tasks); // wait for queue to flush await Task.Delay(1000); // check all items made it into sample Assert.AreEqual(1000, tracer.TotalSummaryCount); }
public void ThresholdLoggingTracer_can_override_defaults() { const int interval = 5000; const int sampleSize = 20; var tracer = new ThresholdLoggingTracer { Interval = interval, SampleSize = sampleSize, KvThreshold = 250000, ViewThreshold = 250000, N1qlThreshold = 250000, SearchThreshold = 250000, AnalyticsThreshold = 250000 }; Assert.AreEqual(interval, tracer.Interval); Assert.AreEqual(sampleSize, tracer.SampleSize); Assert.AreEqual(250000, tracer.KvThreshold); Assert.AreEqual(250000, tracer.ViewThreshold); Assert.AreEqual(250000, tracer.N1qlThreshold); Assert.AreEqual(250000, tracer.SearchThreshold); Assert.AreEqual(250000, tracer.AnalyticsThreshold); }