-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change metrics with micrometer in mantis-control-plane #515
base: master
Are you sure you want to change the base?
Conversation
@@ -70,7 +70,7 @@ public static HighAvailabilityServices createHAServices(CoreConfiguration config | |||
} | |||
else { | |||
if (HAServiceInstanceRef.get() == null) { | |||
HAServiceInstanceRef.compareAndSet(null, new ZkHighAvailabilityServices(configuration)); | |||
HAServiceInstanceRef.compareAndSet(null, new ZkHighAvailabilityServices(configuration, new SimpleMeterRegistry())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you instead pass MeterRegistry
as an arg?
masterConnectRetryCounter = m.getCounter("MasterConnectRetryCount"); | ||
this.meterRegistry = meterRegistry; | ||
String groupName = MasterClientWrapper.class.getCanonicalName(); | ||
masterConnectRetryCounter = meterRegistry.counter(groupName + ".MasterConnectRetryCount"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comment that .
should be _
masterConnectRetryCounter = m.getCounter("MasterConnectRetryCount"); | ||
this.meterRegistry = meterRegistry; | ||
String groupName = MasterClientWrapper.class.getCanonicalName(); | ||
masterConnectRetryCounter = meterRegistry.counter(groupName + ".MasterConnectRetryCount"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
masterConnectRetryCounter = meterRegistry.counter(groupName + ".MasterConnectRetryCount"); | |
masterConnectRetryCounter = meterRegistry.counter(groupName + "_MasterConnectRetryCount"); |
this.failureCounter = metrics.getCounter("failureCounter"); | ||
this.workerSentHeartbeats = metrics.getCounter("workerSentHeartbeats"); | ||
String groupName = "ReportStatusServiceHttpImpl"; | ||
this.failureCounter = Counter.builder(groupName + ".failureCounter").register(meterRegistry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.failureCounter = Counter.builder(groupName + ".failureCounter").register(meterRegistry); | |
this.failureCounter = meterRegistry.counter(groupName + "_failureCounter"); |
btw, is there a difference between doing
meterRegistry.counter(...)
vs
Counter.builder(...).register(meterRegistry)
If not, I prefer we follow the first approach as much as possible.
this.workerSentHeartbeats = metrics.getCounter("workerSentHeartbeats"); | ||
String groupName = "ReportStatusServiceHttpImpl"; | ||
this.failureCounter = Counter.builder(groupName + ".failureCounter").register(meterRegistry); | ||
this.workerSentHeartbeats = Counter.builder(groupName + ".workerSentHeartbeats").register(meterRegistry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.workerSentHeartbeats = Counter.builder(groupName + ".workerSentHeartbeats").register(meterRegistry); | |
this.workerSentHeartbeats = Counter.builder(groupName + "_workerSentHeartbeats").register(meterRegistry); |
this.jobRouteHandler = jobRouteHandler; | ||
MasterConfiguration config = ConfigurationProvider.getConfig(); | ||
this.cache = createCache(actorSystem, config.getApiCacheMinSize(), config.getApiCacheMaxSize(), | ||
config.getApiCacheTtlMilliseconds()); | ||
this.jobListGET = meterRegistry.counter("V0JobRoute" + "_" +"jobListGET"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.jobListGET = meterRegistry.counter("V0JobRoute" + "_" +"jobListGET"); | |
this.jobListGET = meterRegistry.counter("V0JobRoute_jobListGET"); |
can you apply similar change to following lines as well? thx!
} | ||
|
||
private Gauge addGauge(String meterName,int value) { | ||
Gauge gauge = Gauge.builder("JobClusterActor_legacyGaugeCallbackMetricGroup_"+meterName, () -> 1.0 * value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need legacyGaugeCallbackMetricGroup_
infix here because the GaugeCallback
used here is io.mantisrx.common.metrics.spectator.GaugeCallback
which doesn't use this string.
Also, the value being passed in is incorrect. I believe you want to call addGauge
with the lambda and pass it as-is to Gauge.builder
.
For eg:
this.acceptedJobsGauge = addGauge("acceptedJobsGauge", () -> 1.0 * this.jobManager.acceptedJobsCount());
and define addGauge as follows:
private Gauge addGauge(String meterName, Supplier<Number> gaugeFun) {
return Gauge.builder("JobClusterActor_" + meterName, gaugeFunc).tags("jobCluster", name).register(meterRegistry);
}
public void incrementCounter(final String metric, final Iterable<Tag> tags) { | ||
registry.counter(new MetricId(METRIC_GROUP_ID, metric, tags).getSpectatorId(registry)).increment(); | ||
public void incrementCounter(final String metric, final Tags tags) { | ||
meterRegistry.counter(METRIC_GROUP_ID + "_" + metric, tags).increment(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is smart I like it.
@@ -75,13 +72,13 @@ public void recordMisses(int count) { | |||
@Override | |||
public void recordLoadSuccess(long loadTime) { | |||
loadSuccessCount.increment(); | |||
totalLoadTime.set(TimeUnit.MILLISECONDS.convert(loadTime, TimeUnit.NANOSECONDS)); | |||
totalLoadTime.record(Duration.ofDays(TimeUnit.MILLISECONDS.convert(loadTime, TimeUnit.NANOSECONDS))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why use Duration.ofDays
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Actually, I was supposed to use Duration.ofNanos here.
this.noWorkersFoundCounter = m.getCounter("noWorkersFound"); | ||
this.workersFoundCounter = m.getCounter("workersFound"); | ||
this.meterRegistry = meterRegistry; | ||
this.noWorkersFoundCounter = meterRegistry.counter("Storage_noWorkersFound"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comment: pl keep storage
in lower-case to be consistent with original metrics.
It'd be storage
instead of Storage
Context
Explain context and other details for this pull request.
Checklist
./gradlew build
compiles code correctly./gradlew test
passes all tests