예제 #1
0
        public void CapErrorConsume([Object] CapEventDataSubStore eventData)
        {
            var context = _entrySegmentContextAccessor.Context;

            if (context == null)
            {
                return;
            }

            context.Span.AddLog(LogEvent.Event("Event Persistence"));
            context.Span.AddLog(LogEvent.Message("Message persistence failed!"));
            context.Span.ErrorOccurred(eventData.Exception);

            _tracingContext.Release(context);
        }
예제 #2
0
        public void CapAfterConsume([Object] CapEventDataSubStore eventData)
        {
            var context = _entrySegmentContextAccessor.Context;

            if (context == null)
            {
                return;
            }

            context.Span.AddLog(LogEvent.Event("Event Persistence"));
            context.Span.AddLog(LogEvent.Message("CAP message persistence succeeded!"));
            context.Span.AddLog(LogEvent.Message("Persistence spend time: " + eventData.ElapsedTimeMs + "ms"));

            _tracingContext.Release(context);
        }
예제 #3
0
        public void CapBeforeConsume([Object] CapEventDataSubStore eventData)
        {
            var carrierHeader = new CapCarrierHeaderCollection(eventData.TransportMessage);
            var context       = _tracingContext.CreateEntrySegmentContext(OperateNamePrefix + eventData.Operation + ConsumerOperateNameSuffix, carrierHeader);

            context.Span.SpanLayer = SpanLayer.MQ;
            context.Span.Component = GetComponent(eventData.BrokerAddress, false);
            context.Span.Peer      = eventData.BrokerAddress.Endpoint;
            context.Span.AddTag(Tags.MQ_TOPIC, eventData.Operation);
            context.Span.AddTag(Tags.MQ_BROKER, eventData.BrokerAddress.Endpoint);
            context.Span.AddLog(LogEvent.Event("Event Persistence"));
            context.Span.AddLog(LogEvent.Message("CAP message persistence start..."));

            _contexts[eventData.TransportMessage.GetId()] = _entrySegmentContextAccessor.Context;
        }
예제 #4
0
 private void TracingAfter(long?tracingTimestamp, TransportMessage message, BrokerAddress broker)
 {
     if (tracingTimestamp.HasValue && s_diagnosticListener.IsEnabled("DotNetCore.CAP.WriteConsumeAfter"))
     {
         long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
         CapEventDataSubStore eventData = new CapEventDataSubStore
         {
             OperationTimestamp = now,
             Operation          = message.GetName(),
             BrokerAddress      = broker,
             TransportMessage   = message,
             ElapsedTimeMs      = now - tracingTimestamp.Value
         };
         s_diagnosticListener.Write("DotNetCore.CAP.WriteConsumeAfter", eventData);
     }
 }
예제 #5
0
 private long?TracingBefore(TransportMessage message, BrokerAddress broker)
 {
     if (s_diagnosticListener.IsEnabled("DotNetCore.CAP.WriteConsumeBefore"))
     {
         CapEventDataSubStore eventData = new CapEventDataSubStore
         {
             OperationTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
             Operation          = message.GetName(),
             BrokerAddress      = broker,
             TransportMessage   = message
         };
         s_diagnosticListener.Write("DotNetCore.CAP.WriteConsumeBefore", eventData);
         return(eventData.OperationTimestamp);
     }
     return(null);
 }
        public void CapAfterConsume([Object] CapEventDataSubStore eventData)
        {
            var context = _contexts[eventData.TransportMessage.GetId() + eventData.TransportMessage.GetGroup()];

            if (context == null)
            {
                return;
            }

            context.Span.AddLog(LogEvent.Event("Event Persistence End"));
            context.Span.AddLog(LogEvent.Message($"CAP message persistence succeeded!{Environment.NewLine}" +
                                                 $"--> Spend Time: { eventData.ElapsedTimeMs }ms. {Environment.NewLine}" +
                                                 $"--> Message Id: { eventData.TransportMessage.GetId() }, Group: {eventData.TransportMessage.GetGroup()}, Name: {eventData.Operation}"));

            _tracingContext.Release(context);
        }
예제 #7
0
        private void TracingAfter(long?tracingTimestamp, TransportMessage message, BrokerAddress broker)
        {
            if (tracingTimestamp != null && s_diagnosticListener.IsEnabled(CapDiagnosticListenerNames.AfterConsume))
            {
                var now       = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                var eventData = new CapEventDataSubStore()
                {
                    OperationTimestamp = now,
                    Operation          = message.GetName(),
                    BrokerAddress      = broker,
                    TransportMessage   = message,
                    ElapsedTimeMs      = now - tracingTimestamp.Value
                };

                s_diagnosticListener.Write(CapDiagnosticListenerNames.AfterConsume, eventData);
            }
        }
        public void CapBeforeConsume([Object] CapEventDataSubStore eventData)
        {
            var carrierHeader = new CapCarrierHeaderCollection(eventData.TransportMessage);
            var eventName     = eventData.TransportMessage.GetGroup() + "/" + eventData.Operation;
            var operationName = OperateNamePrefix + eventName + ConsumerOperateNameSuffix;
            var context       = _tracingContext.CreateEntrySegmentContext(operationName, carrierHeader);

            context.Span.SpanLayer = SpanLayer.DB;
            context.Span.Component = GetComponent(eventData.BrokerAddress, false);
            context.Span.Peer      = eventData.BrokerAddress.Endpoint.Replace("-1", "5672");
            context.Span.AddTag(Tags.MQ_TOPIC, eventData.Operation);
            context.Span.AddTag(Tags.MQ_BROKER, eventData.BrokerAddress.Endpoint);
            context.Span.AddLog(LogEvent.Event("Event Persistence Start"));
            context.Span.AddLog(LogEvent.Message("CAP message persistence start..."));

            _contexts[eventData.TransportMessage.GetId() + eventData.TransportMessage.GetGroup()] = context;
        }
예제 #9
0
        private long? TracingBefore(TransportMessage message, BrokerAddress broker)
        {
            if (s_diagnosticListener.IsEnabled(CapDiagnosticListenerNames.BeforeConsume))
            {
                var eventData = new CapEventDataSubStore()
                {
                    OperationTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
                    Operation = message.GetName(),
                    BrokerAddress = broker,
                    TransportMessage = message
                };

                s_diagnosticListener.Write(CapDiagnosticListenerNames.BeforeConsume, eventData);

                return eventData.OperationTimestamp;
            }

            return null;
        }