@Test public void internal_metrics_take_precedence_over_metrics_from_children() { String METRIC_NAME = "metric1"; String COMMON_DIMENSION_KEY = "commonKey"; Map<String, String> childDimensions = ImmutableMap.<String, String>builder() .put(COMMON_DIMENSION_KEY, "childCommonVal") .put("childKey", "childVal") .build(); Metric childMetric = new Metric(METRIC_NAME, "child-output-name", "child-description", childDimensions); Map<String, String> parentDimensions = ImmutableMap.<String, String>builder() .put(COMMON_DIMENSION_KEY, "parentCommonVal") .put("parentKey", "parentVal") .build(); Metric parentMetric = new Metric(METRIC_NAME, "parent-output-name", "parent-description", parentDimensions); MetricSet child = new MetricSet("set1", Sets.newHashSet(childMetric)); MetricSet parent = new MetricSet("set1", Sets.newHashSet(parentMetric), Sets.newHashSet(child)); Metric combinedMetric = parent.getMetrics().get(METRIC_NAME); assertEquals("parent-output-name", combinedMetric.outputName); assertEquals("parent-description", combinedMetric.description); assertEquals(3, combinedMetric.dimensions.size()); assertEquals("parentCommonVal", combinedMetric.dimensions.get(COMMON_DIMENSION_KEY)); }
public final Map<String, Metric> getMetrics() { return unmodifiableMap(flatten(metrics, children)); }
MetricSet { public final Map<String, Metric> getMetrics() { return unmodifiableMap(flatten(metrics, children)); } }
MetricSet { public final Map<String, Metric> getMetrics() { return unmodifiableMap(flatten(metrics, children)); } MetricSet(String id, Collection<Metric> metrics);  MetricSet(String id, Collection<Metric> metrics, Collection<MetricSet> children); }
MetricSet { public final Map<String, Metric> getMetrics() { return unmodifiableMap(flatten(metrics, children)); } MetricSet(String id, Collection<Metric> metrics);  MetricSet(String id, Collection<Metric> metrics, Collection<MetricSet> children); static MetricSet empty(); final String getId(); final Map<String, Metric> getMetrics(); @Override boolean equals(Object o); @Override int hashCode(); }
MetricSet { public final Map<String, Metric> getMetrics() { return unmodifiableMap(flatten(metrics, children)); } MetricSet(String id, Collection<Metric> metrics);  MetricSet(String id, Collection<Metric> metrics, Collection<MetricSet> children); static MetricSet empty(); final String getId(); final Map<String, Metric> getMetrics(); @Override boolean equals(Object o); @Override int hashCode();  }