Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
[ISSUE-778]: RemoteReporter should be able to 'ignore' sender exception
Browse files Browse the repository at this point in the history
as in old behaviour.

* Adding a new ignoreSenderErrors to the ReporterConfiguration.
* tracing sender errors in debug if ignoreSenderErrors is set to true in
  RemoteReporter.

Issue: #778
Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
  • Loading branch information
ehsavoie committed Mar 30, 2021
1 parent d1312b0 commit bedd2d6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
19 changes: 19 additions & 0 deletions jaeger-core/src/main/java/io/jaegertracing/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ public class Configuration {
*/
public static final String JAEGER_REPORTER_FLUSH_INTERVAL = JAEGER_PREFIX + "REPORTER_FLUSH_INTERVAL";

/**
* Whether the reporter should ignore sender errors.
*/
public static final String JAEGER_REPORTER_IGNORE_SENDER_ERRORS = JAEGER_PREFIX + "REPORTER_IGNORE_SENDER_ERRORS";


/**
* The sampler type.
*/
Expand Down Expand Up @@ -552,6 +558,7 @@ protected void registerBinaryCodec(JaegerTracer.Builder builder, Format<Binary>

public static class ReporterConfiguration {
private Boolean logSpans;
private Boolean ignoreSenderErrors;
private Integer flushIntervalMs;
private Integer maxQueueSize;
private SenderConfiguration senderConfiguration = new SenderConfiguration();
Expand All @@ -564,6 +571,7 @@ public static ReporterConfiguration fromEnv() {
.withLogSpans(getPropertyAsBool(JAEGER_REPORTER_LOG_SPANS))
.withFlushInterval(getPropertyAsInt(JAEGER_REPORTER_FLUSH_INTERVAL))
.withMaxQueueSize(getPropertyAsInt(JAEGER_REPORTER_MAX_QUEUE_SIZE))
.withIgnoreSenderErrors(getPropertyAsBool(JAEGER_REPORTER_IGNORE_SENDER_ERRORS))
.withSender(SenderConfiguration.fromEnv());
}

Expand All @@ -572,6 +580,11 @@ public ReporterConfiguration withLogSpans(Boolean logSpans) {
return this;
}

public ReporterConfiguration withIgnoreSenderErrors(Boolean ignoreSenderErrors) {
this.ignoreSenderErrors = ignoreSenderErrors;
return this;
}

public ReporterConfiguration withFlushInterval(Integer flushIntervalMs) {
this.flushIntervalMs = flushIntervalMs;
return this;
Expand All @@ -593,6 +606,8 @@ private Reporter getReporter(Metrics metrics) {
.withSender(senderConfiguration.getSender())
.withFlushInterval(numberOrDefault(this.flushIntervalMs, RemoteReporter.DEFAULT_FLUSH_INTERVAL_MS).intValue())
.withMaxQueueSize(numberOrDefault(this.maxQueueSize, RemoteReporter.DEFAULT_MAX_QUEUE_SIZE).intValue())
.withIgnoreSenderErrors(
booleanOrDefault(this.ignoreSenderErrors, RemoteReporter.DEFAULT_IGNORE_SENDER_ERRORS))
.build();

if (Boolean.TRUE.equals(this.logSpans)) {
Expand Down Expand Up @@ -727,6 +742,10 @@ private static Number numberOrDefault(Number value, Number defaultValue) {
return value != null ? value : defaultValue;
}

private static Boolean booleanOrDefault(Boolean value, Boolean defaultValue) {
return value != null ? value : defaultValue;
}

private static String getProperty(String name) {
return System.getProperty(name, System.getenv(name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class RemoteReporter implements Reporter {

public static final int DEFAULT_FLUSH_INTERVAL_MS = 1000;
public static final int DEFAULT_MAX_QUEUE_SIZE = 100;
public static final Boolean DEFAULT_IGNORE_SENDER_ERRORS = Boolean.FALSE;

private final Sender sender;
private final int closeEnqueueTimeout;
Expand All @@ -50,11 +51,13 @@ public class RemoteReporter implements Reporter {
@ToString.Exclude private final Thread queueProcessorThread;
@ToString.Exclude private final QueueProcessor queueProcessor;
@ToString.Exclude private final Metrics metrics;
@ToString.Exclude private final boolean ignoreSenderErrors;

private RemoteReporter(Sender sender, int flushInterval, int maxQueueSize, int closeEnqueueTimeout,
Metrics metrics) {
Metrics metrics, boolean ignoreSenderErrors) {
this.sender = sender;
this.metrics = metrics;
this.ignoreSenderErrors = ignoreSenderErrors;
this.closeEnqueueTimeout = closeEnqueueTimeout;
commandQueue = new ArrayBlockingQueue<Command>(maxQueueSize);

Expand Down Expand Up @@ -187,8 +190,13 @@ public void run() {
} catch (SenderException e) {
metrics.reporterFailure.inc(e.getDroppedSpanCount());
if (!failedBefore) {
log.warn(commandClass.getSimpleName()
+ " execution failed! Repeated errors of this command will not be logged.", e);
if (ignoreSenderErrors) {
log.debug(commandClass.getSimpleName()
+ " execution failed! Repeated errors of this command will not be logged.", e);
} else {
log.warn(commandClass.getSimpleName()
+ " execution failed! Repeated errors of this command will not be logged.", e);
}
commandFailedBefore.add(commandClass);
}
}
Expand All @@ -209,6 +217,7 @@ public static class Builder {
private int flushInterval = DEFAULT_FLUSH_INTERVAL_MS;
private int maxQueueSize = DEFAULT_MAX_QUEUE_SIZE;
private int closeEnqueTimeout = DEFAULT_CLOSE_ENQUEUE_TIMEOUT_MILLIS;
private boolean ignoreSenderErrors = DEFAULT_IGNORE_SENDER_ERRORS;
private Metrics metrics;

public Builder withFlushInterval(int flushInterval) {
Expand Down Expand Up @@ -236,14 +245,20 @@ public Builder withCloseEnqueueTimeout(int closeEnqueueTimeoutMs) {
return this;
}

public Builder withIgnoreSenderErrors(Boolean ignoreSenderErrors) {
this.ignoreSenderErrors = ignoreSenderErrors;
return this;
}

public RemoteReporter build() {
if (sender == null) {
sender = SenderResolver.resolve();
}
if (metrics == null) {
metrics = new Metrics(new InMemoryMetricsFactory());
}
return new RemoteReporter(sender, flushInterval, maxQueueSize, closeEnqueTimeout, metrics);
return new RemoteReporter(sender, flushInterval, maxQueueSize, closeEnqueTimeout, metrics, ignoreSenderErrors);
}

}
}

0 comments on commit bedd2d6

Please sign in to comment.