Skip to content

Commit

Permalink
reduce warning volume for sidecar registry (Netflix#1020)
Browse files Browse the repository at this point in the history
Some writers such as the UDP writer can be quite noisy if
the sidecar is not present. To avoid spamming the user with
warnings, they will be suppressed after a warning is logged.
Warnings will be re-enabled if there is a successful write
so that if there are problems with the sidecar being
intermittently accessible it will still get detected.
  • Loading branch information
brharrington committed Apr 6, 2023
1 parent e778066 commit 3ba0b84
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ static SidecarWriter create(String location) {

private final String location;

private volatile boolean suppressWarnings;

SidecarWriter(String location) {
this.location = location;
this.suppressWarnings = false;
}

abstract void writeImpl(String line) throws IOException;
Expand All @@ -75,8 +78,16 @@ void write(String line) {
try {
LOGGER.trace("writing to {}: {}", location, line);
writeImpl(line);
suppressWarnings = false;
} catch (IOException e) {
LOGGER.warn("write to {} failed: {}", location, line, e);
// Some writers such as the UDP writer can be quite noisy if the sidecar is not present.
// To avoid spamming the user with warnings, they will be suppressed after a warning is
// logged. Warnings will be re-enabled if there is a successful write so that if there
// are problems with a sidecar being intermittently accessible it will still get detected.
if (!suppressWarnings) {
LOGGER.warn("write to {} failed: {}", location, line, e);
suppressWarnings = true;
}
}
}

Expand Down

0 comments on commit 3ba0b84

Please sign in to comment.