本文整理了Java中io.dropwizard.setup.Bootstrap.getMetricRegistry()
方法的一些代码示例,展示了Bootstrap.getMetricRegistry()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bootstrap.getMetricRegistry()
方法的具体详情如下:
包路径:io.dropwizard.setup.Bootstrap
类名称:Bootstrap
方法名:getMetricRegistry
[英]Returns the application metrics.
[中]返回应用程序度量。
代码示例来源:origin: dropwizard/dropwizard
/**
* Registers the JVM metrics to the metric registry and start to report
* the registry metrics via JMX.
*/
public void registerMetrics() {
if (metricsAreRegistered) {
return;
}
getMetricRegistry().register("jvm.attribute", new JvmAttributeGaugeSet());
getMetricRegistry().register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory
.getPlatformMBeanServer()));
getMetricRegistry().register("jvm.classloader", new ClassLoadingGaugeSet());
getMetricRegistry().register("jvm.filedescriptor", new FileDescriptorRatioGauge());
getMetricRegistry().register("jvm.gc", new GarbageCollectorMetricSet());
getMetricRegistry().register("jvm.memory", new MemoryUsageGaugeSet());
getMetricRegistry().register("jvm.threads", new ThreadStatesGaugeSet());
JmxReporter.forRegistry(metricRegistry).build().start();
metricsAreRegistered = true;
}
代码示例来源:origin: dropwizard/dropwizard
@Override
protected void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception {
final Environment environment = new Environment(bootstrap.getApplication().getName(),
bootstrap.getObjectMapper(),
bootstrap.getValidatorFactory(),
bootstrap.getMetricRegistry(),
bootstrap.getClassLoader(),
bootstrap.getHealthCheckRegistry());
configuration.getMetricsFactory().configure(environment.lifecycle(),
bootstrap.getMetricRegistry());
configuration.getServerFactory().configure(environment);
bootstrap.run(configuration, environment);
application.run(configuration, environment);
run(environment, namespace, configuration);
}
代码示例来源:origin: dropwizard/dropwizard
@Override
@SuppressWarnings("unchecked")
public void run(Bootstrap<?> wildcardBootstrap, Namespace namespace) throws Exception {
final Bootstrap<T> bootstrap = (Bootstrap<T>) wildcardBootstrap;
configuration = parseConfiguration(bootstrap.getConfigurationFactoryFactory(),
bootstrap.getConfigurationSourceProvider(),
bootstrap.getValidatorFactory().getValidator(),
namespace.getString("file"),
getConfigurationClass(),
bootstrap.getObjectMapper());
try {
if (configuration != null) {
configuration.getLoggingFactory().configure(bootstrap.getMetricRegistry(),
bootstrap.getApplication().getName());
}
run(bootstrap, namespace, configuration);
} finally {
if (!asynchronous) {
cleanup();
}
}
}
代码示例来源:origin: io.dropwizard/dropwizard-core
/**
* Registers the JVM metrics to the metric registry and start to report
* the registry metrics via JMX.
*/
public void registerMetrics() {
if (metricsAreRegistered) {
return;
}
getMetricRegistry().register("jvm.attribute", new JvmAttributeGaugeSet());
getMetricRegistry().register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory
.getPlatformMBeanServer()));
getMetricRegistry().register("jvm.classloader", new ClassLoadingGaugeSet());
getMetricRegistry().register("jvm.filedescriptor", new FileDescriptorRatioGauge());
getMetricRegistry().register("jvm.gc", new GarbageCollectorMetricSet());
getMetricRegistry().register("jvm.memory", new MemoryUsageGaugeSet());
getMetricRegistry().register("jvm.threads", new ThreadStatesGaugeSet());
JmxReporter.forRegistry(metricRegistry).build().start();
metricsAreRegistered = true;
}
代码示例来源:origin: io.dropwizard/dropwizard-core
@Override
protected void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception {
final Environment environment = new Environment(bootstrap.getApplication().getName(),
bootstrap.getObjectMapper(),
bootstrap.getValidatorFactory().getValidator(),
bootstrap.getMetricRegistry(),
bootstrap.getClassLoader(),
bootstrap.getHealthCheckRegistry());
configuration.getMetricsFactory().configure(environment.lifecycle(),
bootstrap.getMetricRegistry());
configuration.getServerFactory().configure(environment);
bootstrap.run(configuration, environment);
application.run(configuration, environment);
run(environment, namespace, configuration);
}
代码示例来源:origin: io.dropwizard/dropwizard-core
@Override
@SuppressWarnings("unchecked")
public void run(Bootstrap<?> wildcardBootstrap, Namespace namespace) throws Exception {
final Bootstrap<T> bootstrap = (Bootstrap<T>) wildcardBootstrap;
configuration = parseConfiguration(bootstrap.getConfigurationFactoryFactory(),
bootstrap.getConfigurationSourceProvider(),
bootstrap.getValidatorFactory().getValidator(),
namespace.getString("file"),
getConfigurationClass(),
bootstrap.getObjectMapper());
try {
if (configuration != null) {
configuration.getLoggingFactory().configure(bootstrap.getMetricRegistry(),
bootstrap.getApplication().getName());
}
run(bootstrap, namespace, configuration);
} finally {
if (!asynchronous) {
cleanup();
}
}
}
代码示例来源:origin: dropwizard-jobs/dropwizard-jobs
@Override
public void initialize(Bootstrap<?> bootstrap) {
// add shared metrics registry to be used by Jobs, since defaultRegistry
// has been removed
SharedMetricRegistries.add(Job.DROPWIZARD_JOBS_KEY, bootstrap.getMetricRegistry());
}
代码示例来源:origin: roskart/dropwizard-jaxws
/**
* Implements com.yammer.dropwizard.Bundle#initialize()
*/
@Override
public void initialize(Bootstrap<?> bootstrap) {
this.jaxwsEnvironment.setInstrumentedInvokerBuilder(
new InstrumentedInvokerFactory(bootstrap.getMetricRegistry()));
}
代码示例来源:origin: HubSpot/Singularity
@Override
public void configure(Binder binder) {
binder.install(new MetricsInstrumentationModule(getBootstrap().getMetricRegistry()));
binder.install(new SingularityMainModule(getConfiguration()));
binder.install(new SingularityDataModule());
binder.install(new SingularitySchedulerModule());
binder.install(new SingularityResourceModule(getConfiguration().getUiConfiguration()));
binder.install(new SingularityTranscoderModule());
binder.install(new SingularityHistoryModule(getConfiguration()));
binder.install(new SingularityMesosModule());
binder.install(new SingularityZkMigrationsModule());
binder.install(new SingularityMesosClientModule());
binder.install(new SingularityJerseyModule());
// API Docs
getEnvironment().jersey().register(SingularityOpenApiResource.class);
binder.install(new SingularityEventModule(getConfiguration()));
}
代码示例来源:origin: yammer/tenacity
@Override
public void initialize(Bootstrap<?> bootstrap) {
try {
HystrixPlugins.getInstance().registerMetricsPublisher(new YammerMetricsPublisher(bootstrap.getMetricRegistry()));
} catch (Exception err) {
LOGGER.warn("Failed to register YammerMetricsPublisher with HystrixPlugins. This is what MetricsPublisher is currently registered: {}",
HystrixPlugins.getInstance().getMetricsPublisher().getClass(), err);
}
executionHook.ifPresent(HystrixPlugins.getInstance()::registerCommandExecutionHook);
}
代码示例来源:origin: com.yammer.tenacity/tenacity-core
@Override
public void initialize(Bootstrap<?> bootstrap) {
try {
HystrixPlugins.getInstance().registerMetricsPublisher(new YammerMetricsPublisher(bootstrap.getMetricRegistry()));
} catch (Exception err) {
LOGGER.warn("Failed to register YammerMetricsPublisher with HystrixPlugins. This is what MetricsPublisher is currently registered: {}",
HystrixPlugins.getInstance().getMetricsPublisher().getClass(), err);
}
executionHook.ifPresent(HystrixPlugins.getInstance()::registerCommandExecutionHook);
}
代码示例来源:origin: bazaarvoice/emodb
@Override
protected void run(Bootstrap<EmoConfiguration> bootstrap, Namespace namespace, EmoConfiguration configuration)
throws Exception {
String serviceName = namespace.getString("service");
CuratorFramework curator = configuration.getZooKeeperConfiguration().newCurator();
curator.start();
ZooKeeperHostDiscovery hostDiscovery = new ZooKeeperHostDiscovery(curator, serviceName, bootstrap.getMetricRegistry());
for (ServiceEndPoint endPoint : hostDiscovery.getHosts()) {
System.out.println(endPoint.getId());
}
hostDiscovery.close();
curator.close();
}
}
代码示例来源:origin: dropwizard/dropwizard-flyway
@Override
protected void run(final Bootstrap<T> bootstrap, final Namespace namespace, final T configuration) throws Exception {
final PooledDataSourceFactory datasourceFactory = databaseConfiguration.getDataSourceFactory(configuration);
final FlywayFactory flywayFactory = flywayConfiguration.getFlywayFactory(configuration);
final Flyway flyway = flywayFactory.build(datasourceFactory.build(bootstrap.getMetricRegistry(), "Flyway"));
try {
run(namespace, flyway);
} catch (FlywayException e) {
LOG.error("Error while running database command", e);
throw e;
}
}
代码示例来源:origin: bazaarvoice/emodb
@Override
protected void run(Bootstrap<EmoConfiguration> bootstrap, Namespace namespace, EmoConfiguration emoConfiguration)
throws Exception {
_outputOnly = namespace.getBoolean("output_only");
DdlConfiguration ddlConfiguration = parseDdlConfiguration(toFile(namespace.getString("config-ddl")));
CuratorFramework curator = null;
if (!_outputOnly) {
curator = emoConfiguration.getZooKeeperConfiguration().newCurator();
curator.start();
}
try {
createKeyspacesIfNecessary(emoConfiguration, ddlConfiguration, curator, bootstrap.getMetricRegistry());
} finally {
Closeables.close(curator, true);
}
}
代码示例来源:origin: bazaarvoice/emodb
MetricRegistry metricRegistry = bootstrap.getMetricRegistry();
Client client = createDefaultJerseyClient(config.getHttpClientConfiguration(), metricRegistry, "");
代码示例来源:origin: homeaway/stream-registry
@Override
public void initialize(final Bootstrap<StreamRegistryConfiguration> bootstrap) {
// EnvironmentVariableSubstitutor enables EnvVariables to be substituted into the configuration before initialization
bootstrap.setConfigurationSourceProvider(
new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(),
new EnvironmentVariableSubstitutor(false)
)
);
bootstrap.addBundle(new SwaggerBundle<StreamRegistryConfiguration>() {
@Override
protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(StreamRegistryConfiguration configuration) {
return configuration.getSwaggerBundleConfiguration();
}
});
metricRegistry = bootstrap.getMetricRegistry();
}
代码示例来源:origin: bazaarvoice/emodb
@Override
public void initialize(Bootstrap<EmoConfiguration> bootstrap) {
bootstrap.addCommand(new CreateKeyspacesCommand());
bootstrap.addCommand(new RegisterCassandraCommand());
bootstrap.addCommand(new ListCassandraCommand());
bootstrap.addCommand(new UnregisterCassandraCommand());
bootstrap.addCommand(new PurgeDatabusEventsCommand());
bootstrap.addCommand(new AllTablesReportCommand());
bootstrap.addCommand(new EncryptConfigurationApiKeyCommand());
EmoServiceObjectMapperFactory.configure(bootstrap.getObjectMapper());
bootstrap.getMetricRegistry().register("jvm.gc.totals", new EmoGarbageCollectorMetricSet());
}
代码示例来源:origin: yammer/breakerbox
.commandExecutionHook(new ExceptionLoggingCommandHook(
ImmutableList.of(
new DBIExceptionLogger(bootstrap.getMetricRegistry()),
new SQLExceptionLogger(bootstrap.getMetricRegistry()),
new DefaultExceptionLogger()))))
.build();
代码示例来源:origin: com.hubspot/SingularityService
@Override
public void configure(Binder binder) {
binder.install(new MetricsInstrumentationModule(getBootstrap().getMetricRegistry()));
binder.install(new SingularityMainModule(getConfiguration()));
binder.install(new SingularityDataModule());
binder.install(new SingularitySchedulerModule());
binder.install(new SingularityResourceModule(getConfiguration().getUiConfiguration()));
binder.install(new SingularityTranscoderModule());
binder.install(new SingularityHistoryModule(getConfiguration()));
binder.install(new SingularityMesosModule());
binder.install(new SingularityZkMigrationsModule());
binder.install(new SingularityMesosClientModule());
binder.install(new SingularityJerseyModule());
// API Docs
getEnvironment().jersey().register(SingularityOpenApiResource.class);
binder.install(new SingularityEventModule(getConfiguration()));
}
内容来源于网络,如有侵权,请联系作者删除!