Skip to content

Commit

Permalink
Make MetricData factories internal (#4257)
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga authored Mar 11, 2022
1 parent 7ae6904 commit 26c0429
Show file tree
Hide file tree
Showing 29 changed files with 321 additions and 279 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.export.MetricExporter;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableDoublePointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData;
import io.opentelemetry.sdk.resources.Resource;
import java.util.Arrays;
Expand All @@ -32,7 +33,7 @@ class OtlpJsonLoggingMetricExporterTest {
Resource.create(Attributes.builder().put("key", "value").build());

private static final MetricData METRIC1 =
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
RESOURCE,
InstrumentationLibraryInfo.create("instrumentation", "1"),
"metric1",
Expand All @@ -46,7 +47,7 @@ class OtlpJsonLoggingMetricExporterTest {
1, 2, Attributes.of(stringKey("cat"), "meow"), 4))));

private static final MetricData METRIC2 =
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
RESOURCE,
InstrumentationLibraryInfo.create("instrumentation2", "2"),
"metric2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import io.opentelemetry.internal.testing.slf4j.SuppressLogger;
import io.opentelemetry.sdk.common.InstrumentationLibraryInfo;
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableDoublePointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableLongPointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSummaryData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSummaryPointData;
Expand Down Expand Up @@ -63,7 +63,7 @@ void testExport() {
InstrumentationLibraryInfo.create("manualInstrumentation", "1.0");
exporter.export(
Arrays.asList(
MetricData.createDoubleSummary(
ImmutableMetricData.createDoubleSummary(
resource,
instrumentationLibraryInfo,
"measureOne",
Expand All @@ -80,7 +80,7 @@ void testExport() {
Arrays.asList(
ImmutableValueAtQuantile.create(0.0, 25),
ImmutableValueAtQuantile.create(1.0, 433)))))),
MetricData.createLongSum(
ImmutableMetricData.createLongSum(
resource,
instrumentationLibraryInfo,
"counterOne",
Expand All @@ -95,7 +95,7 @@ void testExport() {
nowEpochNanos + 245,
Attributes.of(stringKey("z"), "y", stringKey("x"), "w"),
1010)))),
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
resource,
instrumentationLibraryInfo,
"observedValue",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableLongPointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData;
import io.opentelemetry.sdk.resources.Resource;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -323,7 +324,7 @@ private static <T extends Message> HttpResponse buildResponse(HttpStatus httpSta
private static MetricData generateFakeMetric() {
long startNs = TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis());
long endNs = startNs + TimeUnit.MILLISECONDS.toNanos(900);
return MetricData.createLongSum(
return ImmutableMetricData.createLongSum(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import io.opentelemetry.sdk.metrics.internal.data.ImmutableHistogramPointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableLongExemplarData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableLongPointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSummaryData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSummaryPointData;
Expand Down Expand Up @@ -462,7 +463,7 @@ void exponentialHistogramDataPoints() {
void toProtoMetric_monotonic() {
assertThat(
toProtoMetric(
MetricData.createLongSum(
ImmutableMetricData.createLongSum(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down Expand Up @@ -497,7 +498,7 @@ void toProtoMetric_monotonic() {
.build());
assertThat(
toProtoMetric(
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down Expand Up @@ -536,7 +537,7 @@ void toProtoMetric_monotonic() {
void toProtoMetric_nonMonotonic() {
assertThat(
toProtoMetric(
MetricData.createLongSum(
ImmutableMetricData.createLongSum(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down Expand Up @@ -571,7 +572,7 @@ void toProtoMetric_nonMonotonic() {
.build());
assertThat(
toProtoMetric(
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down Expand Up @@ -610,7 +611,7 @@ void toProtoMetric_nonMonotonic() {
void toProtoMetric_gauges() {
assertThat(
toProtoMetric(
MetricData.createLongGauge(
ImmutableMetricData.createLongGauge(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down Expand Up @@ -641,7 +642,7 @@ void toProtoMetric_gauges() {
.build());
assertThat(
toProtoMetric(
MetricData.createDoubleGauge(
ImmutableMetricData.createDoubleGauge(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down Expand Up @@ -676,7 +677,7 @@ void toProtoMetric_gauges() {
void toProtoMetric_summary() {
assertThat(
toProtoMetric(
MetricData.createDoubleSummary(
ImmutableMetricData.createDoubleSummary(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down Expand Up @@ -731,7 +732,7 @@ void toProtoMetric_summary() {
void toProtoMetric_histogram() {
assertThat(
toProtoMetric(
MetricData.createDoubleHistogram(
ImmutableMetricData.createDoubleHistogram(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down Expand Up @@ -777,7 +778,7 @@ void toProtoMetric_histogram() {
void toProtoMetric_exponentialHistogram() {
assertThat(
toProtoMetric(
MetricData.createExponentialHistogram(
ImmutableMetricData.createExponentialHistogram(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down Expand Up @@ -882,7 +883,7 @@ void protoResourceMetrics() {
assertThat(
toProtoResourceMetrics(
ImmutableList.of(
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
resource,
instrumentationLibraryInfo,
"name",
Expand All @@ -893,7 +894,7 @@ void protoResourceMetrics() {
AggregationTemporality.CUMULATIVE,
Collections.singletonList(
ImmutableDoublePointData.create(123, 456, KV_ATTR, 5.0)))),
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
resource,
instrumentationLibraryInfo,
"name",
Expand All @@ -904,7 +905,7 @@ void protoResourceMetrics() {
AggregationTemporality.CUMULATIVE,
Collections.singletonList(
ImmutableDoublePointData.create(123, 456, KV_ATTR, 5.0)))),
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
Resource.empty(),
instrumentationLibraryInfo,
"name",
Expand All @@ -915,7 +916,7 @@ void protoResourceMetrics() {
AggregationTemporality.CUMULATIVE,
Collections.singletonList(
ImmutableDoublePointData.create(123, 456, KV_ATTR, 5.0)))),
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableLongPointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData;
import io.opentelemetry.sdk.resources.Resource;
import java.time.Duration;
Expand Down Expand Up @@ -110,7 +111,7 @@ public TelemetryExporter<MetricData> build() {
protected MetricData generateFakeTelemetry() {
long startNs = TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis());
long endNs = startNs + TimeUnit.MILLISECONDS.toNanos(900);
return MetricData.createLongSum(
return ImmutableMetricData.createLongSum(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableLongPointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData;
import io.opentelemetry.sdk.resources.Resource;
import java.time.Duration;
Expand Down Expand Up @@ -110,7 +111,7 @@ public TelemetryExporter<MetricData> build() {
protected MetricData generateFakeTelemetry() {
long startNs = TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis());
long endNs = startNs + TimeUnit.MILLISECONDS.toNanos(900);
return MetricData.createLongSum(
return ImmutableMetricData.createLongSum(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableLongPointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData;
import io.opentelemetry.sdk.resources.Resource;
import java.time.Duration;
Expand Down Expand Up @@ -99,7 +100,7 @@ public TelemetryExporter<MetricData> build() {
protected MetricData generateFakeTelemetry() {
long startNs = TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis());
long endNs = startNs + TimeUnit.MILLISECONDS.toNanos(900);
return MetricData.createLongSum(
return ImmutableMetricData.createLongSum(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableLongPointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData;
import io.opentelemetry.sdk.resources.Resource;
import java.time.Duration;
Expand Down Expand Up @@ -99,7 +100,7 @@ public TelemetryExporter<MetricData> build() {
protected MetricData generateFakeTelemetry() {
long startNs = TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis());
long endNs = startNs + TimeUnit.MILLISECONDS.toNanos(900);
return MetricData.createLongSum(
return ImmutableMetricData.createLongSum(
Resource.empty(),
InstrumentationLibraryInfo.empty(),
"name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.opentelemetry.sdk.metrics.internal.data.ImmutableHistogramPointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableLongExemplarData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableLongPointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSummaryData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableSummaryPointData;
Expand All @@ -49,7 +50,7 @@ class MetricAdapterTest {
private static final Attributes KP_VP_ATTR = Attributes.of(stringKey("kp"), "vp");

private static final MetricData MONOTONIC_CUMULATIVE_DOUBLE_SUM =
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationLibraryInfo.create("full", "version"),
"instrument.name",
Expand All @@ -62,7 +63,7 @@ class MetricAdapterTest {
ImmutableDoublePointData.create(
1633947011000000000L, 1633950672000000000L, KP_VP_ATTR, 5))));
private static final MetricData NON_MONOTONIC_CUMULATIVE_DOUBLE_SUM =
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationLibraryInfo.create("full", "version"),
"instrument.name",
Expand All @@ -75,7 +76,7 @@ class MetricAdapterTest {
ImmutableDoublePointData.create(
1633947011000000000L, 1633950672000000000L, KP_VP_ATTR, 5))));
private static final MetricData MONOTONIC_DELTA_DOUBLE_SUM =
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationLibraryInfo.create("full", "version"),
"instrument.name",
Expand All @@ -88,7 +89,7 @@ class MetricAdapterTest {
ImmutableDoublePointData.create(
1633947011000000000L, 1633950672000000000L, KP_VP_ATTR, 5))));
private static final MetricData NON_MONOTONIC_DELTA_DOUBLE_SUM =
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationLibraryInfo.create("full", "version"),
"instrument.name",
Expand All @@ -101,7 +102,7 @@ class MetricAdapterTest {
ImmutableDoublePointData.create(
1633947011000000000L, 1633950672000000000L, KP_VP_ATTR, 5))));
private static final MetricData MONOTONIC_CUMULATIVE_LONG_SUM =
MetricData.createLongSum(
ImmutableMetricData.createLongSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationLibraryInfo.create("full", "version"),
"instrument.name",
Expand All @@ -114,7 +115,7 @@ class MetricAdapterTest {
ImmutableLongPointData.create(
1633947011000000000L, 1633950672000000000L, KP_VP_ATTR, 5))));
private static final MetricData NON_MONOTONIC_CUMULATIVE_LONG_SUM =
MetricData.createLongSum(
ImmutableMetricData.createLongSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationLibraryInfo.create("full", "version"),
"instrument.name",
Expand All @@ -127,7 +128,7 @@ class MetricAdapterTest {
ImmutableLongPointData.create(
1633947011000000000L, 1633950672000000000L, KP_VP_ATTR, 5))));
private static final MetricData MONOTONIC_DELTA_LONG_SUM =
MetricData.createLongSum(
ImmutableMetricData.createLongSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationLibraryInfo.create("full", "version"),
"instrument.name",
Expand All @@ -140,7 +141,7 @@ class MetricAdapterTest {
ImmutableLongPointData.create(
1633947011000000000L, 1633950672000000000L, KP_VP_ATTR, 5))));
private static final MetricData NON_MONOTONIC_DELTA_LONG_SUM =
MetricData.createLongSum(
ImmutableMetricData.createLongSum(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationLibraryInfo.create("full", "version"),
"instrument.name",
Expand All @@ -154,7 +155,7 @@ class MetricAdapterTest {
1633947011000000000L, 1633950672000000000L, KP_VP_ATTR, 5))));

private static final MetricData DOUBLE_GAUGE =
MetricData.createDoubleGauge(
ImmutableMetricData.createDoubleGauge(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationLibraryInfo.create("full", "version"),
"instrument.name",
Expand All @@ -165,7 +166,7 @@ class MetricAdapterTest {
ImmutableDoublePointData.create(
1633947011000000000L, 1633950672000000000L, KP_VP_ATTR, 5))));
private static final MetricData LONG_GAUGE =
MetricData.createLongGauge(
ImmutableMetricData.createLongGauge(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationLibraryInfo.create("full", "version"),
"instrument.name",
Expand All @@ -176,7 +177,7 @@ class MetricAdapterTest {
ImmutableLongPointData.create(
1633947011000000000L, 1633950672000000000L, KP_VP_ATTR, 5))));
private static final MetricData SUMMARY =
MetricData.createDoubleSummary(
ImmutableMetricData.createDoubleSummary(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationLibraryInfo.create("full", "version"),
"instrument.name",
Expand All @@ -194,7 +195,7 @@ class MetricAdapterTest {
ImmutableValueAtQuantile.create(0.9, 0.1),
ImmutableValueAtQuantile.create(0.99, 0.3))))));
private static final MetricData HISTOGRAM =
MetricData.createDoubleHistogram(
ImmutableMetricData.createDoubleHistogram(
Resource.create(Attributes.of(stringKey("kr"), "vr")),
InstrumentationLibraryInfo.create("full", "version"),
"instrument.name",
Expand Down
Loading

0 comments on commit 26c0429

Please sign in to comment.