@Override public Collection<MetricsTag> tags() { return delegate.tags(); }
@Override public void putMetrics(MetricsRecord record) { writer.print(record.timestamp()); writer.print(" "); writer.print(record.context()); writer.print("."); writer.print(record.name()); String separator = ": "; for (MetricsTag tag : record.tags()) { writer.print(separator); separator = ", "; writer.print(tag.name()); writer.print("="); writer.print(tag.value()); } for (AbstractMetric metric : record.metrics()) { writer.print(separator); separator = ", "; writer.print(metric.name()); writer.print("="); writer.print(metric.value()); } writer.println(); }
/** * Whether to accept the record * @param record to filter on * @return true to accept; false otherwise. */ public boolean accepts(MetricsRecord record) { return accepts(record.name()) && accepts(record.tags()); }
@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()); } } } } }
.append(record.context()).append(".").append(record.name()); for (MetricsTag tag : record.tags()) { if (tag.value() != null) { metricsPathPrefix.append(".");
@Override public boolean equals(Object obj) { if (obj instanceof MetricsRecord) { final MetricsRecord other = (MetricsRecord) obj; return Objects.equal(timestamp(), other.timestamp()) && Objects.equal(name(), other.name()) && Objects.equal(description(), other.description()) && Objects.equal(tags(), other.tags()) && Iterables.elementsEqual(metrics(), other.metrics()); } return false; }
/** * 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; }
String sn = serviceName; for (MetricsTag tag : record.tags()) { if (tag.info().name().equals(MsInfo.Hostname.name()) && tag.value() != null) {
for (MetricsTag tag : record.tags()) { currentOutStream.printf("%s%s=%s", separator, tag.name(), tag.value());
/** * Whether to accept the record * @param record to filter on * @return true to accept; false otherwise. */ public boolean accepts(MetricsRecord record) { return accepts(record.name()) && accepts(record.tags()); }
/** * Whether to accept the record * @param record to filter on * @return true to accept; false otherwise. */ public boolean accepts(MetricsRecord record) { return accepts(record.name()) && accepts(record.tags()); }
/** * Whether to accept the record * @param record to filter on * @return true to accept; false otherwise. */ public boolean accepts(MetricsRecord record) { return accepts(record.name()) && accepts(record.tags()); }
private static MetricsTag getFirstTagByName(MetricsRecord record, String name) { return Iterables.getFirst(Iterables.filter(record.tags(), new MetricsTagPredicate(name)), null); }
private static MetricsTag getFirstTagByName(MetricsRecord record, String name) { return Iterables.getFirst(Iterables.filter(record.tags(), new MetricsTagPredicate(name)), null); }
private MetricsRecord makeRecord(String name, Collection<MetricsTag> tags, Collection<AbstractMetric> metrics) { MetricsRecord mr = mock(MetricsRecord.class); when(mr.name()).thenReturn(name); when(mr.tags()).thenReturn(tags); when(mr.metrics()).thenReturn(metrics); return mr; }
private MetricsRecord makeRecord(String name, Collection<MetricsTag> tags, Collection<AbstractMetric> metrics) { MetricsRecord mr = mock(MetricsRecord.class); when(mr.name()).thenReturn(name); when(mr.tags()).thenReturn(tags); when(mr.metrics()).thenReturn(metrics); return mr; }
@Override public boolean equals(Object obj) { if (obj instanceof MetricsRecord) { final MetricsRecord other = (MetricsRecord) obj; return Objects.equal(timestamp(), other.timestamp()) && Objects.equal(name(), other.name()) && Objects.equal(description(), other.description()) && Objects.equal(tags(), other.tags()) && Iterables.elementsEqual(metrics(), other.metrics()); } return false; }
@Override public boolean equals(Object obj) { if (obj instanceof MetricsRecord) { final MetricsRecord other = (MetricsRecord) obj; return Objects.equal(timestamp(), other.timestamp()) && Objects.equal(name(), other.name()) && Objects.equal(description(), other.description()) && Objects.equal(tags(), other.tags()) && Iterables.elementsEqual(metrics(), other.metrics()); } return false; }
@Override public boolean equals(Object obj) { if (obj instanceof MetricsRecord) { final MetricsRecord other = (MetricsRecord) obj; return Objects.equal(timestamp(), other.timestamp()) && Objects.equal(name(), other.name()) && Objects.equal(description(), other.description()) && Objects.equal(tags(), other.tags()) && Iterables.elementsEqual(metrics(), other.metrics()); } return false; }