コード例 #1
0
    public void OnForwarderFailed(DateTime timestamp, ForwarderError error)
    {
        var metrics = PerRequestMetrics.Current;

        metrics.ProxyStopOffset = metrics.CalcOffset(timestamp);
        metrics.Error           = error;
    }
コード例 #2
0
        private HttpContext GetFailedRequestContext(ForwarderError error)
        {
            var errorFeature = new ForwarderErrorFeature(error, null);
            var context      = new DefaultHttpContext();

            context.Features.Set <IForwarderErrorFeature>(errorFeature);
            return(context);
        }
コード例 #3
0
 private static string GetMessage(ForwarderError error)
 {
     return(error switch
     {
         ForwarderError.None => throw new NotSupportedException("A more specific error must be used"),
         ForwarderError.Request => "An error was encountered before receiving a response.",
         ForwarderError.RequestTimedOut => "The request timed out before receiving a response.",
         ForwarderError.RequestCanceled => "The request was canceled before receiving a response.",
         ForwarderError.RequestBodyCanceled => "Copying the request body was canceled.",
         ForwarderError.RequestBodyClient => "The client reported an error when copying the request body.",
         ForwarderError.RequestBodyDestination => "The destination reported an error when copying the request body.",
         ForwarderError.ResponseBodyCanceled => "Copying the response body was canceled.",
         ForwarderError.ResponseBodyClient => "The client reported an error when copying the response body.",
         ForwarderError.ResponseBodyDestination => "The destination reported an error when copying the response body.",
         ForwarderError.ResponseHeaders => "The destination returned a response that cannot be proxied back to the client.",
         ForwarderError.UpgradeRequestCanceled => "Copying the upgraded request body was canceled.",
         ForwarderError.UpgradeRequestClient => "The client reported an error when copying the upgraded request body.",
         ForwarderError.UpgradeRequestDestination => "The destination reported an error when copying the upgraded request body.",
         ForwarderError.UpgradeResponseCanceled => "Copying the upgraded response body was canceled.",
         ForwarderError.UpgradeResponseClient => "The client reported an error when copying the upgraded response body.",
         ForwarderError.UpgradeResponseDestination => "The destination reported an error when copying the upgraded response body.",
         ForwarderError.NoAvailableDestinations => throw new NotImplementedException(), // Not used in this class
         _ => throw new NotImplementedException(error.ToString()),
     });
コード例 #4
0
        public void OnForwarderFailed(DateTime timestamp, ForwarderError error)
        {
            var metrics = PerRequestMetrics.Current;

            metrics.Error = error;
        }
コード例 #5
0
 public static void ErrorProxying(ILogger logger, ForwarderError error, Exception ex)
 {
     _proxyError(logger, error, GetMessage(error), ex);
 }
コード例 #6
0
 private void ReportProxyError(HttpContext context, ForwarderError error, Exception ex)
 {
     context.Features.Set <IForwarderErrorFeature>(new ForwarderErrorFeature(error, ex));
     Log.ErrorProxying(_logger, error, ex);
     ForwarderTelemetry.Log.ForwarderFailed(error);
 }
コード例 #7
0
 internal ForwarderErrorFeature(ForwarderError error, Exception?ex)
 {
     Error     = error;
     Exception = ex;
 }