com.demo.app.MetricsConfig Maven / Gradle / Ivy
package com.demo.app;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.codahale.metrics.MetricRegistry;
import io.micrometer.core.instrument.Clock;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.config.NamingConvention;
import io.micrometer.core.instrument.dropwizard.DropwizardConfig;
import io.micrometer.core.instrument.dropwizard.DropwizardMeterRegistry;
import io.micrometer.core.instrument.util.HierarchicalNameMapper;
@Configuration
public class MetricsConfig {
@Bean
public MetricRegistry dropwizardRegistry() {
return new MetricRegistry();
}
@Bean
public MeterRegistry consoleLoggingRegistry(MetricRegistry dropwizardRegistry) {
DropwizardConfig consoleConfig = new DropwizardConfig() {
@Override
public String prefix() {
return "console";
}
@Override
public String get(String key) {
return null;
}
};
DropwizardMeterRegistry reg = new DropwizardMeterRegistry(consoleConfig, dropwizardRegistry, HierarchicalNameMapper.DEFAULT,
Clock.SYSTEM) {
@Override
protected Double nullGaugeValue() {
return null;
}
};
reg.config().namingConvention(NamingConvention.dot);
return reg;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy