Skip to content

Commit

Permalink
Merge pull request #83 from dinomite/parent-reporter
Browse files Browse the repository at this point in the history
Move start() to AbstractReporter
  • Loading branch information
codahale committed Sep 26, 2011
2 parents bf6d1d2 + f4dcce9 commit 572ef9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.yammer.metrics.reporting;

import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import com.yammer.metrics.core.MetricsRegistry;

Expand All @@ -15,4 +16,12 @@ protected AbstractReporter(MetricsRegistry metricsRegistry, String name) {

@Override
public abstract void run();

/**
* Starts sending output to ganglia server.
*
* @param period the period between successive displays
* @param unit the time unit of {@code period}
*/
public abstract void start(long period, TimeUnit unit);
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public List<?> values() {
private static JmxReporter INSTANCE;
public static final void startDefault(MetricsRegistry defaultMetricsRegistry) {
INSTANCE = new JmxReporter(defaultMetricsRegistry);
INSTANCE.start();
INSTANCE.start(1, TimeUnit.MINUTES);
}

public JmxReporter(MetricsRegistry metricsRegistry) {
Expand All @@ -313,8 +313,8 @@ public JmxReporter(MetricsRegistry metricsRegistry) {
this.server = ManagementFactory.getPlatformMBeanServer();
}

public void start() {
tickThread.scheduleAtFixedRate(this, 0, 1, TimeUnit.MINUTES);
public void start(long period, TimeUnit unit) {
tickThread.scheduleAtFixedRate(this, 0, period, unit);
// then schedule the tick thread every 100ms for the next second so
// as to pick up the initialization of most metrics (in the first 1s of
// the application lifecycle) w/o incurring a high penalty later on
Expand Down

0 comments on commit 572ef9f

Please sign in to comment.