-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Replace Map metric to a Metric class During collection process, metrics are collected as Map<String, Object>, but keys are known and fixed so we can replace this map to a POJO which will be lighter in term of memory footprint and allocation. * cache Metric instances Use Metric class as a cache and avoid recreating it for each collection. Only the value is updated. For simple & complex attribute Tags are also cached into the Metric instance. For complex & tabular attribute, cache is done per sub attribute into a new JMXSubAttribute abstract class Transfer checkName into the attribute to be inserted into the Metric instance at creation * fix bad metric instantiantion Co-authored-by: Jaime Fullaondo <truthbk@gmail.com>
- Loading branch information
Showing
8 changed files
with
103 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.datadog.jmxfetch; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import javax.management.MBeanAttributeInfo; | ||
import javax.management.ObjectName; | ||
|
||
abstract class JmxSubAttribute extends JmxAttribute { | ||
private Map<String, Metric> cachedMetrics = new HashMap<String, Metric>(); | ||
|
||
public JmxSubAttribute(MBeanAttributeInfo attribute, ObjectName beanName, String instanceName, | ||
String checkName, Connection connection, Map<String, String> instanceTags, | ||
boolean cassandraAliasing, boolean emptyDefaultHostname) { | ||
super(attribute, beanName, instanceName, checkName, connection, instanceTags, | ||
cassandraAliasing, emptyDefaultHostname); | ||
} | ||
|
||
public Metric getCachedMetric(String name) { | ||
Metric metric = cachedMetrics.get(name); | ||
if (metric != null) { | ||
return metric; | ||
} | ||
String alias = getAlias(name); | ||
String metricType = getMetricType(name); | ||
String[] tags = getTags(); | ||
metric = new Metric(alias, metricType, tags, checkName); | ||
cachedMetrics.put(name, metric); | ||
return metric; | ||
} | ||
} |
Oops, something went wrong.