Skip to content

Commit

Permalink
Merge pull request #437 from dmuino/count-timeouts
Browse files Browse the repository at this point in the history
Add timeout exception counter to the registry
  • Loading branch information
dmuino authored Jan 17, 2018
2 parents b680c9d + a57bee5 commit c7e22c5
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
import com.netflix.servo.DefaultMonitorRegistry;
import com.netflix.servo.Metric;
import com.netflix.servo.MonitorRegistry;
import com.netflix.servo.monitor.BasicCounter;
import com.netflix.servo.monitor.CompositeMonitor;
import com.netflix.servo.monitor.Counter;
import com.netflix.servo.monitor.DynamicCounter;
import com.netflix.servo.monitor.Monitor;
import com.netflix.servo.monitor.MonitorConfig;
import com.netflix.servo.util.Clock;
import com.netflix.servo.util.ClockWithOffset;
import com.netflix.servo.util.ThreadFactories;
Expand All @@ -44,6 +48,12 @@
public final class MonitorRegistryMetricPoller implements MetricPoller {

private static final Logger LOGGER = LoggerFactory.getLogger(MonitorRegistryMetricPoller.class);
private static final String GET_VALUE_ERROR = "servo.getValueError";
private static final Counter TIMEOUT_ERROR = new BasicCounter(MonitorConfig.builder(GET_VALUE_ERROR)
.withTag("id", "timeout").build());
static {
DefaultMonitorRegistry.getInstance().register(TIMEOUT_ERROR);
}

private final MonitorRegistry registry;

Expand Down Expand Up @@ -138,8 +148,10 @@ private Object getValue(Monitor<?> monitor) {
}
} catch (TimeLimiter.UncheckedTimeoutException e) {
LOGGER.warn("timeout trying to get value for {}", monitor.getConfig());
TIMEOUT_ERROR.increment();
} catch (Exception e) {
LOGGER.warn("failed to get value for " + monitor.getConfig(), e);
DynamicCounter.increment(GET_VALUE_ERROR, "id", e.getClass().getSimpleName());
}
return null;
}
Expand Down

0 comments on commit c7e22c5

Please sign in to comment.