Skip to content

Commit

Permalink
Update log lever for retry (#94)
Browse files Browse the repository at this point in the history
* Update log lever for retry

* Pass the retry error to user side
  • Loading branch information
ruhan1 authored Oct 12, 2024
1 parent a1b19de commit 09d6ebb
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ public Response intercept( @NotNull Chain chain ) throws IOException
{
Request req = chain.request();
Response resp = null;
IOException latestException = null;
int tryCounter = 0;
do {
if ( resp != null )
Expand All @@ -410,23 +411,20 @@ public Response intercept( @NotNull Chain chain ) throws IOException
Span.current()
.setAttribute( "target.try." + tryCounter + ".status_code", resp.code() );

logger.debug( "TRY({}/{}): Response missing or indicates server error: {}. Retrying",
logger.warn( "TRY({}/{}): Response missing or indicates server error: {}. Retrying",
tryCounter, count, resp );
}
}
}
catch( IOException e )
{
if ( tryCounter >= count )
{
throw e;
}
latestException = e;

Span.current().setAttribute( "target.try." + tryCounter + ".error_message", e.getMessage() );
Span.current()
.setAttribute( "target.try." + tryCounter + ".error_class", e.getClass().getSimpleName() );

logger.debug( "TRY(" + tryCounter + "/" + count + "): Failed upstream request: " + req.url(), e );
logger.warn( "TRY(" + tryCounter + "/" + count + "): Failed upstream request: " + req.url(), e );
}

try
Expand All @@ -447,7 +445,9 @@ public Response intercept( @NotNull Chain chain ) throws IOException

Span.current().setAttribute( "target.retries", tryCounter );

throw new IOException( "Proxy retry interceptor reached an unexpected fall-through condition!" );
throw new IOException( String.format(
"Proxy retry interceptor reached an unexpected fall-through condition! %s, Failed upstream request: %s",
latestException, req.url() ) );
}
}

Expand Down

0 comments on commit 09d6ebb

Please sign in to comment.