.metricsEntrySet()) { AbstractMetric metric = entry.getValue(); sb.append(metric.name()); String name = sb.toString(); metric.visit(gangliaMetricVisitor); type = gangliaMetricVisitor.getType(); slopeFromMetric = gangliaMetricVisitor.getSlope(); emitMetric(groupName, name, type, metric.value().toString(), gConf, calculatedSlope); sb.append(metric.name()); String name = sb.toString(); metric.visit(gangliaMetricVisitor); type = gangliaMetricVisitor.getType(); slopeFromMetric = gangliaMetricVisitor.getSlope(); emitMetric(groupName, name, type, metric.value().toString(), gConf, calculatedSlope);
/** * Lookup a metric value * @param key name of the metric * @return the metric value */ public Number getMetric(String key) { AbstractMetric metric = metrics.get(key); return metric != null ? metric.value() : null; }
/** * Update the cache and return the current cached record * @param mr the update record * @param includingTags cache tag values (for later lookup by name) if true * @return the updated cache record */ public Record update(MetricsRecord mr, boolean includingTags) { String name = mr.name(); RecordCache recordCache = map.get(name); if (recordCache == null) { recordCache = new RecordCache(); map.put(name, recordCache); } Collection<MetricsTag> tags = mr.tags(); Record record = recordCache.get(tags); if (record == null) { record = new Record(); recordCache.put(tags, record); } for (AbstractMetric m : mr.metrics()) { record.metrics.put(m.name(), m); } if (includingTags) { // mostly for some sinks that include tags as part of a dense schema for (MetricsTag t : mr.tags()) { record.tags.put(t.name(), t.value()); } } return record; }
MBeanInfo get() { curRecNo = 0; for (MetricsRecordImpl rec : recs) { for (MetricsTag t : rec.tags()) { attrs.add(newAttrInfo("tag."+ t.name(), t.description(), "java.lang.String")); } for (AbstractMetric m : rec.metrics()) { m.visit(this); } ++curRecNo; } MetricsSystemImpl.LOG.debug(attrs.toString()); MBeanAttributeInfo[] attrsArray = new MBeanAttributeInfo[attrs.size()]; return new MBeanInfo(name, description, attrs.toArray(attrsArray), null, null, null); // no ops/ctors/notifications } }
@Override public int hashCode() { return Objects.hashCode(info, value()); }
@Override public void putMetrics(MetricsRecord record) { // we could wait until flush, but this is a really lightweight process, so we just write // them // as soon as we get them if (!LOG.isDebugEnabled()) { return; } LOG.debug("Found record:" + record.name()); for (AbstractMetric metric : record.metrics()) { // just print the metric we care about if (metric.name().startsWith(TracingUtils.METRIC_SOURCE_KEY)) { LOG.debug("\t metric:" + metric); } } }
MBeanInfo get() { curRecNo = 0; for (MetricsRecordImpl rec : recs) { for (MetricsTag t : rec.tags()) { attrs.add(newAttrInfo("tag."+ t.name(), t.description(), "java.lang.String")); } for (AbstractMetric m : rec.metrics()) { m.visit(this); } ++curRecNo; } MetricsSystemImpl.LOG.debug(attrs); MBeanAttributeInfo[] attrsArray = new MBeanAttributeInfo[attrs.size()]; return new MBeanInfo(name, description, attrs.toArray(attrsArray), null, null, null); // no ops/ctors/notifications } }
.metricsEntrySet()) { AbstractMetric metric = entry.getValue(); sb.append(metric.name()); String name = sb.toString(); metric.visit(gangliaMetricVisitor); type = gangliaMetricVisitor.getType(); slopeFromMetric = gangliaMetricVisitor.getSlope(); emitMetric(groupName, name, type, metric.value().toString(), gConf, calculatedSlope); sb.append(metric.name()); String name = sb.toString(); metric.visit(gangliaMetricVisitor); type = gangliaMetricVisitor.getType(); slopeFromMetric = gangliaMetricVisitor.getSlope(); emitMetric(groupName, name, type, metric.value().toString(), gConf, calculatedSlope);
@Override public String toString() { return new StringJoiner(", ", this.getClass().getSimpleName() + "{", "}") .add("info=" + info) .add("value=" + value()) .toString(); } }
@Override public boolean apply(AbstractMetric input) { return input.name().equals(metricName); } }
MBeanInfo get() { curRecNo = 0; for (MetricsRecordImpl rec : recs) { for (MetricsTag t : rec.tags()) { attrs.add(newAttrInfo("tag."+ t.name(), t.description(), "java.lang.String")); } for (AbstractMetric m : rec.metrics()) { m.visit(this); } ++curRecNo; } MetricsSystemImpl.LOG.debug(attrs); MBeanAttributeInfo[] attrsArray = new MBeanAttributeInfo[attrs.size()]; return new MBeanInfo(name, description, attrs.toArray(attrsArray), null, null, null); // no ops/ctors/notifications } }