Search in sources :

Example 1 with InstrumentedResourceMethodApplicationListener

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());
}
Also used : OrganizationPrincipal(gov.cms.dpc.api.auth.OrganizationPrincipal) GenerateRequestIdFilter(gov.cms.dpc.common.logging.filters.GenerateRequestIdFilter) InstrumentedResourceMethodApplicationListener(com.codahale.metrics.jersey2.InstrumentedResourceMethodApplicationListener) AuthValueFactoryProvider(io.dropwizard.auth.AuthValueFactoryProvider) LogResponseFilter(gov.cms.dpc.common.logging.filters.LogResponseFilter) JsonParseExceptionMapper(gov.cms.dpc.api.exceptions.JsonParseExceptionMapper)

Example 2 with InstrumentedResourceMethodApplicationListener

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());
}
Also used : GenerateRequestIdFilter(gov.cms.dpc.common.logging.filters.GenerateRequestIdFilter) InstrumentedResourceMethodApplicationListener(com.codahale.metrics.jersey2.InstrumentedResourceMethodApplicationListener) LogResponseFilter(gov.cms.dpc.common.logging.filters.LogResponseFilter)

Example 3 with InstrumentedResourceMethodApplicationListener

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);
}
Also used : SlidingTimeWindowReservoir(com.codahale.metrics.SlidingTimeWindowReservoir) InstrumentedResourceMethodApplicationListener(com.codahale.metrics.jersey2.InstrumentedResourceMethodApplicationListener) MetricRegistry(com.codahale.metrics.MetricRegistry) Reservoir(com.codahale.metrics.Reservoir) SlidingTimeWindowReservoir(com.codahale.metrics.SlidingTimeWindowReservoir) JmxReporter(com.codahale.metrics.jmx.JmxReporter)

Aggregations

InstrumentedResourceMethodApplicationListener (com.codahale.metrics.jersey2.InstrumentedResourceMethodApplicationListener)3 GenerateRequestIdFilter (gov.cms.dpc.common.logging.filters.GenerateRequestIdFilter)2 LogResponseFilter (gov.cms.dpc.common.logging.filters.LogResponseFilter)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 Reservoir (com.codahale.metrics.Reservoir)1 SlidingTimeWindowReservoir (com.codahale.metrics.SlidingTimeWindowReservoir)1 JmxReporter (com.codahale.metrics.jmx.JmxReporter)1 OrganizationPrincipal (gov.cms.dpc.api.auth.OrganizationPrincipal)1 JsonParseExceptionMapper (gov.cms.dpc.api.exceptions.JsonParseExceptionMapper)1 AuthValueFactoryProvider (io.dropwizard.auth.AuthValueFactoryProvider)1