本文整理汇总了Java中com.nike.riposte.metrics.codahale.contrib.DefaultSLF4jReporterFactory类的典型用法代码示例。如果您正苦于以下问题:Java DefaultSLF4jReporterFactory类的具体用法?Java DefaultSLF4jReporterFactory怎么用?Java DefaultSLF4jReporterFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultSLF4jReporterFactory类属于com.nike.riposte.metrics.codahale.contrib包,在下文中一共展示了DefaultSLF4jReporterFactory类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MetricsTestConfig
import com.nike.riposte.metrics.codahale.contrib.DefaultSLF4jReporterFactory; //导入依赖的package包/类
public MetricsTestConfig() {
try {
port = ComponentTestUtils.findFreePort();
}
catch (IOException e) {
throw new RuntimeException("Couldn't allocate port", e);
}
CodahaleMetricsEngine metricsEngine = new CodahaleMetricsEngine()
.addReporter(new DefaultSLF4jReporterFactory())
.addReporter(new RiposteGraphiteReporterFactory("test.metrics.stuff", "doesnotexist.nikecloud.com", 2003))
.reportJvmMetrics()
.start();
metricsListener = new CodahaleMetricsListener(metricsEngine.getMetricsCollector());
metricsListener.initEndpointAndServerConfigMetrics(this);
}
示例2: metricsReporters
import com.nike.riposte.metrics.codahale.contrib.DefaultSLF4jReporterFactory; //导入依赖的package包/类
@Provides
@Singleton
public List<ReporterFactory> metricsReporters(
@Named("metrics.slf4j.reporting.enabled") boolean slf4jReportingEnabled,
@Named("metrics.jmx.reporting.enabled") boolean jmxReportingEnabled,
@Named("metrics.graphite.url") String graphiteUrl,
@Named("metrics.graphite.port") int graphitePort,
@Named("metrics.graphite.reporting.enabled") boolean graphiteEnabled,
@Named("appInfoFuture") CompletableFuture<AppInfo> appInfoFuture
) {
List<ReporterFactory> reporters = new ArrayList<>();
if (slf4jReportingEnabled)
reporters.add(new DefaultSLF4jReporterFactory());
if (jmxReportingEnabled)
reporters.add(new DefaultJMXReporterFactory());
if (graphiteEnabled) {
AppInfo appInfo = appInfoFuture.join();
String graphitePrefix = appInfo.appId() + "." + appInfo.dataCenter() + "." + appInfo.environment()
+ "." + appInfo.instanceId();
reporters.add(new DefaultGraphiteReporterFactory(graphitePrefix, graphiteUrl, graphitePort));
}
if (reporters.isEmpty()) {
logger.info("No metrics reporters enabled - disabling metrics entirely.");
return null;
}
String metricReporterTypes = reporters.stream()
.map(rf -> rf.getClass().getSimpleName())
.collect(Collectors.joining(",", "[", "]"));
logger.info("Metrics reporters enabled. metric_reporter_types={}", metricReporterTypes);
return reporters;
}
示例3: metricsReporters
import com.nike.riposte.metrics.codahale.contrib.DefaultSLF4jReporterFactory; //导入依赖的package包/类
@Provides
@Singleton
public List<ReporterFactory> metricsReporters(
@Named("metrics.slf4j.reporting.enabled") boolean slf4jReportingEnabled,
@Named("metrics.jmx.reporting.enabled") boolean jmxReportingEnabled,
@Named("metrics.signalfx.reporting.enabled") boolean signalFxEnabled,
@Named("graphite.url") String graphiteUrl,
@Named("graphite.port") int graphitePort,
@Named("graphite.reporting.enabled") boolean graphiteEnabled,
@Named("appInfoFuture") CompletableFuture<AppInfo> appInfoFuture,
@Nullable SignalFxReporterFactory signalFxReporterFactory
) {
List<ReporterFactory> reporters = new ArrayList<>();
if (slf4jReportingEnabled)
reporters.add(new DefaultSLF4jReporterFactory());
if (jmxReportingEnabled)
reporters.add(new DefaultJMXReporterFactory());
if (signalFxEnabled && signalFxReporterFactory != null)
reporters.add(signalFxReporterFactory);
if (graphiteEnabled) {
AppInfo appInfo = appInfoFuture.join();
String graphitePrefix = appInfo.appId() + "." + appInfo.dataCenter() + "." + appInfo.environment()
+ "." + appInfo.instanceId();
reporters.add(new DefaultGraphiteReporterFactory(graphitePrefix, graphiteUrl, graphitePort));
}
if (reporters.isEmpty()) {
logger.info("No metrics reporters enabled - disabling metrics entirely.");
return null;
}
String metricReporterTypes = reporters.stream()
.map(rf -> rf.getClass().getSimpleName())
.collect(Collectors.joining(",", "[", "]"));
logger.info("Metrics reporters enabled. metric_reporter_types={}", metricReporterTypes);
return reporters;
}
示例4: metricsReporters_are_added_as_expected
import com.nike.riposte.metrics.codahale.contrib.DefaultSLF4jReporterFactory; //导入依赖的package包/类
@DataProvider(value = {
"true | false | false",
"false | true | false",
"false | false | true",
"true | true | true",
}, splitBy = "\\|")
@Test
public void metricsReporters_are_added_as_expected(boolean enableSlf4jReporter, boolean enableJmxReporter,
boolean enableGraphiteReporter) {
// given
configForTesting = generateAppConfigWithMetricsEnabledOrDisabled(enableSlf4jReporter, enableJmxReporter,
enableGraphiteReporter);
appGuiceModule = new AppGuiceModule(configForTesting);
injector = generateInjector(appGuiceModule, configForTesting);
// when
List<ReporterFactory> reporters = injector.getInstance(Key.get(new TypeLiteral<List<ReporterFactory>>() {}));
List<Class<? extends ReporterFactory>> reporterClasses = reporters.stream()
.map(ReporterFactory::getClass)
.collect(Collectors.toList());
// then
if (enableSlf4jReporter)
assertThat(reporterClasses).contains(DefaultSLF4jReporterFactory.class);
else
assertThat(reporterClasses).doesNotContain(DefaultSLF4jReporterFactory.class);
if (enableJmxReporter)
assertThat(reporterClasses).contains(DefaultJMXReporterFactory.class);
else
assertThat(reporterClasses).doesNotContain(DefaultJMXReporterFactory.class);
if (enableGraphiteReporter) {
assertThat(reporterClasses).contains(DefaultGraphiteReporterFactory.class);
DefaultGraphiteReporterFactory graphiteReporter = (DefaultGraphiteReporterFactory)reporters
.stream().filter(r -> r instanceof DefaultGraphiteReporterFactory).findFirst().get();
AppInfo appInfo = injector.getInstance(Key.get(new TypeLiteral<CompletableFuture<AppInfo>>() {},
Names.named("appInfoFuture"))).join();
String expectedPrefix = appInfo.appId() + "." + appInfo.dataCenter() + "." + appInfo.environment()
+ "." + appInfo.instanceId();
String expectedGraphiteUrl = configForTesting.getString("metrics.graphite.url");
int expectedPort = configForTesting.getInt("metrics.graphite.port");
assertThat(Whitebox.getInternalState(graphiteReporter, "prefix")).isEqualTo(expectedPrefix);
assertThat(Whitebox.getInternalState(graphiteReporter, "graphiteURL")).isEqualTo(expectedGraphiteUrl);
assertThat(Whitebox.getInternalState(graphiteReporter, "graphitePort")).isEqualTo(expectedPort);
}
else
assertThat(reporterClasses).doesNotContain(DefaultGraphiteReporterFactory.class);
}