Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private void onError(
+ e.getMessage(),
e);
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, "Failed to export " + type + "s. Details follow: " + e);
Comment thread
jkwatson marked this conversation as resolved.
logger.log(Level.FINEST, "Failed to export " + type + "s. Details follow:", e);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually have inconsistent and probably bad patterns around this in other places:

In these cases we log both the exception message and record the the exception itself:

logger.log(
Level.SEVERE,
"Failed to export "
+ type
+ "s. The request could not be executed. Full error message: "
+ e.getMessage(),
e);

logger.log(
Level.SEVERE,
"Failed to execute "
+ TYPE
+ "s. The request could not be executed. Error message: "
+ e.getMessage(),
e);

In these cases we include the stringified caught exception message and don't record the exception, preventing the user from seeing the stacktrace:

throw new ConfigurationException(
"Invalid duration property " + name + "=" + value + ". " + ex.getMessage());

logger.warning(
"Error closing " + closeable.getClass().getName() + ": " + ex.getMessage());

logger.log(
Level.WARNING,
"Exception caught while extracting span context; returning null. "
+ "Exception: [{0}] Message: [{1}]",
new String[] {e.getClass().getName(), e.getMessage()});

logger.warning(
"Error closing " + closeable.getClass().getName() + ": " + ex.getMessage());

logger.warning("Error setting explicit bucket boundaries advice: " + e.getMessage());
return this;

logger.warning("Error setting explicit bucket boundaries advice: " + e.getMessage());

We should add some guidance to https://github.com/open-telemetry/opentelemetry-java/blob/main/CONTRIBUTING.md#best-practices-that-we-follow to recommend not stringifying the exception and recording the exception using dedicated log overloads.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #8228 to discuss / track separately.

}
result.failExceptionally(FailedExportException.grpcFailedExceptionally(e));
}
Expand Down
Loading