use of com.codahale.metrics.jersey2.InstrumentedResourceMethodApplicationListener in project dpc-app by CMSgov.
the class DPCAPIService method run.
@Override
public void run(final DPCAPIConfiguration configuration, final Environment environment) {
EnvironmentParser.getEnvironment("API");
final var listener = new InstrumentedResourceMethodApplicationListener(environment.metrics());
environment.jersey().getResourceConfig().register(listener);
environment.jersey().register(new AuthValueFactoryProvider.Binder<>(OrganizationPrincipal.class));
environment.jersey().register(new JsonParseExceptionMapper());
environment.jersey().register(new GenerateRequestIdFilter(false));
environment.jersey().register(new LogResponseFilter());
}
use of com.codahale.metrics.jersey2.InstrumentedResourceMethodApplicationListener in project dpc-app by CMSgov.
the class DPCAttributionService method run.
@Override
public void run(DPCAttributionConfiguration configuration, Environment environment) {
EnvironmentParser.getEnvironment("Attribution");
final var listener = new InstrumentedResourceMethodApplicationListener(environment.metrics());
environment.jersey().getResourceConfig().register(listener);
environment.jersey().register(new GenerateRequestIdFilter(true));
environment.jersey().register(new LogResponseFilter());
}
use of com.codahale.metrics.jersey2.InstrumentedResourceMethodApplicationListener in project helix by apache.
the class HelixRestServer method initMetricRegistry.
/*
* Initialize metric registry and jmx reporter for each namespace.
*/
private void initMetricRegistry(ResourceConfig cfg, String namespace) {
MetricRegistry metricRegistry = new MetricRegistry();
// Set the sliding time window to be 1 minute for now
Supplier<Reservoir> reservoirSupplier = () -> {
return new SlidingTimeWindowReservoir(60, TimeUnit.SECONDS);
};
cfg.register(new InstrumentedResourceMethodApplicationListener(metricRegistry, Clock.defaultClock(), false, reservoirSupplier));
SharedMetricRegistries.add(namespace, metricRegistry);
// JmxReporter doesn't have an option to specify namespace for each servlet,
// we use a customized object name factory to get and insert namespace to object name.
JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).inDomain(REST_DOMAIN).createsObjectNamesWith(new HelixRestObjectNameFactory(namespace)).build();
jmxReporter.start();
_jmxReporterList.add(jmxReporter);
}
Aggregations