@Override protected MetricsTag newValue(MetricsInfo info, String value) { return new MetricsTag(info, value); } };
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 } }
@InterfaceAudience.Private public void appendPrefix(MetricsRecord record, StringBuilder sb) { String contextName = record.context(); Collection<MetricsTag> tags = record.tags(); if (useTagsMap.containsKey(contextName)) { Set<String> useTags = useTagsMap.get(contextName); for (MetricsTag t : tags) { if (useTags == null || useTags.contains(t.name())) { // the context is always skipped here because it is always added // the hostname is always skipped to avoid case-mismatches // from different DNSes. if (t.info() != MsInfo.Context && t.info() != MsInfo.Hostname && t.value() != null) { sb.append('.').append(t.name()).append('=').append(t.value()); } } } } }
@Override public String toString() { return new StringJoiner(", ", this.getClass().getSimpleName() + "{", "}") .add("info=" + info) .add("value=" + value()) .toString(); } }
private void addDynamicEntry(List<String> keys, List<Object> values, List<String> variableValues, String family, MetricsTag tag, MetricInfo metric, int count) { // <family><.dynColumn><count> <VARCHAR> keys.add(getDynamicColumnName(family, metric.columnName, count) + " VARCHAR"); // build the annotation value String val = tag.description() + " - " + tag.value(); values.add(VARIABLE_VALUE); variableValues.add(val); }
@Override public boolean apply(MetricsTag input) { return input.name().equals(tagName); } }
@InterfaceAudience.Private public void appendPrefix(MetricsRecord record, StringBuilder sb) { String contextName = record.context(); Collection<MetricsTag> tags = record.tags(); if (useTagsMap.containsKey(contextName)) { Set<String> useTags = useTagsMap.get(contextName); for (MetricsTag t : tags) { if (useTags == null || useTags.contains(t.name())) { // the context is always skipped here because it is always added // the hostname is always skipped to avoid case-mismatches // from different DNSes. if (t.info() != MsInfo.Context && t.info() != MsInfo.Hostname && t.value() != null) { sb.append('.').append(t.name()).append('=').append(t.value()); } } } } }
/** * Gets the balancer status tag from the Metrics registry */ public String getStatus() throws Exception { MetricsSource source = DefaultMetricsSystem.instance().getSource(MetricsBalancerSource.METRICS_JMX_CONTEXT); if (source instanceof MetricsBalancerSourceImpl) { MetricsTag status = ((MetricsBalancerSourceImpl) source).getMetricsRegistry() .getTag(MetricsBalancerSource.BALANCER_STATUS); return status.value(); } else { LOG.warn("Balancer JMX Metrics not registered"); throw new Exception("MetricsBalancer JMX Context not found"); } }
private void addDynamicEntry(List<String> keys, List<Object> values, List<String> variableValues, String family, MetricsTag tag, MetricInfo metric, int count) { // <family><.dynColumn><count> <VARCHAR> keys.add(getDynamicColumnName(family, metric.columnName, count) + " VARCHAR"); // build the annotation value String val = tag.description() + " - " + tag.value(); values.add(VARIABLE_VALUE); variableValues.add(val); }
@Override public boolean apply(MetricsTag input) { return input.name().equals(tagName); } }
@InterfaceAudience.Private public void appendPrefix(MetricsRecord record, StringBuilder sb) { String contextName = record.context(); Collection<MetricsTag> tags = record.tags(); if (useTagsMap.containsKey(contextName)) { Set<String> useTags = useTagsMap.get(contextName); for (MetricsTag t : tags) { if (useTags == null || useTags.contains(t.name())) { // the context is always skipped here because it is always added // the hostname is always skipped to avoid case-mismatches // from different DNSes. if (t.info() != MsInfo.Context && t.info() != MsInfo.Hostname && t.value() != null) { sb.append('.').append(t.name()).append('=').append(t.value()); } } } } }
if (tag.info().name().equals(MsInfo.Hostname.name()) && tag.value() != null) { hn = tag.value(); } else if (tag.info().name().equals(MsInfo.Context.name()) && tag.value() != null) { ctx = tag.value(); } else if (tag.info().name().equals(MsInfo.ProcessName.name()) && tag.value() != null) { sn = tag.value();
/** * Get a metrics tag * * @param info of the tag * @param value of the tag * @return an interned metrics tag */ public static MetricsTag tag(MetricsInfo info, String value) { Map<String, MetricsTag> map = tagCache.getUnchecked(info); MetricsTag tag = map.get(value); if (tag == null) { tag = new MetricsTag(info, value); map.put(value, tag); } return tag; }
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 } }
private void addDynamicEntry(List<String> keys, List<Object> values, List<String> variableValues, String family, MetricsTag tag, MetricInfo metric, int count) { // <family><.dynColumn><count> <VARCHAR> keys.add(getDynamicColumnName(family, metric.columnName, count) + " VARCHAR"); // build the annotation value String val = tag.description() + " - " + tag.value(); values.add(VARIABLE_VALUE); variableValues.add(val); }