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());
        }
 internal void FireResponseReceived(RequestEventArgs args)
 {
     if (this.ResponseReceived != null)
     {
         this.ResponseReceived(this, args);
     }
 }
 internal void FireSendingRequest(RequestEventArgs args)
 {
     if (this.SendingRequest != null)
     {
         this.SendingRequest(this, args);
     }
 }
 internal void FireSendingRequest(RequestEventArgs args)
 {
     EventHandler<RequestEventArgs> handler = this.SendingRequest;
     if (handler != null)
     {
         handler(this, args);
     }
 }
        internal void FireResponseReceived(RequestEventArgs args)
        {
            EventHandler <RequestEventArgs> handler = this.ResponseReceived;

            if (handler != null)
            {
                handler(this, args);
            }
        }
        internal void FireSendingRequest(RequestEventArgs args)
        {
            EventHandler <RequestEventArgs> handler = this.SendingRequest;

            if (handler != null)
            {
                handler(this, args);
            }
        }
        private void OperationContextResponseReceived(object sender, RequestEventArgs e)
        {
            if (!TracingAdapter.IsEnabled)
            {
                return;
            }
        
            DateTime currentTime = DateTime.Now;

            double duration = 0;
            string httpStatusCode = null;
            string serviceRequestId = null;
            string exceptionString = null;
            string extendedInfoErrorCode = null;
            string extendedInfoErrorMessage = null;
            long contentLength = e.Response != null ? e.Response.ContentLength : 0;
            this.Response = e.Response;

            if (this.OperationContext.LastResult != null)
            {
                httpStatusCode = this.OperationContext.LastResult.HttpStatusCode.ToString(CultureInfo.InvariantCulture);
                serviceRequestId = this.OperationContext.LastResult.ServiceRequestID;

                // It should have been this.operationContext.LastResult.EndTime - this.operationContext.LastResult.StartTime
                // However, in the flow of control, the EndTime is not yet set in the operation context.
                duration = (currentTime - this.operationContext.LastResult.StartTime).TotalMilliseconds;

                if (this.operationContext.LastResult.Exception != null)
                {
                    exceptionString = this.operationContext.LastResult.Exception.ToString();

                    if (this.OperationContext.LastResult.ExtendedErrorInformation != null)
                    {
                        extendedInfoErrorCode = this.OperationContext.LastResult.ExtendedErrorInformation.ErrorCode;
                        extendedInfoErrorMessage = this.operationContext.LastResult.ExtendedErrorInformation.ErrorMessage;
                    }
                }
            }

            if (this.operationContext.LastResult != null && this.operationContext.LastResult.Exception != null)
            {
                this.LogTableStorageOperationError(
                    this.resourceUri, exceptionString, httpStatusCode, serviceRequestId, extendedInfoErrorCode, extendedInfoErrorMessage, contentLength, this.accountName);
            }
            else
            {
                this.LogTableStorageOperationCompletedInvoking(
                    this.resourceUri, string.Empty, (long)duration, httpStatusCode, serviceRequestId, contentLength, this.accountName);
            }
        }
Example #8
0
        internal void FireRetrying(RequestEventArgs args)
        {
            EventHandler <RequestEventArgs> handler = this.Retrying;

            if (handler != null)
            {
                handler(this, args);
            }

            EventHandler <RequestEventArgs> handlerStatic = OperationContext.GlobalRetrying;

            if (handlerStatic != null)
            {
                handlerStatic(this, args);
            }
        }
Example #9
0
        internal void FireSendingRequest(RequestEventArgs args)
        {
            EventHandler <RequestEventArgs> handler = this.SendingRequest;

            if (handler != null)
            {
                handler(this, args);
            }

            EventHandler <RequestEventArgs> handlerStatic = OperationContext.GlobalSendingRequest;

            if (handlerStatic != null)
            {
                handlerStatic(this, args);
            }
        }
        internal void FireRequestCompleted(RequestEventArgs args)
        {
            this.RequestCompleted?.Invoke(this, args);

            OperationContext.GlobalRequestCompleted?.Invoke(this, args);
        }
        private void OperationContextSendingRequest(object sender, RequestEventArgs e)
        {
            if (!TracingAdapter.IsEnabled)
            {
                return;
            }

            long contentLength = e.Request != null ? e.Request.ContentLength : 0;
            this.LogTableStorageOperationInvoking(this.resourceUri, contentLength, this.accountName);
        }
Example #12
0
        static void StorageRequest_Retrying(object sender, RequestEventArgs e)
        {
            string errMessage = e.RequestInformation.Exception.Message;
            string path = e.Request.Address.AbsoluteUri;

            OperationContext oc = (OperationContext)sender;
            int retryCount = oc.RequestResults.Count;

            string message = string.Format(CultureInfo.InvariantCulture, "Retry Count = {0}, Error = {1}, URI = {2}", retryCount, errMessage, path);

            Logger.JobInfo("Azure Storage Request Retry: " + message);
        }
Example #13
0
 internal void FireResponseReceived(RequestEventArgs args)
 {
     throw new System.NotImplementedException();
 }
Example #14
0
 internal void FireRetrying(RequestEventArgs args)
 {
     throw new System.NotImplementedException();
 }
        internal void FireRetrying(RequestEventArgs args)
        {
            EventHandler<RequestEventArgs> handler = this.Retrying;
            if (handler != null)
            {
                handler(this, args);
            }

            EventHandler<RequestEventArgs> handlerStatic = OperationContext.GlobalRetrying;
            if (handlerStatic != null)
            {
                handlerStatic(this, args);
            }
        }
Example #16
0
 internal void FireSendingRequest(RequestEventArgs args)
 {
     throw new System.NotImplementedException();
 }
        internal void FireSendingRequest(RequestEventArgs args)
        {
            EventHandler<RequestEventArgs> handler = this.SendingRequest;
            if (handler != null)
            {
                handler(this, args);
            }

            EventHandler<RequestEventArgs> handlerStatic = OperationContext.GlobalSendingRequest;
            if (handlerStatic != null)
            {
                handlerStatic(this, args);
            }
        }
        internal void FireRetrying(RequestEventArgs args)
        {
            this.Retrying?.Invoke(this, args);

            OperationContext.GlobalRetrying?.Invoke(this, args);
        }
 internal void FireResponseReceived(RequestEventArgs args)
 {
     EventHandler<RequestEventArgs> handler = this.ResponseReceived;
     if (handler != null)
     {
         handler(this, args);
     }
 }
        internal void FireResponseReceived(RequestEventArgs args)
        {
            this.ResponseReceived?.Invoke(this, args);

            OperationContext.GlobalResponseReceived?.Invoke(this, args);
        }
        internal void FireSendingRequest(RequestEventArgs args)
        {
            this.SendingRequest?.Invoke(this, args);

            OperationContext.GlobalSendingRequest?.Invoke(this, args);
        }