本文整理匯總了Java中com.nike.riposte.server.config.AppInfo.environment方法的典型用法代碼示例。如果您正苦於以下問題:Java AppInfo.environment方法的具體用法?Java AppInfo.environment怎麽用?Java AppInfo.environment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.nike.riposte.server.config.AppInfo
的用法示例。
在下文中一共展示了AppInfo.environment方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: metricsReporters
import com.nike.riposte.server.config.AppInfo; //導入方法依賴的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;
}
示例2: metricsReporters
import com.nike.riposte.server.config.AppInfo; //導入方法依賴的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;
}
示例3: metricsReporters_are_added_as_expected
import com.nike.riposte.server.config.AppInfo; //導入方法依賴的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);
}