0

I am calculating dropwizard metrics and I am using the "meter" metric of DW to calculate how many number of times in a second a particular API was hit. and I want to send this "rate metrics" calculated by DW to Prometheus.

I know DW stores these metrics values in java heap memory. How do I send them to Prometheus? Also, I do not want to make use of the "Pushgateway" since it isn't a batch job.

userdr725
  • 25
  • 1
  • 6

1 Answers1

0
import io.micrometer.core.instrument.* 

/**
 * Avoid weak reference recycling
 */
private final static AtomicLong ALONG = new AtomicLong(0);

public void execute(ShardingContext shardingContext) {
  Gauge.builder("gaugeName",
    ALONG, (t) -> {
      // ... ... get result
      return 1;
    }).register(Metrics.globalRegistry);
}
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 15 '22 at 09:35