Async logging should not rethrow error in onFailure callback #645
Labels
api: logging
Issues related to the googleapis/java-logging API.
lang: java
Issues specific to Java.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
For async logging, when there is an error with
WriteLogEntries
, the error provided toApiFutureCallback.onFailure()
is rethrown. See:java-logging/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java
Line 823 in 60e53b7
An
ApiFutureCallback
is not expected to throw errors, so this is then logged as an error byApiFutures
. This then results in another log write. In some cases, such as the example stacktrace below where the quota was exceeded, this leads to a never ending cycle of error logs as the quota is exceeded with each error.I think the suggestion here would be to not rethrow the error in the
ApiFutureCallback.onFailure()
callback. An option to maintain visibility of the error would be to "manually" log the error toSystem.err
instead. This is a common practice for logging libraries when errors are encountered as logging is not available in the library itself.Example stack trace:
The text was updated successfully, but these errors were encountered: