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

            CallTreeTrace = new ConsumerTrace(
                AppInfoProvider.Service.Name,
                $"{fileName}:{operationMemberName}");
        }
Exemplo n.º 2
0
 public void ShouldSetCurrentTraceIfInvalidTraceInformationIsPassed()
 {
     TraceManager.SamplingRate = 1.0f;
     using (var client = new ConsumerTrace(serviceName, rpc, null, null, null, null, null))
     {
         Assert.IsNotNull(client.Trace);
     }
 }
Exemplo n.º 3
0
        public void TraceStart(
            [CallerMemberName] string callerMemberName = "",
            [CallerFilePath] string callerFilePath     = "")
        {
            var fileName = Path.GetFileNameWithoutExtension(callerFilePath);

            CallTreeTrace = new ConsumerTrace(
                AppInfoProvider.Service.Name,
                $"{fileName}:{callerMemberName}");
        }
Exemplo n.º 4
0
        static async Task ProcessMessage(Message message)
        {
            // need to supply trace information from producer
            using (var messageConsumerTrace = new ConsumerTrace(
                       serviceName: "message.consumer",
                       rpc: "process message",
                       encodedTraceId: message.TraceId,
                       encodedSpanId: message.SpanId,
                       encodedParentSpanId: message.ParentId,
                       sampledStr: message.Sampled,
                       flagsStr: message.Flags.ToString(CultureInfo.InvariantCulture)))
            {
                await messageConsumerTrace.TracedActionAsync(Task.Delay(600)); // Test delay for mock processing

                messageConsumerTrace.AddAnnotation(Annotations.Tag("sampleConsumerTag", "success!"));
            }
        }
Exemplo n.º 5
0
        public void ShouldSetChildTraceIfValidTraceInformationIsPassed()
        {
            TraceManager.SamplingRate = 1.0f;
            var rootTrace = Trace.Create();
            var trace     = rootTrace.Child();
            var context   = trace.CurrentSpan;

            using (var client = new ConsumerTrace(serviceName, rpc,
                                                  context.SerializeTraceId(),
                                                  context.SerializeSpanId(),
                                                  context.SerializeParentSpanId(),
                                                  context.SerializeSampledKey(),
                                                  context.SerializeDebugKey()))
            {
                Assert.AreEqual(trace.CurrentSpan.SpanId, client.Trace.CurrentSpan.ParentSpanId);
                Assert.AreEqual(trace.CurrentSpan.TraceId, client.Trace.CurrentSpan.TraceId);
            }
        }
Exemplo n.º 6
0
        public void ShouldLogConsumerAnnotations()
        {
            // Arrange
            dispatcher
            .Setup(h => h.Dispatch(It.IsAny <Record>()))
            .Returns(true);

            // Act
            TraceManager.SamplingRate = 1.0f;
            using (var server = new ConsumerTrace(serviceName, rpc, null, null, null, null, null))
            {
                // Assert
                dispatcher
                .Verify(h =>
                        h.Dispatch(It.Is <Record>(m =>
                                                  m.Annotation is ConsumerStart)));

                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 ConsumerStop)));
        }