private void addTabularMetrics(MetricFilter filter, List<Metric> metrics, TagList tags, String attrName, CompositeData obj) { Map<String, Object> values = new HashMap<>(); // tabular composite data has a value called key and one called value values.put(obj.get("key").toString(), obj.get("value")); for (Map.Entry<String, Object> e : values.entrySet()) { final Tag compositeTag = Tags.newTag(COMPOSITE_PATH_KEY, e.getKey()); final TagList newTags = getTagListWithAdditionalTag(tags, compositeTag); if (filter.matches(MonitorConfig.builder(attrName).withTags(newTags).build())) { addMetric(metrics, attrName, newTags, e.getValue()); } } }
private void addCompositeMetrics(MetricFilter filter, List<Metric> metrics, TagList tags, String attrName, CompositeData obj) { Map<String, Object> values = new HashMap<>(); extractValues(null, values, obj); for (Map.Entry<String, Object> e : values.entrySet()) { final Tag compositeTag = Tags.newTag(COMPOSITE_PATH_KEY, e.getKey()); final TagList newTags = getTagListWithAdditionalTag(tags, compositeTag); if (filter.matches(MonitorConfig.builder(attrName).withTags(newTags).build())) { addMetric(metrics, attrName, newTags, e.getValue()); } } }
/** * Create a new metric object and add it to the list. */ private void addMetric( List<Metric> metrics, String name, TagList tags, Object value) { long now = System.currentTimeMillis(); if (onlyNumericMetrics) { value = asNumber(value); } if (value != null) { TagList newTags = counters.matches(MonitorConfig.builder(name).withTags(tags).build()) ? getTagListWithAdditionalTag(tags, DataSourceType.COUNTER) : getTagListWithAdditionalTag(tags, DataSourceType.GAUGE); Metric m = new Metric(name, newTags, now, value); metrics.add(m); } }
private void addTabularMetrics(MetricFilter filter, List<Metric> metrics, TagList tags, String attrName, CompositeData obj) { Map<String, Object> values = new HashMap<>(); // tabular composite data has a value called key and one called value values.put(obj.get("key").toString(), obj.get("value")); for (Map.Entry<String, Object> e : values.entrySet()) { final Tag compositeTag = Tags.newTag(COMPOSITE_PATH_KEY, e.getKey()); final TagList newTags = getTagListWithAdditionalTag(tags, compositeTag); if (filter.matches(MonitorConfig.builder(attrName).withTags(newTags).build())) { addMetric(metrics, attrName, newTags, e.getValue()); } } }
/** * Create a new metric object and add it to the list. */ private void addMetric( List<Metric> metrics, String name, TagList tags, Object value) { long now = System.currentTimeMillis(); if (onlyNumericMetrics) { value = asNumber(value); } if (value != null) { TagList newTags = counters.matches(MonitorConfig.builder(name).withTags(tags).build()) ? getTagListWithAdditionalTag(tags, DataSourceType.COUNTER) : getTagListWithAdditionalTag(tags, DataSourceType.GAUGE); Metric m = new Metric(name, newTags, now, value); metrics.add(m); } }
private void addCompositeMetrics(MetricFilter filter, List<Metric> metrics, TagList tags, String attrName, CompositeData obj) { Map<String, Object> values = new HashMap<>(); extractValues(null, values, obj); for (Map.Entry<String, Object> e : values.entrySet()) { final Tag compositeTag = Tags.newTag(COMPOSITE_PATH_KEY, e.getKey()); final TagList newTags = getTagListWithAdditionalTag(tags, compositeTag); if (filter.matches(MonitorConfig.builder(attrName).withTags(newTags).build())) { addMetric(metrics, attrName, newTags, e.getValue()); } } }