|
42 | 42 | import com.google.monitoring.v3.TimeSeries; |
43 | 43 | import com.google.protobuf.Empty; |
44 | 44 | import io.opentelemetry.api.common.Attributes; |
| 45 | +import io.opentelemetry.sdk.common.CompletableResultCode; |
45 | 46 | import io.opentelemetry.sdk.common.InstrumentationScopeInfo; |
46 | 47 | import io.opentelemetry.sdk.metrics.data.AggregationTemporality; |
47 | 48 | import io.opentelemetry.sdk.metrics.data.LongPointData; |
@@ -190,6 +191,35 @@ public void testClientCacheReferenceCounting() { |
190 | 191 | verify(mockClient); |
191 | 192 | } |
192 | 193 |
|
| 194 | + @Test |
| 195 | + public void testExportingIgnoredMetrics() { |
| 196 | + // No expectations on mockMetricServiceStub means we expect NO calls to it. |
| 197 | + replay(mockMetricServiceStub); |
| 198 | + |
| 199 | + long fakeValue = 11L; |
| 200 | + long startEpoch = 10; |
| 201 | + long endEpoch = 15; |
| 202 | + LongPointData longPointData = |
| 203 | + ImmutableLongPointData.create(startEpoch, endEpoch, attributes, fakeValue); |
| 204 | + |
| 205 | + String ignoredMetricName = "otel.sdk.metric_reader.collection.duration"; |
| 206 | + MetricData ignoredData = |
| 207 | + ImmutableMetricData.createLongSum( |
| 208 | + resource, |
| 209 | + scope, |
| 210 | + ignoredMetricName, |
| 211 | + "description", |
| 212 | + "1", |
| 213 | + ImmutableSumData.create( |
| 214 | + true, AggregationTemporality.CUMULATIVE, ImmutableList.of(longPointData))); |
| 215 | + |
| 216 | + CompletableResultCode result = exporter.export(Collections.singletonList(ignoredData)); |
| 217 | + |
| 218 | + assertThat(result.isSuccess()).isTrue(); |
| 219 | + |
| 220 | + verify(mockMetricServiceStub); |
| 221 | + } |
| 222 | + |
193 | 223 | private static class FakeMetricServiceClient extends MetricServiceClient { |
194 | 224 | protected FakeMetricServiceClient(MetricServiceStub stub) { |
195 | 225 | super(stub); |
|
0 commit comments