Esempio n. 1
0
        private void TraceStartInternal(string operationMemberName, string operationFilePath)
        {
            var fileName = Path.GetFileNameWithoutExtension(operationFilePath);

            CallTreeTrace = new ProducerTrace(
                AppInfoProvider.Service.Name,
                $"{fileName}:{operationMemberName}");
        }
Esempio n. 2
0
 public void ShouldNotSetCurrentTrace()
 {
     Trace.Current = null;
     using (var producer = new ProducerTrace(serviceName, rpc))
     {
         Assert.IsNull(producer.Trace);
     }
 }
Esempio n. 3
0
        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!"));
            }
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
        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)));
        }