I am trying to capture the metrics for an override method in Java / Springboot. Below is the snippet
@Override
@Timed(value = "processor_timer", histogram = true)
public void preProcess(byte[] key, byte[] event, Headers headers) {
super.preProcess(key, event, headers);
}
I have added this configuration as well still timer not working for the override method
import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@Configuration
@EnableAspectJAutoProxy
public class MetricsConfig {
@Bean
TimedAspect timedAspect(MeterRegistry registry) {
return new TimedAspect(registry);
}
}
Springboot Version
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
I am calling the preProcess like this
@Slf4j
public abstract class Processor<T> {
private static final String TIME_HEADER_KEY = "time";
private static final String ERRORS_HEADER_KEY = "errors";
String topic;
public EventProcessor(String topic,) {
this.topic = topic;
}
@Timed(value = "parent_preprocess_event", histogram = true)
public void preProcess(byte[] key, byte[] event, Headers headers) {
log.info("Inside parent preProcess");
T message = extractMessage(event);
//some business logic
}