コード例 #1
0
        public static T AsTimelineMessage <T>(this T message, TimelineCategoryItem eventCategory, string eventSubText = null)
            where T : ITimelineMessage
        {
            message.AsTimelineMessage(string.Empty, eventCategory, eventSubText);

            return(message);
        }
コード例 #2
0
        public WindowsAzureStorageTimelineMessage(string serviceName, string serviceOperation, string resourceUri, int responseCode, DateTime startTime, DateTime endTime, TimeSpan offset, RequestEventArgs requestEventArgs)
        {
            Id = Guid.NewGuid();

            EventName = string.Format("WAZStorage:{0} - {1} {2} {3}", serviceName, serviceOperation, resourceUri, responseCode);
            EventCategory = new TimelineCategoryItem("Windows Azure Storage", "#0094FF", "#0094FF");

            ServiceName = serviceName;
            ServiceOperation = serviceOperation;
            Url = resourceUri;
            ResponseCode = responseCode;

            StartTime = startTime;
            Duration = endTime - startTime;
            Offset = offset;

            RequestSize = requestEventArgs.Request.ContentLength;
            foreach (var header in requestEventArgs.Request.Headers.AllKeys)
            {
                RequestSize += header.Length + 2 + string.Join(";", requestEventArgs.Request.Headers.GetValues(header)).Length;
            }
            ResponseSize = requestEventArgs.Response.ContentLength;
            foreach (var header in requestEventArgs.Response.Headers.AllKeys)
            {
                ResponseSize += header.Length + 2 + string.Join(";", requestEventArgs.Response.Headers.GetValues(header)).Length;
            }

            RequestHeaders = requestEventArgs.Request.Headers;
            ResponseHeaders = requestEventArgs.Request.Headers;

            EventSubText = string.Format("out: {0}/in: {1}", RequestSize.ToBytesHuman(), ResponseSize.ToBytesHuman());
        }
コード例 #3
0
        public void ShouldBeAbleToBuildWithFactory(TimerResult timerResult, string eventName, TimelineCategoryItem eventCategory, string eventSubText)
        {
            var testMessage = new TestMessage().AsTimelineMessage(eventName, eventCategory, eventSubText);

            Assert.Equal(eventName, testMessage.EventName);
            Assert.Equal(eventCategory, testMessage.EventCategory);
            Assert.Equal(eventSubText, testMessage.EventSubText);
        }
コード例 #4
0
        public static T AsTimelineMessage <T>(this T message, string eventName, TimelineCategoryItem eventCategory, string eventSubText = null)
            where T : ITimelineMessage
        {
            message.EventName     = eventName;
            message.EventCategory = eventCategory;
            message.EventSubText  = eventSubText;

            return(message);
        }
コード例 #5
0
        internal static OngoingCapture Capture(string eventName, string eventSubText, TimelineCategoryItem category, ITimelineMessage message)
        {
            if (string.IsNullOrEmpty(eventName))
            {
                throw new ArgumentNullException("eventName");
            }

            #pragma warning disable 618
            var executionTimer = GlimpseConfiguration.GetConfiguredTimerStrategy()();
            var messageBroker = GlimpseConfiguration.GetConfiguredMessageBroker();
            #pragma warning restore 618

            if (executionTimer == null || messageBroker == null)
            {
                return OngoingCapture.Empty();
            }

            return new OngoingCapture(executionTimer, messageBroker, eventName, eventSubText, category, message);
        }
コード例 #6
0
            public Message(string cacheName, string operationType) // , DateTime startTime, DateTime endTime, TimeSpan offset)
            {
                Id = Guid.NewGuid();

                EventName = string.Format("WAZCache:{0}:{1}", cacheName, operationType);
                EventCategory = new TimelineCategoryItem("Windows Azure Caching", "#0094FF", "#0094FF");

                // StartTime = startTime;
                // Duration = endTime - startTime;
                // Offset = offset;

                // RequestSize = requestEventArgs.Request.ContentLength;
                // foreach (var header in requestEventArgs.Request.Headers.AllKeys)
                // {
                //     RequestSize += header.Length + 2 + string.Join(";", requestEventArgs.Request.Headers.GetValues(header)).Length;
                // }
                // ResponseSize = requestEventArgs.Response.ContentLength;
                // foreach (var header in requestEventArgs.Response.Headers.AllKeys)
                // {
                //     ResponseSize += header.Length + 2 + string.Join(";", requestEventArgs.Response.Headers.GetValues(header)).Length;
                // }

                // EventSubText = string.Format("out: {0}/in: {1}", RequestSize.ToBytesHuman(), ResponseSize.ToBytesHuman());
            }
コード例 #7
0
        internal static void CaptureMoment(string eventName, string eventSubText, TimelineCategoryItem category, ITimelineMessage message)
        {
            if (string.IsNullOrEmpty(eventName))
            {
                throw new ArgumentNullException("eventName");
            }

            #pragma warning disable 618
            var executionTimer = GlimpseConfiguration.GetConfiguredTimerStrategy()();
            var messageBroker = GlimpseConfiguration.GetConfiguredMessageBroker();
            #pragma warning restore 618

            if (executionTimer == null || messageBroker == null)
            {
                return;
            }

            message
                .AsTimelineMessage(eventName, category, eventSubText)
                .AsTimedMessage(executionTimer.Point());

            messageBroker.Publish(message);
        }
コード例 #8
0
 internal static void CaptureMoment(string eventName, TimelineCategoryItem category, ITimelineMessage message)
 {
     CaptureMoment(eventName, null, category, message);
 }
コード例 #9
0
 internal static OngoingCapture Capture(string eventName, TimelineCategoryItem category, ITimelineMessage message)
 {
     return Capture(eventName, null, category, message);
 }
コード例 #10
0
 public OngoingCapture(IExecutionTimer executionTimer, IMessageBroker messageBroker, string eventName, string eventSubText, TimelineCategoryItem category, ITimelineMessage message)
 {
     Offset = executionTimer.Start();
     ExecutionTimer = executionTimer;
     Message = message.AsTimelineMessage(eventName, category, eventSubText);
     MessageBroker = messageBroker;
 }