com.github.mtakaki.dropwizard.petite.MonitoredPetiteContainer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dropwizard-petite Show documentation
Show all versions of dropwizard-petite Show documentation
Jodd Petite integration for dropwizard
The newest version!
package com.github.mtakaki.dropwizard.petite;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import jodd.petite.PetiteContainer;
public class MonitoredPetiteContainer extends PetiteContainer {
private final Timer timerGetBean;
private final Timer timerAddBean;
public MonitoredPetiteContainer(final MetricRegistry metricRegistry) {
this.timerGetBean = metricRegistry
.timer(MetricRegistry.name(MonitoredPetiteContainer.class, "getBean"));
this.timerAddBean = metricRegistry
.timer(MetricRegistry.name(MonitoredPetiteContainer.class, "addBean"));
}
@Override
public T getBean(final Class type) {
try (Timer.Context context = this.timerGetBean.time()) {
return super.getBean(type);
}
}
@Override
public T getBean(final String name) {
try (Timer.Context context = this.timerGetBean.time()) {
return super.getBean(name);
}
}
@Override
public void addBean(final String name, final Object bean) {
try (Timer.Context context = this.timerAddBean.time()) {
super.addBean(name, bean);
}
}
} © 2015 - 2025 Weber Informatics LLC | Privacy Policy