public void HttpRequestSucceeded(
     VssTraceActivity activity,
     HttpResponseMessage response)
 {
     if (IsEnabled())
     {
         SetActivityId(activity);
         HttpRequestSucceeded(response.RequestMessage.GetHttpMethod(), response.RequestMessage.RequestUri.AbsoluteUri, (Int32)response.StatusCode);
     }
 }
 public void HttpRequestStart(
     VssTraceActivity activity,
     HttpRequestMessage request)
 {
     if (IsEnabled())
     {
         SetActivityId(activity);
         HttpRequestStart(request.GetHttpMethod(), request.RequestUri.AbsoluteUri);
     }
 }
 public void HttpRequestFailed(
     VssTraceActivity activity,
     HttpRequestMessage request,
     String message)
 {
     if (IsEnabled())
     {
         SetActivityId(activity);
         WriteMessageEvent(request.GetHttpMethod(), request.RequestUri.AbsoluteUri, message, this.HttpRequestFailed);
     }
 }
 public void HttpRequestUnauthorized(
     VssTraceActivity activity,
     HttpRequestMessage request,
     String message)
 {
     if (IsEnabled())
     {
         SetActivityId(activity);
         HttpRequestUnauthorized(request.GetHttpMethod(), request.RequestUri.AbsoluteUri, message);
     }
 }
 public void HttpOperationStart(
     VssTraceActivity activity,
     String area,
     String operation)
 {
     if (IsEnabled())
     {
         SetActivityId(activity);
         HttpOperationStart(area, operation);
     }
 }
 public void HttpRequestTimedOut(
     VssTraceActivity activity,
     HttpRequestMessage request,
     TimeSpan timeout)
 {
     if (IsEnabled())
     {
         SetActivityId(activity);
         HttpRequestTimedOut(request.GetHttpMethod(), request.RequestUri.AbsoluteUri, (Int32)timeout.TotalSeconds);
     }
 }
 public void IssuedTokenRetrievedFromCache(
     VssTraceActivity activity,
     IssuedTokenProvider provider,
     IssuedToken token)
 {
     if (IsEnabled())
     {
         SetActivityId(activity);
         IssuedTokenRetrievedFromCache(provider.CredentialType, provider.GetHashCode(), token.GetHashCode());
     }
 }
 public void AuthenticationError(
     VssTraceActivity activity,
     IssuedTokenProvider provider,
     String message)
 {
     if (IsEnabled(EventLevel.Error, Keywords.Authentication))
     {
         SetActivityId(activity);
         WriteMessageEvent(provider.CredentialType, provider.GetHashCode(), message, this.AuthenticationError);
     }
 }
 public void IssuedTokenWaitStop(
     VssTraceActivity activity,
     IssuedTokenProvider provider,
     IssuedToken token)
 {
     if (IsEnabled(EventLevel.Verbose, Keywords.Authentication))
     {
         SetActivityId(activity);
         IssuedTokenWaitStop(provider.CredentialType, provider.GetHashCode(), token != null ? token.GetHashCode() : 0);
     }
 }
 public void IssuedTokenValidated(
     VssTraceActivity activity,
     IssuedTokenProvider provider,
     IssuedToken token)
 {
     if (IsEnabled())
     {
         SetActivityId(activity);
         IssuedTokenValidated(provider.CredentialType, provider.GetHashCode(), token.GetHashCode());
     }
 }
 public void IssuedTokenWaitStart(
     VssTraceActivity activity,
     IssuedTokenProvider provider,
     Guid waitForActivityId)
 {
     if (IsEnabled(EventLevel.Verbose, Keywords.Authentication))
     {
         SetActivityId(activity);
         IssuedTokenWaitStart(provider.CredentialType, provider.GetHashCode(), waitForActivityId);
     }
 }
 public Exception HttpRequestFailed(
     VssTraceActivity activity,
     HttpRequestMessage request,
     Exception exception)
 {
     if (IsEnabled())
     {
         HttpRequestFailed(activity, request, exception.ToString());
     }
     return(exception);
 }
 public void HttpRequestSucceededWithRetry(
     VssTraceActivity activity,
     HttpResponseMessage response,
     Int32 attempt)
 {
     if (IsEnabled())
     {
         SetActivityId(activity);
         HttpRequestSucceededWithRetry(response.RequestMessage.GetHttpMethod(), response.RequestMessage.RequestUri.AbsoluteUri, attempt);
     }
 }
        public void AuthenticationError(
            VssTraceActivity activity,
            IssuedTokenProvider provider,
            Exception exception)
        {
            if (IsEnabled(EventLevel.Error, Keywords.Authentication))
            {
                if (exception is AggregateException)
                {
                    exception = ((AggregateException)exception).Flatten().InnerException;
                }

                AuthenticationError(activity, provider, exception.ToString());
            }
        }
        public void HttpRequestRetrying(
            VssTraceActivity activity,
            HttpRequestMessage request,
            Int32 attempt,
            TimeSpan backoffDuration,
            HttpStatusCode?httpStatusCode,
            WebExceptionStatus?webExceptionStatus,
            SocketError?socketErrorCode,
            WinHttpErrorCode?winHttpErrorCode,
            CurlErrorCode?curlErrorCode,
            string afdRefInfo)
        {
            if (IsEnabled())
            {
                String reason = "<unknown>";
                if (httpStatusCode != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "HTTP Status: {0}", httpStatusCode.Value);
                }
                else if (webExceptionStatus != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "Web Exception Status: {0}", webExceptionStatus.Value);
                }
                else if (socketErrorCode != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "Socket Error: {0}", socketErrorCode.Value);
                }
                else if (winHttpErrorCode != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "WinHttp Error: {0}", winHttpErrorCode);
                }
                else if (curlErrorCode != null)
                {
                    reason = String.Format(CultureInfo.InvariantCulture, "Curl Error: {0}", curlErrorCode);
                }

                if (!string.IsNullOrEmpty(afdRefInfo))
                {
                    reason += $", AFD Ref: {afdRefInfo}";
                }

                SetActivityId(activity);
                HttpRequestRetrying(request.GetHttpMethod(), request.RequestUri.AbsoluteUri, attempt, reason, backoffDuration.TotalSeconds);
            }
        }
        public void HttpRequestFailed(
            VssTraceActivity activity,
            HttpRequestMessage request,
            HttpStatusCode statusCode,
            string afdRefInfo)
        {
            if (IsEnabled())
            {
                SetActivityId(activity);
                CultureInfo cultureInfo = CultureInfo.InstalledUICulture;
                String      message     = String.Format(cultureInfo, "HTTP Status: {0}", statusCode);

                if (!string.IsNullOrEmpty(afdRefInfo))
                {
                    message += $", AFD Ref: {afdRefInfo}";
                }

                WriteMessageEvent(request.GetHttpMethod(), request.RequestUri.AbsoluteUri, message, this.HttpRequestFailed);
            }
        }
 private void SetActivityId(VssTraceActivity activity)
 {
 }