@Test public void builder_can_retain_subset_of_metrics() { MetricsPacket packet = new MetricsPacket.Builder(toServiceId("foo")) .putMetrics(ImmutableList.of( new Metric("remove", 1), new Metric("keep", 2))) .retainMetrics(ImmutableSet.of(toMetricId("keep"), toMetricId("non-existent"))) .build(); assertFalse("should not contain 'remove'", packet.metrics().containsKey(toMetricId("remove"))); assertTrue("should contain 'keep'", packet.metrics().containsKey(toMetricId("keep"))); assertFalse("should not contain 'non-existent'", packet.metrics().containsKey(toMetricId("non-existent"))); }
public Map<MetricId, Number> metrics() { return unmodifiableMap(metrics); }
MetricsPacket { public Map<MetricId, Number> metrics() { return unmodifiableMap(metrics); } }
MetricsPacket { public Map<MetricId, Number> metrics() { return unmodifiableMap(metrics); } private  MetricsPacket(int statusCode, String statusMessage, long timestamp, ServiceId service,
                          Map<MetricId, Number> metrics, Map<DimensionId, String> dimensions, Set<ConsumerId> consumers ); }
MetricsPacket { public Map<MetricId, Number> metrics() { return unmodifiableMap(metrics); } private  MetricsPacket(int statusCode, String statusMessage, long timestamp, ServiceId service,
                          Map<MetricId, Number> metrics, Map<DimensionId, String> dimensions, Set<ConsumerId> consumers ); Map<MetricId, Number> metrics(); Map<DimensionId, String> dimensions(); List<ConsumerId> consumers(); @Override String toString(); }
MetricsPacket { public Map<MetricId, Number> metrics() { return unmodifiableMap(metrics); } private  MetricsPacket(int statusCode, String statusMessage, long timestamp, ServiceId service,
                          Map<MetricId, Number> metrics, Map<DimensionId, String> dimensions, Set<ConsumerId> consumers ); Map<MetricId, Number> metrics(); Map<DimensionId, String> dimensions(); List<ConsumerId> consumers(); @Override String toString(); final int statusCode; final String statusMessage; final long timestamp; final ServiceId service; }