From b9671c319a24bad27e4e6b07b30fd7d8c73ba886 Mon Sep 17 00:00:00 2001 From: raymond zhao Date: Tue, 17 Oct 2023 14:54:36 -0400 Subject: [PATCH 1/7] add bean attribute instance stats --- .../java/org/datadog/jmxfetch/Instance.java | 57 ++++++++++++++----- .../java/org/datadog/jmxfetch/Status.java | 5 ++ .../jmxfetch/util/InstanceTelemetry.java | 28 +++++++++ .../jmxfetch/util/InstanceTelemetryMBean.java | 2 + .../java/org/datadog/jmxfetch/StatusTest.java | 9 +++ 5 files changed, 87 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/datadog/jmxfetch/Instance.java b/src/main/java/org/datadog/jmxfetch/Instance.java index ded593d60..04654059a 100644 --- a/src/main/java/org/datadog/jmxfetch/Instance.java +++ b/src/main/java/org/datadog/jmxfetch/Instance.java @@ -434,7 +434,8 @@ public Connection getConnection( /** Initializes the instance. May force a new connection.. */ public void init(boolean forceNewConnection) - throws IOException, FailedLoginException, SecurityException { + throws IOException, FailedLoginException, SecurityException, + MalformedObjectNameException { log.info("Trying to connect to JMX Server at " + this.toString()); connection = getConnection(instanceMap, forceNewConnection); log.info( @@ -467,7 +468,7 @@ public String toString() { } /** Returns a map of metrics collected. */ - public List getMetrics() throws IOException { + public List getMetrics() throws IOException, MalformedObjectNameException { // In case of ephemeral beans, we can force to refresh the bean list x seconds // post initialization and every x seconds thereafter. @@ -509,13 +510,18 @@ public List getMetrics() throws IOException { } } } - instanceTelemetryBean.setBeansFetched(beans.size()); - instanceTelemetryBean.setTopLevelAttributeCount(matchingAttributes.size()); - instanceTelemetryBean.setMetricCount(metrics.size()); - log.debug("Updated jmx bean for instance: " + this.getCheckName() - + " With beans fetched = " + instanceTelemetryBean.getBeansFetched() - + " top attributes = " + instanceTelemetryBean.getTopLevelAttributeCount() - + " metrics = " + instanceTelemetryBean.getMetricCount()); + if (instanceTelemetryBean != null) { + instanceTelemetryBean.setBeansFetched(beans.size()); + instanceTelemetryBean.setTopLevelAttributeCount(matchingAttributes.size()); + instanceTelemetryBean.setMetricCount(metrics.size()); + log.debug("Updated jmx bean for instance: " + this.getCheckName() + + " With beans fetched = " + instanceTelemetryBean.getBeansFetched() + + " top attributes = " + instanceTelemetryBean.getTopLevelAttributeCount() + + " metrics = " + instanceTelemetryBean.getMetricCount() + + " domains queried = " + instanceTelemetryBean.getDomainsQueried() + + " wildcard query count = " + instanceTelemetryBean.getWildcardQueryCount() + + " attribute match ratio = " + instanceTelemetryBean.getAttributeMatchRatio()); + } return metrics; } @@ -547,11 +553,14 @@ private void getMatchingAttributes() throws IOException { this.failingAttributes.clear(); int metricsCount = 0; + int beansWithAttributeMatch = 0; + if (!action.equals(AppConfig.ACTION_COLLECT)) { reporter.displayInstanceName(this); } for (ObjectName beanName : this.beans) { + boolean attributeMatched = false; if (limitReached) { log.debug("Limit reached"); if (action.equals(AppConfig.ACTION_COLLECT)) { @@ -702,7 +711,17 @@ private void getMatchingAttributes() throws IOException { || action.equals(AppConfig.ACTION_LIST_NOT_MATCHING))) { reporter.displayNonMatchingAttributeName(jmxAttribute); } + if (jmxAttribute.getMatchingConf() != null) { + attributeMatched = true; + } } + if (attributeMatched) { + beansWithAttributeMatch += 1; + } + } + if (instanceTelemetryBean != null) { + instanceTelemetryBean.setAttributeMatchRatio((double) + beansWithAttributeMatch / beans.size()); } log.info("Found {} matching attributes", matchingAttributes.size()); } @@ -719,7 +738,7 @@ public List getBeansScopes() { * Query and refresh the instance's list of beans. Limit the query scope when possible on * certain actions, and fallback if necessary. */ - private void refreshBeansList() throws IOException { + private void refreshBeansList() throws IOException, MalformedObjectNameException { this.beans = new HashSet(); String action = appConfig.getAction(); boolean limitQueryScopes = @@ -733,14 +752,24 @@ private void refreshBeansList() throws IOException { ObjectName name = new ObjectName(scope); this.beans.addAll(connection.queryNames(name)); } - } catch (Exception e) { + if (instanceTelemetryBean != null) { + instanceTelemetryBean.setDomainsQueried(beanScopes.size()); + } + } catch (MalformedObjectNameException e) { + log.error("Unable to create ObjectName", e); + } catch (IOException e) { log.error( - "Unable to compute a common bean scope, querying all beans as a fallback", - e); + "Unable to query mbean server", e); } } - this.beans = (this.beans.isEmpty()) ? connection.queryNames(null) : this.beans; + if (this.beans.isEmpty()) { + this.beans = connection.queryNames(null); + if (instanceTelemetryBean != null) { + int wildcardQueryCount = instanceTelemetryBean.getWildcardQueryCount(); + instanceTelemetryBean.setWildcardQueryCount(wildcardQueryCount + 1); + } + } this.lastRefreshTime = System.currentTimeMillis(); } diff --git a/src/main/java/org/datadog/jmxfetch/Status.java b/src/main/java/org/datadog/jmxfetch/Status.java index e6ecfc494..637ada311 100644 --- a/src/main/java/org/datadog/jmxfetch/Status.java +++ b/src/main/java/org/datadog/jmxfetch/Status.java @@ -127,6 +127,11 @@ private void addStats( instStats.put("instance_attribute_count", instanceTelemetryBean.getTopLevelAttributeCount()); instStats.put("instance_metric_count", instanceTelemetryBean.getMetricCount()); + instStats.put("instance_domains_queried", instanceTelemetryBean.getDomainsQueried()); + instStats.put("instance_wildcard_query_count", + instanceTelemetryBean.getWildcardQueryCount()); + instStats.put("instance_attribute_match_ratio", + instanceTelemetryBean.getAttributeMatchRatio()); } instStats.put("message", message); instStats.put("status", status); diff --git a/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetry.java b/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetry.java index b216b54f5..7bc04b51e 100644 --- a/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetry.java +++ b/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetry.java @@ -7,12 +7,18 @@ public class InstanceTelemetry implements InstanceTelemetryMBean { private int beansFetched; private int topLevelAttributeCount; private int metricCount; + private int domainsQueried; + private int wildcardQueryCount; + private double attributeMatchRatio; /** Jmxfetch telemetry bean constructor. */ public InstanceTelemetry() { beansFetched = 0; topLevelAttributeCount = 0; metricCount = 0; + domainsQueried = 0; + wildcardQueryCount = 0; + attributeMatchRatio = 0.0; } public int getBeansFetched() { @@ -27,6 +33,17 @@ public int getMetricCount() { return metricCount; } + public int getDomainsQueried() { + return domainsQueried; + } + + public int getWildcardQueryCount() { + return wildcardQueryCount; + } + + public double getAttributeMatchRatio() { + return attributeMatchRatio; + } public void setBeansFetched(int count) { beansFetched = count; @@ -40,5 +57,16 @@ public void setMetricCount(int count) { metricCount = count; } + public void setDomainsQueried(int count) { + domainsQueried = count; + } + + public void setWildcardQueryCount(int count) { + wildcardQueryCount = count; + } + + public void setAttributeMatchRatio(double ratio) { + attributeMatchRatio = ratio; + } } diff --git a/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetryMBean.java b/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetryMBean.java index b80d126c0..3f5b028c4 100644 --- a/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetryMBean.java +++ b/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetryMBean.java @@ -8,4 +8,6 @@ public interface InstanceTelemetryMBean { int getMetricCount(); + int getDomainsQueried(); + } diff --git a/src/test/java/org/datadog/jmxfetch/StatusTest.java b/src/test/java/org/datadog/jmxfetch/StatusTest.java index 471aac120..fe6ae0456 100644 --- a/src/test/java/org/datadog/jmxfetch/StatusTest.java +++ b/src/test/java/org/datadog/jmxfetch/StatusTest.java @@ -33,10 +33,16 @@ public void TestStatus() throws IOException { int fakeBeansFetched = 11; int fakeMetricCount = 29; int fakeAttributeCount = 55; + int fakeDomainsQueried = 3; + int fakeWildcardQueryCount = 9; + double fakeBeansAttributeMatchRatio = .4; instance.setBeansFetched(fakeBeansFetched); instance.setMetricCount(fakeMetricCount); instance.setTopLevelAttributeCount(fakeAttributeCount); + instance.setDomainsQueried(fakeDomainsQueried); + instance.setWildcardQueryCount(fakeWildcardQueryCount); + instance.setAttributeMatchRatio(fakeBeansAttributeMatchRatio); status.addInstanceStats("fake_check", "fake_instance", 10, 3, "fake_message", Status.STATUS_OK, instance); status.flush(); @@ -55,6 +61,9 @@ public void TestStatus() throws IOException { assertEquals(fakeBeansFetched, stats.get("instance_bean_count")); assertEquals(fakeAttributeCount, stats.get("instance_attribute_count")); assertEquals(fakeMetricCount, stats.get("instance_metric_count")); + assertEquals(fakeDomainsQueried, stats.get("instance_domains_queried")); + assertEquals(fakeWildcardQueryCount, stats.get("instance_wildcard_query_count")); + assertEquals(fakeBeansAttributeMatchRatio, stats.get("instance_attribute_match_ratio")); assertEquals("fake_message", stats.get("message")); assertEquals(Status.STATUS_OK, stats.get("status")); } From bf4d08cebe78fcc38a680b3e696f4d84b41a236d Mon Sep 17 00:00:00 2001 From: raymond zhao Date: Wed, 1 Nov 2023 11:52:02 -0400 Subject: [PATCH 2/7] rename fields --- .../java/org/datadog/jmxfetch/Instance.java | 11 +++++---- .../java/org/datadog/jmxfetch/Status.java | 4 ++-- .../jmxfetch/util/InstanceTelemetry.java | 24 +++++++++---------- .../java/org/datadog/jmxfetch/StatusTest.java | 4 ++-- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/datadog/jmxfetch/Instance.java b/src/main/java/org/datadog/jmxfetch/Instance.java index 04654059a..39dcc81dd 100644 --- a/src/main/java/org/datadog/jmxfetch/Instance.java +++ b/src/main/java/org/datadog/jmxfetch/Instance.java @@ -519,8 +519,9 @@ public List getMetrics() throws IOException, MalformedObjectNameExceptio + " top attributes = " + instanceTelemetryBean.getTopLevelAttributeCount() + " metrics = " + instanceTelemetryBean.getMetricCount() + " domains queried = " + instanceTelemetryBean.getDomainsQueried() - + " wildcard query count = " + instanceTelemetryBean.getWildcardQueryCount() - + " attribute match ratio = " + instanceTelemetryBean.getAttributeMatchRatio()); + + " wildcard domain query count = " + + instanceTelemetryBean.getWildcardDomainQueryCount() + + " bean match ratio = " + instanceTelemetryBean.getBeanMatchRatio()); } return metrics; } @@ -720,7 +721,7 @@ private void getMatchingAttributes() throws IOException { } } if (instanceTelemetryBean != null) { - instanceTelemetryBean.setAttributeMatchRatio((double) + instanceTelemetryBean.setBeanMatchRatio((double) beansWithAttributeMatch / beans.size()); } log.info("Found {} matching attributes", matchingAttributes.size()); @@ -766,8 +767,8 @@ private void refreshBeansList() throws IOException, MalformedObjectNameException if (this.beans.isEmpty()) { this.beans = connection.queryNames(null); if (instanceTelemetryBean != null) { - int wildcardQueryCount = instanceTelemetryBean.getWildcardQueryCount(); - instanceTelemetryBean.setWildcardQueryCount(wildcardQueryCount + 1); + int wildcardQueryCount = instanceTelemetryBean.getWildcardDomainQueryCount(); + instanceTelemetryBean.setWildcardDomainQueryCount(wildcardQueryCount + 1); } } this.lastRefreshTime = System.currentTimeMillis(); diff --git a/src/main/java/org/datadog/jmxfetch/Status.java b/src/main/java/org/datadog/jmxfetch/Status.java index 637ada311..9cd9745ec 100644 --- a/src/main/java/org/datadog/jmxfetch/Status.java +++ b/src/main/java/org/datadog/jmxfetch/Status.java @@ -129,9 +129,9 @@ private void addStats( instStats.put("instance_metric_count", instanceTelemetryBean.getMetricCount()); instStats.put("instance_domains_queried", instanceTelemetryBean.getDomainsQueried()); instStats.put("instance_wildcard_query_count", - instanceTelemetryBean.getWildcardQueryCount()); + instanceTelemetryBean.getWildcardDomainQueryCount()); instStats.put("instance_attribute_match_ratio", - instanceTelemetryBean.getAttributeMatchRatio()); + instanceTelemetryBean.getBeanMatchRatio()); } instStats.put("message", message); instStats.put("status", status); diff --git a/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetry.java b/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetry.java index 7bc04b51e..c5031eb17 100644 --- a/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetry.java +++ b/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetry.java @@ -8,8 +8,8 @@ public class InstanceTelemetry implements InstanceTelemetryMBean { private int topLevelAttributeCount; private int metricCount; private int domainsQueried; - private int wildcardQueryCount; - private double attributeMatchRatio; + private int wildcardDomainQueryCount; + private double beanMatchRatio; /** Jmxfetch telemetry bean constructor. */ public InstanceTelemetry() { @@ -17,8 +17,8 @@ public InstanceTelemetry() { topLevelAttributeCount = 0; metricCount = 0; domainsQueried = 0; - wildcardQueryCount = 0; - attributeMatchRatio = 0.0; + wildcardDomainQueryCount = 0; + beanMatchRatio = 0.0; } public int getBeansFetched() { @@ -37,12 +37,12 @@ public int getDomainsQueried() { return domainsQueried; } - public int getWildcardQueryCount() { - return wildcardQueryCount; + public int getWildcardDomainQueryCount() { + return wildcardDomainQueryCount; } - public double getAttributeMatchRatio() { - return attributeMatchRatio; + public double getBeanMatchRatio() { + return beanMatchRatio; } public void setBeansFetched(int count) { @@ -61,12 +61,12 @@ public void setDomainsQueried(int count) { domainsQueried = count; } - public void setWildcardQueryCount(int count) { - wildcardQueryCount = count; + public void setWildcardDomainQueryCount(int count) { + wildcardDomainQueryCount = count; } - public void setAttributeMatchRatio(double ratio) { - attributeMatchRatio = ratio; + public void setBeanMatchRatio(double ratio) { + beanMatchRatio = ratio; } } diff --git a/src/test/java/org/datadog/jmxfetch/StatusTest.java b/src/test/java/org/datadog/jmxfetch/StatusTest.java index fe6ae0456..02f56179a 100644 --- a/src/test/java/org/datadog/jmxfetch/StatusTest.java +++ b/src/test/java/org/datadog/jmxfetch/StatusTest.java @@ -41,8 +41,8 @@ public void TestStatus() throws IOException { instance.setMetricCount(fakeMetricCount); instance.setTopLevelAttributeCount(fakeAttributeCount); instance.setDomainsQueried(fakeDomainsQueried); - instance.setWildcardQueryCount(fakeWildcardQueryCount); - instance.setAttributeMatchRatio(fakeBeansAttributeMatchRatio); + instance.setWildcardDomainQueryCount(fakeWildcardQueryCount); + instance.setBeanMatchRatio(fakeBeansAttributeMatchRatio); status.addInstanceStats("fake_check", "fake_instance", 10, 3, "fake_message", Status.STATUS_OK, instance); status.flush(); From 5c9c727ec353626116cb73713e7040924128aad6 Mon Sep 17 00:00:00 2001 From: raymond zhao Date: Wed, 1 Nov 2023 12:16:46 -0400 Subject: [PATCH 3/7] remove throw for MalformedObjectNameException --- src/main/java/org/datadog/jmxfetch/Instance.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/datadog/jmxfetch/Instance.java b/src/main/java/org/datadog/jmxfetch/Instance.java index 39dcc81dd..ea0cc2bca 100644 --- a/src/main/java/org/datadog/jmxfetch/Instance.java +++ b/src/main/java/org/datadog/jmxfetch/Instance.java @@ -434,8 +434,7 @@ public Connection getConnection( /** Initializes the instance. May force a new connection.. */ public void init(boolean forceNewConnection) - throws IOException, FailedLoginException, SecurityException, - MalformedObjectNameException { + throws IOException, FailedLoginException, SecurityException { log.info("Trying to connect to JMX Server at " + this.toString()); connection = getConnection(instanceMap, forceNewConnection); log.info( @@ -739,7 +738,7 @@ public List getBeansScopes() { * Query and refresh the instance's list of beans. Limit the query scope when possible on * certain actions, and fallback if necessary. */ - private void refreshBeansList() throws IOException, MalformedObjectNameException { + private void refreshBeansList() throws IOException { this.beans = new HashSet(); String action = appConfig.getAction(); boolean limitQueryScopes = From d449d7cc185265efaa509a4f320bcd88054d4938 Mon Sep 17 00:00:00 2001 From: raymond zhao Date: Wed, 1 Nov 2023 12:20:11 -0400 Subject: [PATCH 4/7] remove throw for MalformedObjectNameException pt2 --- src/main/java/org/datadog/jmxfetch/Instance.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/datadog/jmxfetch/Instance.java b/src/main/java/org/datadog/jmxfetch/Instance.java index ea0cc2bca..7c4fe0bd4 100644 --- a/src/main/java/org/datadog/jmxfetch/Instance.java +++ b/src/main/java/org/datadog/jmxfetch/Instance.java @@ -467,7 +467,7 @@ public String toString() { } /** Returns a map of metrics collected. */ - public List getMetrics() throws IOException, MalformedObjectNameException { + public List getMetrics() throws IOException { // In case of ephemeral beans, we can force to refresh the bean list x seconds // post initialization and every x seconds thereafter. From 63250e53e84e19d646c73bfc1d700dd5c94db7da Mon Sep 17 00:00:00 2001 From: raymond zhao Date: Thu, 2 Nov 2023 10:46:31 -0400 Subject: [PATCH 5/7] fix status --- src/main/java/org/datadog/jmxfetch/Status.java | 4 ++-- src/test/java/org/datadog/jmxfetch/StatusTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/datadog/jmxfetch/Status.java b/src/main/java/org/datadog/jmxfetch/Status.java index 9cd9745ec..84944ee02 100644 --- a/src/main/java/org/datadog/jmxfetch/Status.java +++ b/src/main/java/org/datadog/jmxfetch/Status.java @@ -128,9 +128,9 @@ private void addStats( instanceTelemetryBean.getTopLevelAttributeCount()); instStats.put("instance_metric_count", instanceTelemetryBean.getMetricCount()); instStats.put("instance_domains_queried", instanceTelemetryBean.getDomainsQueried()); - instStats.put("instance_wildcard_query_count", + instStats.put("instance_wildcard_domain_query_count", instanceTelemetryBean.getWildcardDomainQueryCount()); - instStats.put("instance_attribute_match_ratio", + instStats.put("instance_bean_match_ratio", instanceTelemetryBean.getBeanMatchRatio()); } instStats.put("message", message); diff --git a/src/test/java/org/datadog/jmxfetch/StatusTest.java b/src/test/java/org/datadog/jmxfetch/StatusTest.java index 02f56179a..f4273e35a 100644 --- a/src/test/java/org/datadog/jmxfetch/StatusTest.java +++ b/src/test/java/org/datadog/jmxfetch/StatusTest.java @@ -62,8 +62,8 @@ public void TestStatus() throws IOException { assertEquals(fakeAttributeCount, stats.get("instance_attribute_count")); assertEquals(fakeMetricCount, stats.get("instance_metric_count")); assertEquals(fakeDomainsQueried, stats.get("instance_domains_queried")); - assertEquals(fakeWildcardQueryCount, stats.get("instance_wildcard_query_count")); - assertEquals(fakeBeansAttributeMatchRatio, stats.get("instance_attribute_match_ratio")); + assertEquals(fakeWildcardQueryCount, stats.get("instance_wildcard_domain_query_count")); + assertEquals(fakeBeansAttributeMatchRatio, stats.get("instance_bean_match_ratio")); assertEquals("fake_message", stats.get("message")); assertEquals(Status.STATUS_OK, stats.get("status")); } From 363e888a919c4e378c3a0b9005ebf7c607a789b5 Mon Sep 17 00:00:00 2001 From: raymond zhao Date: Thu, 2 Nov 2023 10:48:52 -0400 Subject: [PATCH 6/7] fix status pt2 --- src/test/java/org/datadog/jmxfetch/StatusTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/datadog/jmxfetch/StatusTest.java b/src/test/java/org/datadog/jmxfetch/StatusTest.java index f4273e35a..7f2dae4e9 100644 --- a/src/test/java/org/datadog/jmxfetch/StatusTest.java +++ b/src/test/java/org/datadog/jmxfetch/StatusTest.java @@ -34,15 +34,15 @@ public void TestStatus() throws IOException { int fakeMetricCount = 29; int fakeAttributeCount = 55; int fakeDomainsQueried = 3; - int fakeWildcardQueryCount = 9; - double fakeBeansAttributeMatchRatio = .4; + int fakeWildcardDomainQueryCount = 9; + double fakeBeanMatchRatio = .4; instance.setBeansFetched(fakeBeansFetched); instance.setMetricCount(fakeMetricCount); instance.setTopLevelAttributeCount(fakeAttributeCount); instance.setDomainsQueried(fakeDomainsQueried); - instance.setWildcardDomainQueryCount(fakeWildcardQueryCount); - instance.setBeanMatchRatio(fakeBeansAttributeMatchRatio); + instance.setWildcardDomainQueryCount(fakeWildcardDomainQueryCount); + instance.setBeanMatchRatio(fakeBeanMatchRatio); status.addInstanceStats("fake_check", "fake_instance", 10, 3, "fake_message", Status.STATUS_OK, instance); status.flush(); @@ -62,8 +62,8 @@ public void TestStatus() throws IOException { assertEquals(fakeAttributeCount, stats.get("instance_attribute_count")); assertEquals(fakeMetricCount, stats.get("instance_metric_count")); assertEquals(fakeDomainsQueried, stats.get("instance_domains_queried")); - assertEquals(fakeWildcardQueryCount, stats.get("instance_wildcard_domain_query_count")); - assertEquals(fakeBeansAttributeMatchRatio, stats.get("instance_bean_match_ratio")); + assertEquals(fakeWildcardDomainQueryCount, stats.get("instance_wildcard_domain_query_count")); + assertEquals(fakeBeanMatchRatio, stats.get("instance_bean_match_ratio")); assertEquals("fake_message", stats.get("message")); assertEquals(Status.STATUS_OK, stats.get("status")); } From 734a3d0401d7bc753330f7e774fce96be55b453a Mon Sep 17 00:00:00 2001 From: raymond zhao Date: Mon, 6 Nov 2023 10:18:33 -0500 Subject: [PATCH 7/7] remove domains queried --- src/main/java/org/datadog/jmxfetch/Instance.java | 4 ---- src/main/java/org/datadog/jmxfetch/Status.java | 1 - .../org/datadog/jmxfetch/util/InstanceTelemetry.java | 10 ---------- .../datadog/jmxfetch/util/InstanceTelemetryMBean.java | 4 +++- src/test/java/org/datadog/jmxfetch/StatusTest.java | 3 --- 5 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/datadog/jmxfetch/Instance.java b/src/main/java/org/datadog/jmxfetch/Instance.java index 7c4fe0bd4..1cc3b91f9 100644 --- a/src/main/java/org/datadog/jmxfetch/Instance.java +++ b/src/main/java/org/datadog/jmxfetch/Instance.java @@ -517,7 +517,6 @@ public List getMetrics() throws IOException { + " With beans fetched = " + instanceTelemetryBean.getBeansFetched() + " top attributes = " + instanceTelemetryBean.getTopLevelAttributeCount() + " metrics = " + instanceTelemetryBean.getMetricCount() - + " domains queried = " + instanceTelemetryBean.getDomainsQueried() + " wildcard domain query count = " + instanceTelemetryBean.getWildcardDomainQueryCount() + " bean match ratio = " + instanceTelemetryBean.getBeanMatchRatio()); @@ -752,9 +751,6 @@ private void refreshBeansList() throws IOException { ObjectName name = new ObjectName(scope); this.beans.addAll(connection.queryNames(name)); } - if (instanceTelemetryBean != null) { - instanceTelemetryBean.setDomainsQueried(beanScopes.size()); - } } catch (MalformedObjectNameException e) { log.error("Unable to create ObjectName", e); } catch (IOException e) { diff --git a/src/main/java/org/datadog/jmxfetch/Status.java b/src/main/java/org/datadog/jmxfetch/Status.java index 84944ee02..6a96a9031 100644 --- a/src/main/java/org/datadog/jmxfetch/Status.java +++ b/src/main/java/org/datadog/jmxfetch/Status.java @@ -127,7 +127,6 @@ private void addStats( instStats.put("instance_attribute_count", instanceTelemetryBean.getTopLevelAttributeCount()); instStats.put("instance_metric_count", instanceTelemetryBean.getMetricCount()); - instStats.put("instance_domains_queried", instanceTelemetryBean.getDomainsQueried()); instStats.put("instance_wildcard_domain_query_count", instanceTelemetryBean.getWildcardDomainQueryCount()); instStats.put("instance_bean_match_ratio", diff --git a/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetry.java b/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetry.java index c5031eb17..3cbb938fd 100644 --- a/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetry.java +++ b/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetry.java @@ -7,7 +7,6 @@ public class InstanceTelemetry implements InstanceTelemetryMBean { private int beansFetched; private int topLevelAttributeCount; private int metricCount; - private int domainsQueried; private int wildcardDomainQueryCount; private double beanMatchRatio; @@ -16,7 +15,6 @@ public InstanceTelemetry() { beansFetched = 0; topLevelAttributeCount = 0; metricCount = 0; - domainsQueried = 0; wildcardDomainQueryCount = 0; beanMatchRatio = 0.0; } @@ -33,10 +31,6 @@ public int getMetricCount() { return metricCount; } - public int getDomainsQueried() { - return domainsQueried; - } - public int getWildcardDomainQueryCount() { return wildcardDomainQueryCount; } @@ -57,10 +51,6 @@ public void setMetricCount(int count) { metricCount = count; } - public void setDomainsQueried(int count) { - domainsQueried = count; - } - public void setWildcardDomainQueryCount(int count) { wildcardDomainQueryCount = count; } diff --git a/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetryMBean.java b/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetryMBean.java index 3f5b028c4..4c98b5200 100644 --- a/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetryMBean.java +++ b/src/main/java/org/datadog/jmxfetch/util/InstanceTelemetryMBean.java @@ -8,6 +8,8 @@ public interface InstanceTelemetryMBean { int getMetricCount(); - int getDomainsQueried(); + int getWildcardDomainQueryCount(); + + double getBeanMatchRatio(); } diff --git a/src/test/java/org/datadog/jmxfetch/StatusTest.java b/src/test/java/org/datadog/jmxfetch/StatusTest.java index 7f2dae4e9..f8a8b06ec 100644 --- a/src/test/java/org/datadog/jmxfetch/StatusTest.java +++ b/src/test/java/org/datadog/jmxfetch/StatusTest.java @@ -33,14 +33,12 @@ public void TestStatus() throws IOException { int fakeBeansFetched = 11; int fakeMetricCount = 29; int fakeAttributeCount = 55; - int fakeDomainsQueried = 3; int fakeWildcardDomainQueryCount = 9; double fakeBeanMatchRatio = .4; instance.setBeansFetched(fakeBeansFetched); instance.setMetricCount(fakeMetricCount); instance.setTopLevelAttributeCount(fakeAttributeCount); - instance.setDomainsQueried(fakeDomainsQueried); instance.setWildcardDomainQueryCount(fakeWildcardDomainQueryCount); instance.setBeanMatchRatio(fakeBeanMatchRatio); @@ -61,7 +59,6 @@ public void TestStatus() throws IOException { assertEquals(fakeBeansFetched, stats.get("instance_bean_count")); assertEquals(fakeAttributeCount, stats.get("instance_attribute_count")); assertEquals(fakeMetricCount, stats.get("instance_metric_count")); - assertEquals(fakeDomainsQueried, stats.get("instance_domains_queried")); assertEquals(fakeWildcardDomainQueryCount, stats.get("instance_wildcard_domain_query_count")); assertEquals(fakeBeanMatchRatio, stats.get("instance_bean_match_ratio")); assertEquals("fake_message", stats.get("message"));