Skip to content

Commit

Permalink
Allow customizing start log message in PushMeterRegistry implementati…
Browse files Browse the repository at this point in the history
…ons (#4848)

It will be helpful in troubleshooting to be able to log more specific information to the implementation than is available at the level of PushMeterRegistry. Allowing this to be overridden also avoids registry implementations from logging similar messages resulting in multiple logs on start for essentially the same thing.
  • Loading branch information
shakuzen authored Mar 11, 2024
1 parent 5d1f7ed commit a568824
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ public void start(ThreadFactory threadFactory) {
stop();

if (config.enabled()) {
logger.info("publishing metrics for " + getClass().getSimpleName() + " every "
+ TimeUtils.format(config.step()));
logger.info(startMessage());

scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(threadFactory);
long stepMillis = config.step().toMillis();
Expand All @@ -118,6 +117,17 @@ public void start(ThreadFactory threadFactory) {
}
}

/**
* Message that will be logged when the registry is {@link #start(ThreadFactory)
* started}. This can be overridden to customize the message with info specific to the
* registry implementation that may be helpful in troubleshooting. By default, the
* registry class name and step interval are included.
* @return message to log on registry start
*/
protected String startMessage() {
return "publishing metrics for " + getClass().getSimpleName() + " every " + TimeUtils.format(config.step());
}

public void stop() {
if (scheduledExecutorService != null) {
scheduledExecutorService.shutdown();
Expand Down

0 comments on commit a568824

Please sign in to comment.