mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Remove injectable constructors in metrics library
Users of the client library should be responsible for providing the bindings required. By removing the injectable constructors and named bindings in their parameters, the client library is no longer forcing its users to provide bindings with specific named annotations. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=170490834
This commit is contained in:
parent
ac0718079d
commit
dc41d7923e
2 changed files with 6 additions and 18 deletions
|
@ -30,8 +30,6 @@ import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Engine to write metrics to a {@link MetricWriter} on a regular periodic basis.
|
* Engine to write metrics to a {@link MetricWriter} on a regular periodic basis.
|
||||||
|
@ -57,11 +55,8 @@ public class MetricReporter extends AbstractScheduledService {
|
||||||
* @param writeInterval time period between metric writes, in seconds.
|
* @param writeInterval time period between metric writes, in seconds.
|
||||||
* @param threadFactory factory to use when creating background threads.
|
* @param threadFactory factory to use when creating background threads.
|
||||||
*/
|
*/
|
||||||
@Inject
|
|
||||||
public MetricReporter(
|
public MetricReporter(
|
||||||
MetricWriter metricWriter,
|
MetricWriter metricWriter, long writeInterval, ThreadFactory threadFactory) {
|
||||||
@Named("metricsWriteInterval") long writeInterval,
|
|
||||||
@Named("metricsBackgroundThreadFactory") ThreadFactory threadFactory) {
|
|
||||||
this(
|
this(
|
||||||
metricWriter,
|
metricWriter,
|
||||||
writeInterval,
|
writeInterval,
|
||||||
|
|
|
@ -27,11 +27,10 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
import dagger.Provides;
|
import dagger.Provides;
|
||||||
import google.registry.config.RegistryConfig.Config;
|
import google.registry.config.RegistryConfig.Config;
|
||||||
|
import google.registry.monitoring.metrics.MetricReporter;
|
||||||
import google.registry.monitoring.metrics.MetricWriter;
|
import google.registry.monitoring.metrics.MetricWriter;
|
||||||
import google.registry.monitoring.metrics.stackdriver.StackdriverWriter;
|
import google.registry.monitoring.metrics.stackdriver.StackdriverWriter;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ThreadFactory;
|
|
||||||
import javax.inject.Named;
|
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
|
|
||||||
/** Dagger module for Google Stackdriver service connection objects. */
|
/** Dagger module for Google Stackdriver service connection objects. */
|
||||||
|
@ -85,15 +84,9 @@ public final class StackdriverModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Named("metricsBackgroundThreadFactory")
|
static MetricReporter provideMetricReporter(
|
||||||
static ThreadFactory provideThreadFactory() {
|
MetricWriter metricWriter, @Config("metricsWriteInterval") Duration writeInterval) {
|
||||||
return ThreadManager.backgroundThreadFactory();
|
return new MetricReporter(
|
||||||
}
|
metricWriter, writeInterval.getStandardSeconds(), ThreadManager.backgroundThreadFactory());
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Named("metricsWriteInterval")
|
|
||||||
static long provideMetricsWriteInterval(
|
|
||||||
@Config("metricsWriteInterval") Duration metricsWriteInterval) {
|
|
||||||
return metricsWriteInterval.getStandardSeconds();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue