I have the following Java snippet that I am using to publish histogram metrics
public class MessageConsumer {
private MeterRegistry meterRegistry;
private NormalRandomGenerator serviceResponseTimeSecondsGenerator;
Timer responseTimeSeconds;
@Autowired
public MessageConsumer(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
this.serviceResponseTimeSecondsGenerator = new NormalRandomGenerator(0.5, 0.1);
this.responseTimeSeconds = Timer
.builder("processing_duration")
.serviceLevelObjectives(
Duration.ofMillis(100),
Duration.ofMillis(200),
Duration.ofMillis(300),
Duration.ofMillis(400),
Duration.ofMillis(500),
Duration.ofMillis(600),
Duration.ofMillis(700),
Duration.ofMillis(800),
Duration.ofMillis(900),
Duration.ofMillis(1000),
Duration.ofMillis(1100),
Duration.ofMillis(1200),
Duration.ofMillis(1300),
Duration.ofMillis(1400),
Duration.ofMillis(1500))
.maximumExpectedValue(Duration.ofMillis(1500))
.register(this.meterRegistry);
}
@KafkaListener(topics = "hist")
public void histListen(String message) throws InterruptedException {
Type type = new TypeToken<HashMap<String, String>>() {
}.getType();
Map<String, String> r = new Gson().fromJson(message, type);
String id = r.get("id");
String pod = r.get("pod");
long responseTimeMillis = (long) (serviceResponseTimeSecondsGenerator.normalRandom() * 1_000);
log.info("Received message: {}, will say responseTime is {}", r, responseTimeMillis);
responseTimeSeconds.record(Duration.ofMillis(responseTim
My issue is that I am not able to find a way to add the tags that whose values I know at runtime when publishing.
I need to create grafana dashboard and need to do the grouping say on “id” level. Unless I can put that tag/label, I wont be able to. How do I handle that? Or it is not supported?