/** * Get the parent {@link MetricContext} of this {@link MetricContext} wrapped in an * {@link com.google.common.base.Optional}, which may be absent if it has not parent * {@link MetricContext}. * * @return the parent {@link MetricContext} of this {@link MetricContext} wrapped in an * {@link com.google.common.base.Optional} */ public Optional<MetricContext> getParent() { return this.innerMetricContext.getParent(); }
/** * Called when any {@link MetricContext} is removed from the tree. * * @param context {@link InnerMetricContext} backing the removed {@link MetricContext}. */ protected void removedMetricContext(InnerMetricContext context) { this.contextsToReport.remove(context); if (context.getParent().isPresent() && this.contextFilter.shouldReplaceByParent(context)) { this.contextsToReport.add(context.getParent().get().getInnerMetricContext()); } }
@Override public String toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("InnerMetricContext Name: "); stringBuilder.append(this.name); if (this.getParent().isPresent()) { stringBuilder.append(", Parent Name: "); stringBuilder.append(this.getParent().get().getName()); } else { stringBuilder.append(", No Parent Context"); } stringBuilder.append(", Number of Children: "); stringBuilder.append(this.getChildContextsAsMap().size()); stringBuilder.append(", Tags: "); stringBuilder.append(Joiner.on(", ").withKeyValueSeparator(" : ").useForNull("NULL").join(this.getTagMap())); return stringBuilder.toString(); } }
/** * Get the parent {@link MetricContext} of this {@link MetricContext} wrapped in an * {@link com.google.common.base.Optional}, which may be absent if it has not parent * {@link MetricContext}. * * @return the parent {@link MetricContext} of this {@link MetricContext} wrapped in an * {@link com.google.common.base.Optional} */ public Optional<MetricContext> getParent() { return this.innerMetricContext.getParent(); }
/** * Called when any {@link MetricContext} is removed from the tree. * * @param context {@link InnerMetricContext} backing the removed {@link MetricContext}. */ protected void removedMetricContext(InnerMetricContext context) { this.contextsToReport.remove(context); if (context.getParent().isPresent() && this.contextFilter.shouldReplaceByParent(context)) { this.contextsToReport.add(context.getParent().get().getInnerMetricContext()); } }
@Override public String toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("InnerMetricContext Name: "); stringBuilder.append(this.name); if (this.getParent().isPresent()) { stringBuilder.append(", Parent Name: "); stringBuilder.append(this.getParent().get().getName()); } else { stringBuilder.append(", No Parent Context"); } stringBuilder.append(", Number of Children: "); stringBuilder.append(this.getChildContextsAsMap().size()); stringBuilder.append(", Tags: "); stringBuilder.append(Joiner.on(", ").withKeyValueSeparator(" : ").useForNull("NULL").join(this.getTagMap())); return stringBuilder.toString(); } }