2

I am currently exporting Actuator metrics for my Spring Boot Webflux project to DataDog with 10 seconds interval. I would like to add another exporter for one of our internal system that is not in the list of supported backends. Looking at the implementation from DataDogMeterRegistry I came up with the following.

public interface ExternalConfig extends StepRegistryConfig {

  ExternalConfig DEFAULT = k -> null;

  @Override
  default String prefix() {
    return "vwexternal";
  }
}

@Slf4j
public class ExternalMeterRegistry extends StepMeterRegistry {

  public ExternalMeterRegistry() {
    this(ExternalConfig.DEFAULT, Clock.SYSTEM);
  }

  public ExternalMeterRegistry(StepRegistryConfig config, Clock clock) {
    super(config, clock);
  }

  @Override
  protected void publish() {
    log.info("HERE");
  }

  @Override
  protected TimeUnit getBaseTimeUnit() {
    return TimeUnit.MILLISECONDS;
  }
}

@SpringBootApplication
public class MyApplication {
  public static void main(String[] args) {
    SpringApplication.run(MyApplication.class, args);
    Metrics.addRegistry(new ExternalMeterRegistry());
  }
}

However this is not working since no logs are printed.

My question is how can I add and implement another MeterRegistry for Spring Boot Micrometer?

user3139545
  • 6,882
  • 13
  • 44
  • 87

1 Answers1

3

You need to start the publishing. Compare with the LoggingMeterRegistry

In your constructor something like:

start(new NamedThreadFactory("vw-metrics-publisher"))
checketts
  • 14,167
  • 10
  • 53
  • 82