spring-bootprometheusmetricsmicrometer

Micrometer LongTaskTimer timer in multiple instances?


How do I meter the same task performed on multiple worker instances?

Say I have ten workers who take tasks from the queue and process them.

Should I have a LongTaskTimer with a unique name for each worker or just a different set of tags?


Solution

  • Using a different set of tags is the recommended approach, that way it is easier to aggregate, process, follow naming conventions and it is explicit what you mean by that tag (it has an explicit name). This is the whole deal with using a dimensional metrics library (over hierarchical), use that advantage:

    LongTaskTimer ltt = LongTaskTimer.builder("tasks")
        .description("a description of what this timer does")
        .tags("instanceId", instanceId)
        .register(registry);