From b9f7ca97230c41230a7e4508c1d3ca7fd018537e Mon Sep 17 00:00:00 2001 From: HYEONSEOK1 Date: Wed, 31 Jul 2024 13:28:03 +0900 Subject: [PATCH] Add default factoryType tag for consistency in CommonsObjectPool2Metrics --- .../binder/commonspool2/CommonsObjectPool2Metrics.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/commonspool2/CommonsObjectPool2Metrics.java b/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/commonspool2/CommonsObjectPool2Metrics.java index 37ac39afe3..714d283502 100644 --- a/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/commonspool2/CommonsObjectPool2Metrics.java +++ b/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/commonspool2/CommonsObjectPool2Metrics.java @@ -129,12 +129,16 @@ public void bindTo(@NonNull MeterRegistry registry) { private Iterable nameTag(ObjectName name, String type) throws AttributeNotFoundException, MBeanException, ReflectionException, InstanceNotFoundException { + Tags tags = Tags.of("name", name.getKeyProperty("name"), "type", type); + String factoryType = "none"; // Default value for factoryType if not available + if (Objects.equals(type, "GenericObjectPool")) { // for GenericObjectPool, we want to include the name and factoryType as tags - String factoryType = mBeanServer.getAttribute(name, "FactoryType").toString(); - tags = Tags.concat(tags, "factoryType", factoryType); + factoryType = mBeanServer.getAttribute(name, "FactoryType").toString(); } + + tags = Tags.concat(tags, "factoryType", factoryType); return tags; }