Hi everyone, I figured out what was going on. The method that create a 
gauge metric takes a numeric value as a function. I imagine that this 
function is somehow executed in a lazy way, and that was the problem. The 
"function" that I was passing was actually a simple number, and the value 
was never updated.
For anyone having this issue, here is a snippet from the code that I wrote:

private final Map<String, AtomicInteger> statusCodes = new HashMap<>();

.
.
.

private void createOrUpdateMetric(String healthType, Status status) {
statusCodes.put(healthType, new AtomicInteger(healthToCode(status)));

Gauge.builder(HEALTH, statusCodes, statusCodes -> 
statusCodes.get(healthType).get())
.tags(Tags.of(Tag.of(HEALTH_TYPE, healthType)))
.description(HEALTH_DESCRIPTION + healthType)
.register(meterRegistry);
}
On Friday, December 4, 2020 at 8:06:50 PM UTC-3 Victor Augusto Farias Dinis 
wrote:

> Hi Stuart!
> Thanks for the quick response!
> Then my idea was correct about how to achieve what I am trying to.
> Now for the second question, do you know why my gauge metric are not 
> getting updated?
>
> I found a question on stack overflow referring to the same problem: 
> https://stackoverflow.com/questions/61771197/spring-boot-prometheus-micrometers-gauge-not-updating
>
> Thanks again!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/6cf4547d-11fb-4763-b759-480cdb09f5a8n%40googlegroups.com.

Reply via email to