public async Task DisjointThreads_Annotate() { var mockConsumer = new Mock <IConsumer <TraceProto> >(); var tracer = SimpleManagedTracer.Create(mockConsumer.Object, ProjectId, TraceId); mockConsumer.Setup(c => c.Receive( Match.Create <IEnumerable <TraceProto> >( tProto => IsValidSpan(tProto.Single().Spans.Single(), "span-name")))); var annotation = new Dictionary <string, string> { { "new", "label" } }; Predicate <IEnumerable <TraceProto> > matcher = t => { var singleSpan = t.Single().Spans.Single(); return(IsValidSpan(singleSpan, "span-name") && string.IsNullOrWhiteSpace(singleSpan.Labels[TraceLabels.StackTrace]) && TraceUtils.IsValidAnnotation(singleSpan, annotation)); }; mockConsumer.Setup(c => c.Receive(Match.Create(matcher))); ISpan span = null; await RunInDisjointThreads(() => span = tracer.StartSpan("span-name"), () => { span.SetStackTrace(FilledStackTrace); span.AnnotateSpan(annotation); span.Dispose(); }); mockConsumer.Verify(); }
internal void EndRequest(object sender, EventArgs e) { ISpan span = ContextInstanceManager.Get <ISpan>(); if (span == null) { return; } // End the span and annotate it with information from the current response. span.AnnotateSpan(Labels.FromHttpResponse(HttpContext.Current.Response)); span.Dispose(); }