|
9 | 9 | import com.newrelic.telemetry.util.Utils; |
10 | 10 | import java.util.ArrayList; |
11 | 11 | import java.util.Collection; |
12 | | -import java.util.Map; |
13 | 12 | import java.util.Queue; |
14 | 13 | import java.util.concurrent.ConcurrentLinkedQueue; |
15 | 14 | import org.slf4j.LoggerFactory; |
@@ -40,36 +39,28 @@ public MetricBuffer(Attributes commonAttributes) { |
40 | 39 | } |
41 | 40 |
|
42 | 41 | /** |
43 | | - * Append a {@link Count} to this buffer, to be sent in the next {@link MetricBatch}. |
| 42 | + * Append a {@link Metric} to this buffer, to be sent in the next {@link MetricBatch}. |
44 | 43 | * |
45 | | - * @param countMetric The new {@link Count} instance to be sent. |
| 44 | + * @param metric The new {@link Metric} instance to be sent. |
46 | 45 | */ |
47 | | - public void addMetric(Count countMetric) { |
48 | | - Map<String, Object> attributes = countMetric.getAttributes(); |
49 | | - ingestWarnings.raiseIngestWarnings(attributes, countMetric); |
50 | | - metrics.add(countMetric); |
| 46 | + public void addMetric(Metric metric) { |
| 47 | + raiseIngestWarnings(metric); |
| 48 | + metrics.add(metric); |
51 | 49 | } |
52 | 50 |
|
53 | 51 | /** |
54 | | - * Append a {@link Gauge} to this buffer, to be sent in the next {@link MetricBatch}. |
| 52 | + * Add IngestWarnings for concrete Metric implementations. |
55 | 53 | * |
56 | | - * @param gaugeMetric The new {@link Gauge} instance to be sent. |
| 54 | + * @param metric Metric instance to validate |
57 | 55 | */ |
58 | | - public void addMetric(Gauge gaugeMetric) { |
59 | | - Map<String, Object> attributes = gaugeMetric.getAttributes(); |
60 | | - ingestWarnings.raiseIngestWarnings(attributes, gaugeMetric); |
61 | | - metrics.add(gaugeMetric); |
62 | | - } |
63 | | - |
64 | | - /** |
65 | | - * Append a {@link Summary} to this buffer, to be sent in the next {@link MetricBatch}. |
66 | | - * |
67 | | - * @param summaryMetric The new {@link Summary} instance to be sent. |
68 | | - */ |
69 | | - public void addMetric(Summary summaryMetric) { |
70 | | - Map<String, Object> attributes = summaryMetric.getAttributes(); |
71 | | - ingestWarnings.raiseIngestWarnings(attributes, summaryMetric); |
72 | | - metrics.add(summaryMetric); |
| 56 | + private void raiseIngestWarnings(Metric metric) { |
| 57 | + if (metric instanceof Count) { |
| 58 | + ingestWarnings.raiseIngestWarnings(((Count) metric).getAttributes(), metric); |
| 59 | + } else if (metric instanceof Gauge) { |
| 60 | + ingestWarnings.raiseIngestWarnings(((Gauge) metric).getAttributes(), metric); |
| 61 | + } else if (metric instanceof Summary) { |
| 62 | + ingestWarnings.raiseIngestWarnings(((Summary) metric).getAttributes(), metric); |
| 63 | + } |
73 | 64 | } |
74 | 65 |
|
75 | 66 | /** |
|
0 commit comments