Skip to content

Commit

Permalink
removed unnecessary exception logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelweave committed Jan 17, 2025
1 parent 03a7162 commit 7653e90
Showing 1 changed file with 0 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,6 @@ static bool IsRetryableException(Exception ex) =>
ex is CosmosOperationCanceledException ||
(ex is CosmosException cex && (cex.StatusCode == HttpStatusCode.ServiceUnavailable || cex.StatusCode == (HttpStatusCode)449));

void LogAdditionalRetryableExceptionDetails(Exception exception)
{
if (exception is CosmosException cosmosException && cosmosException.StatusCode == HttpStatusCode.ServiceUnavailable)
{
_logger.LogWarning(
cosmosException,
"Received a ServiceUnavailable response from Cosmos DB. Retrying. Diagnostics: {CosmosDiagnostics}",
cosmosException.Diagnostics?.ToString() ?? "empty");
}
}

do
{
cancellationToken.ThrowIfCancellationRequested();
Expand All @@ -107,7 +96,6 @@ void LogAdditionalRetryableExceptionDetails(Exception exception)
// No reasons to retry as the cancellation was external to the health check.

_logger.LogWarning(ex, "Failed to connect to the data store. External cancellation requested.");
LogAdditionalRetryableExceptionDetails(ex);

return HealthCheckResult.Unhealthy(
description: UnhealthyDescription,
Expand All @@ -126,7 +114,6 @@ void LogAdditionalRetryableExceptionDetails(Exception exception)
"Failed to connect to the data store. There were {NumberOfAttempts} attempts to connect to the data store, but they suffered a '{ExceptionType}'.",
attempt,
ex.GetType().Name);
LogAdditionalRetryableExceptionDetails(ex);

return HealthCheckResult.Unhealthy(
description: UnhealthyDescription,
Expand All @@ -144,7 +131,6 @@ void LogAdditionalRetryableExceptionDetails(Exception exception)
"Failed to connect to the data store. Attempt {NumberOfAttempts}. '{ExceptionType}'.",
attempt,
ex.GetType().Name);
LogAdditionalRetryableExceptionDetails(ex);
}
}
catch (CosmosException ex) when (ex.IsCmkClientError())
Expand Down

0 comments on commit 7653e90

Please sign in to comment.