Search in sources :

Example 1 with FastForward

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);
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) FastForward(eu.toolchain.ffwd.FastForward) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder)

Aggregations

ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 FastForward (eu.toolchain.ffwd.FastForward)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ThreadFactory (java.util.concurrent.ThreadFactory)1