Skip to content

Commit

Permalink
fix(metrics): fix caching agent drift gauge usage (#3747)
Browse files Browse the repository at this point in the history
Registry.gauge(Id, Number) is deprecated and is for continuously polled
metrics, when what we want is an active gauge that is only published
when available.
  • Loading branch information
dreynaud committed Jun 4, 2019
1 parent 926de75 commit 10f5a6f
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.netflix.spinnaker.clouddriver.aws.provider.agent;

import com.netflix.spectator.api.Id;
import com.netflix.spectator.api.Gauge;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.clouddriver.aws.security.NetflixAmazonCredentials;
import org.slf4j.Logger;
Expand All @@ -32,9 +32,9 @@ public interface DriftMetric {

String getAgentType();

default Id getDriftMetricId() {
default Gauge getDriftMetricGauge() {
return getRegistry()
.createId(
.gauge(
"cache.drift",
"agent",
getClass().getSimpleName(),
Expand All @@ -48,7 +48,7 @@ default void recordDrift(Long start) {
if (start != null && start != 0L) {
Long drift = getRegistry().clock().wallTime() - start;
getLog().info("{}/drift - {} milliseconds", getAgentType(), drift);
getRegistry().gauge(getDriftMetricId(), drift);
getDriftMetricGauge().set(drift);
}
}
}

0 comments on commit 10f5a6f

Please sign in to comment.