use of eu.toolchain.ffwd.FastForward in project helios by spotify.
the class FastForwardReporter method create.
/**
* Overload of {@link #create(MetricRegistry, Optional, String, int)} which allows for setting
* additional attributes in each reported metric.
*
* <p>The additional attributes are modeled as a Supplier to allow for attributes that might
* change values at runtime.
*/
public static FastForwardReporter create(MetricRegistry registry, Optional<HostAndPort> address, String metricKey, int intervalSeconds, Supplier<Map<String, String>> additionalAttributes) throws SocketException, UnknownHostException {
final FastForward ff;
if (address.isPresent()) {
ff = FastForward.setup(address.get().getHostText(), address.get().getPort());
} else {
ff = FastForward.setup();
}
final ThreadFactory threadFactory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("fast-forward-reporter-%d").build();
final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(threadFactory);
return new FastForwardReporter(ff, registry, executorService, metricKey, intervalSeconds, TimeUnit.SECONDS, additionalAttributes);
}
Aggregations