private void TraceStartInternal(string operationMemberName, string operationFilePath) { var fileName = Path.GetFileNameWithoutExtension(operationFilePath); CallTreeTrace = new ProducerTrace( AppInfoProvider.Service.Name, $"{fileName}:{operationMemberName}"); }
public void ShouldNotSetCurrentTrace() { Trace.Current = null; using (var producer = new ProducerTrace(serviceName, rpc)) { Assert.IsNull(producer.Trace); } }
static async Task TracedProduceMessage(string text) { using (var messageProducerTrace = new ProducerTrace("message.producer", "create message")) { // TracedActionAsync extension method logs error annotation if exception occurs await messageProducerTrace.TracedActionAsync(ProduceMessage(messageProducerTrace.Trace.CurrentSpan, text)); messageProducerTrace.AddAnnotation(Annotations.Tag("sampleProducerTag", "success!")); } }
public void ShouldCallChildWhenCurrentTraceNotNull() { var trace = Trace.Create(); Trace.Current = trace; using (var producer = new ProducerTrace(serviceName, rpc)) { Assert.AreEqual(trace.CurrentSpan.SpanId, producer.Trace.CurrentSpan.ParentSpanId); Assert.AreEqual(trace.CurrentSpan.TraceId, producer.Trace.CurrentSpan.TraceId); } }
public void ShouldLogProducerAnnotations() { // Arrange dispatcher .Setup(h => h.Dispatch(It.IsAny <Record>())) .Returns(true); // Act var trace = Trace.Create(); trace.ForceSampled(); Trace.Current = trace; using (var producer = new ProducerTrace(serviceName, rpc)) { // Assert dispatcher .Verify(h => h.Dispatch(It.Is <Record>(m => m.Annotation is ProducerStart))); dispatcher .Verify(h => h.Dispatch(It.Is <Record>(m => m.Annotation is ServiceName && ((ServiceName)m.Annotation).Service == serviceName))); dispatcher .Verify(h => h.Dispatch(It.Is <Record>(m => m.Annotation is Rpc && ((Rpc)m.Annotation).Name == rpc))); } // Assert dispatcher .Verify(h => h.Dispatch(It.Is <Record>(m => m.Annotation is ProducerStop))); }