Why is Micrometer MeterRegistryCustomizer deny not working?

74 views Asked by At

I am using Kotlin with spring boot version 3.0.4 alongside with micrometer to send some tracing to Jaeger. But since I deployed this app into a Kubernetes instance it keeps checking the URL/actuator/healthy, but I do not want those calls to be sent to Jaeger.

I am trying to use MeterRegistryCustomizer deny, to keep those calls from being sent to Jaeger, but it seems that deny is not working, even when I set it to deny everything. I am gonna paste the bean I am using to exclude those calls, which is not working at the moment.

The Code:

@Bean
fun buildMeterRegistry(): MeterRegistryCustomizer < MeterRegistry > {
  return MeterRegistryCustomizer < MeterRegistry > {
    registry ->
    registry.config()
    .meterFilter(MeterFilter.deny())
    .meterFilter(MeterFilter.deny {
      id ->
        val uri: String ? = id.getTag("uri")
        (uri != null &&
          (uri.startsWith("/actuator") ||
            uri.startsWith("/metrics") ||
            uri.startsWith("/health") ||
            uri.startsWith("/favicon.ico") ||
            uri.startsWith("/prometheus")))
    })
  }
}

It seems that deny is not working because even when I set it up like this, it keeps sending all the metrics to Jaeger.

The Code:

@Bean
fun buildMeterRegistry(): MeterRegistryCustomizer < MeterRegistry > {
  return MeterRegistryCustomizer < MeterRegistry > {
    registry ->
    registry.config()
    .meterFilter(MeterFilter.deny())
    .meterFilter(MeterFilter.deny {
      true
    })
  }
}

Also tried (as suggested):

@Bean
fun meterFilter(): MeterFilter {
    return object : MeterFilter {
        override fun accept(id: Meter.Id): MeterFilterReply {
            return MeterFilterReply.DENY
        }
    }
}

So I'd like your help to understand how I could keep/deny some requests from being published to my Jaeger instance.

0

There are 0 answers