From 26c04299d3395e5f49daf1e050eaa2b21a33e63a Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Fri, 11 Mar 2022 16:30:13 +0900 Subject: [PATCH] Make MetricData factories internal (#4257) --- .../OtlpJsonLoggingMetricExporterTest.java | 5 +- .../logging/LoggingMetricExporterTest.java | 8 +- .../metrics/OtlpHttpMetricExporterTest.java | 3 +- .../metrics/MetricsRequestMarshalerTest.java | 27 +-- .../metrics/OtlpGrpcMetricExporterTest.java | 3 +- .../OtlpGrpcNettyMetricExporterTest.java | 3 +- ...OtlpGrpcNettyShadedMetricExporterTest.java | 3 +- .../OtlpGrpcOkHttpMetricExporterTest.java | 3 +- .../prometheus/MetricAdapterTest.java | 25 +-- .../prometheus/PrometheusCollectorTest.java | 5 +- .../prometheus/PrometheusHttpServerTest.java | 5 +- .../exporter/prometheus/SerializerTest.java | 29 +-- .../internal/metrics/MetricAdapter.java | 15 +- .../OtlpGrpcServerExtension.java | 3 +- .../OtlpHttpServerExtension.java | 3 +- .../testing/assertj/MetricAssertionsTest.java | 23 +- .../exporter/InMemoryMetricExporterTest.java | 3 +- .../sdk/metrics/data/MetricData.java | 158 +------------- .../sdk/metrics/data/MetricDataImpl.java | 30 --- .../DoubleExponentialHistogramAggregator.java | 3 +- .../aggregator/DoubleHistogramAggregator.java | 3 +- .../aggregator/DoubleLastValueAggregator.java | 3 +- .../aggregator/DoubleSumAggregator.java | 3 +- .../aggregator/LongLastValueAggregator.java | 3 +- .../aggregator/LongSumAggregator.java | 3 +- .../internal/data/ImmutableMetricData.java | 201 ++++++++++++++++++ ...Test.java => ImmutableMetricDataTest.java} | 21 +- .../export/PeriodicMetricReaderTest.java | 3 +- .../LongLastValueAggregatorTest.java | 3 +- 29 files changed, 321 insertions(+), 279 deletions(-) delete mode 100644 sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/data/MetricDataImpl.java create mode 100644 sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/data/ImmutableMetricData.java rename sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/data/{MetricDataImplTest.java => ImmutableMetricDataTest.java} (95%) diff --git a/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingMetricExporterTest.java b/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingMetricExporterTest.java index 14188c82a1e..e29bd18bd3a 100644 --- a/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingMetricExporterTest.java +++ b/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingMetricExporterTest.java @@ -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; @@ -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", @@ -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", diff --git a/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/LoggingMetricExporterTest.java b/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/LoggingMetricExporterTest.java index 3abc3141356..8d48a66c630 100644 --- a/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/LoggingMetricExporterTest.java +++ b/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/LoggingMetricExporterTest.java @@ -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; @@ -63,7 +63,7 @@ void testExport() { InstrumentationLibraryInfo.create("manualInstrumentation", "1.0"); exporter.export( Arrays.asList( - MetricData.createDoubleSummary( + ImmutableMetricData.createDoubleSummary( resource, instrumentationLibraryInfo, "measureOne", @@ -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", @@ -95,7 +95,7 @@ void testExport() { nowEpochNanos + 245, Attributes.of(stringKey("z"), "y", stringKey("x"), "w"), 1010)))), - MetricData.createDoubleSum( + ImmutableMetricData.createDoubleSum( resource, instrumentationLibraryInfo, "observedValue", diff --git a/exporters/otlp-http/metrics/src/test/java/io/opentelemetry/exporter/otlp/http/metrics/OtlpHttpMetricExporterTest.java b/exporters/otlp-http/metrics/src/test/java/io/opentelemetry/exporter/otlp/http/metrics/OtlpHttpMetricExporterTest.java index 1c9e382f63b..c030cb600bb 100644 --- a/exporters/otlp-http/metrics/src/test/java/io/opentelemetry/exporter/otlp/http/metrics/OtlpHttpMetricExporterTest.java +++ b/exporters/otlp-http/metrics/src/test/java/io/opentelemetry/exporter/otlp/http/metrics/OtlpHttpMetricExporterTest.java @@ -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; @@ -323,7 +324,7 @@ private static 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", diff --git a/exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/metrics/MetricsRequestMarshalerTest.java b/exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/metrics/MetricsRequestMarshalerTest.java index bb42a27cda8..d9184f852df 100644 --- a/exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/metrics/MetricsRequestMarshalerTest.java +++ b/exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/metrics/MetricsRequestMarshalerTest.java @@ -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; @@ -462,7 +463,7 @@ void exponentialHistogramDataPoints() { void toProtoMetric_monotonic() { assertThat( toProtoMetric( - MetricData.createLongSum( + ImmutableMetricData.createLongSum( Resource.empty(), InstrumentationLibraryInfo.empty(), "name", @@ -497,7 +498,7 @@ void toProtoMetric_monotonic() { .build()); assertThat( toProtoMetric( - MetricData.createDoubleSum( + ImmutableMetricData.createDoubleSum( Resource.empty(), InstrumentationLibraryInfo.empty(), "name", @@ -536,7 +537,7 @@ void toProtoMetric_monotonic() { void toProtoMetric_nonMonotonic() { assertThat( toProtoMetric( - MetricData.createLongSum( + ImmutableMetricData.createLongSum( Resource.empty(), InstrumentationLibraryInfo.empty(), "name", @@ -571,7 +572,7 @@ void toProtoMetric_nonMonotonic() { .build()); assertThat( toProtoMetric( - MetricData.createDoubleSum( + ImmutableMetricData.createDoubleSum( Resource.empty(), InstrumentationLibraryInfo.empty(), "name", @@ -610,7 +611,7 @@ void toProtoMetric_nonMonotonic() { void toProtoMetric_gauges() { assertThat( toProtoMetric( - MetricData.createLongGauge( + ImmutableMetricData.createLongGauge( Resource.empty(), InstrumentationLibraryInfo.empty(), "name", @@ -641,7 +642,7 @@ void toProtoMetric_gauges() { .build()); assertThat( toProtoMetric( - MetricData.createDoubleGauge( + ImmutableMetricData.createDoubleGauge( Resource.empty(), InstrumentationLibraryInfo.empty(), "name", @@ -676,7 +677,7 @@ void toProtoMetric_gauges() { void toProtoMetric_summary() { assertThat( toProtoMetric( - MetricData.createDoubleSummary( + ImmutableMetricData.createDoubleSummary( Resource.empty(), InstrumentationLibraryInfo.empty(), "name", @@ -731,7 +732,7 @@ void toProtoMetric_summary() { void toProtoMetric_histogram() { assertThat( toProtoMetric( - MetricData.createDoubleHistogram( + ImmutableMetricData.createDoubleHistogram( Resource.empty(), InstrumentationLibraryInfo.empty(), "name", @@ -777,7 +778,7 @@ void toProtoMetric_histogram() { void toProtoMetric_exponentialHistogram() { assertThat( toProtoMetric( - MetricData.createExponentialHistogram( + ImmutableMetricData.createExponentialHistogram( Resource.empty(), InstrumentationLibraryInfo.empty(), "name", @@ -882,7 +883,7 @@ void protoResourceMetrics() { assertThat( toProtoResourceMetrics( ImmutableList.of( - MetricData.createDoubleSum( + ImmutableMetricData.createDoubleSum( resource, instrumentationLibraryInfo, "name", @@ -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", @@ -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", @@ -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", diff --git a/exporters/otlp/metrics/src/test/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcMetricExporterTest.java b/exporters/otlp/metrics/src/test/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcMetricExporterTest.java index 55bbfbc2467..0c9742a0743 100644 --- a/exporters/otlp/metrics/src/test/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcMetricExporterTest.java +++ b/exporters/otlp/metrics/src/test/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcMetricExporterTest.java @@ -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; @@ -110,7 +111,7 @@ public TelemetryExporter 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", diff --git a/exporters/otlp/metrics/src/testGrpcNetty/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcNettyMetricExporterTest.java b/exporters/otlp/metrics/src/testGrpcNetty/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcNettyMetricExporterTest.java index cae4ffcfe96..a0977e13dcb 100644 --- a/exporters/otlp/metrics/src/testGrpcNetty/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcNettyMetricExporterTest.java +++ b/exporters/otlp/metrics/src/testGrpcNetty/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcNettyMetricExporterTest.java @@ -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; @@ -110,7 +111,7 @@ public TelemetryExporter 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", diff --git a/exporters/otlp/metrics/src/testGrpcNettyShaded/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcNettyShadedMetricExporterTest.java b/exporters/otlp/metrics/src/testGrpcNettyShaded/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcNettyShadedMetricExporterTest.java index f447fb86d16..e8ca0fb7899 100644 --- a/exporters/otlp/metrics/src/testGrpcNettyShaded/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcNettyShadedMetricExporterTest.java +++ b/exporters/otlp/metrics/src/testGrpcNettyShaded/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcNettyShadedMetricExporterTest.java @@ -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; @@ -99,7 +100,7 @@ public TelemetryExporter 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", diff --git a/exporters/otlp/metrics/src/testGrpcOkhttp/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcOkHttpMetricExporterTest.java b/exporters/otlp/metrics/src/testGrpcOkhttp/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcOkHttpMetricExporterTest.java index a8f646ec174..fe6c8030456 100644 --- a/exporters/otlp/metrics/src/testGrpcOkhttp/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcOkHttpMetricExporterTest.java +++ b/exporters/otlp/metrics/src/testGrpcOkhttp/java/io/opentelemetry/exporter/otlp/metrics/OtlpGrpcOkHttpMetricExporterTest.java @@ -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; @@ -99,7 +100,7 @@ public TelemetryExporter 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", diff --git a/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/MetricAdapterTest.java b/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/MetricAdapterTest.java index 001ae2257fe..4747fd791d4 100644 --- a/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/MetricAdapterTest.java +++ b/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/MetricAdapterTest.java @@ -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; @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", diff --git a/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusCollectorTest.java b/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusCollectorTest.java index baf4d62f6aa..ab100a43377 100644 --- a/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusCollectorTest.java +++ b/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusCollectorTest.java @@ -19,6 +19,7 @@ import io.opentelemetry.sdk.metrics.export.MetricProducer; 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.resources.Resource; import io.prometheus.client.CollectorRegistry; @@ -76,7 +77,7 @@ void registerToDefault() throws IOException { private static ImmutableList generateTestData() { return ImmutableList.of( - MetricData.createLongSum( + ImmutableMetricData.createLongSum( Resource.create(Attributes.of(stringKey("kr"), "vr")), InstrumentationLibraryInfo.create("grpc", "version"), "grpc.name", @@ -91,7 +92,7 @@ private static ImmutableList generateTestData() { 1633950672000000000L, Attributes.of(stringKey("kp"), "vp"), 5)))), - MetricData.createDoubleSum( + ImmutableMetricData.createDoubleSum( Resource.create(Attributes.of(stringKey("kr"), "vr")), InstrumentationLibraryInfo.create("http", "version"), "http.name", diff --git a/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServerTest.java b/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServerTest.java index ac8265df420..9d8ca84b942 100644 --- a/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServerTest.java +++ b/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServerTest.java @@ -24,6 +24,7 @@ import io.opentelemetry.sdk.metrics.export.MetricProducer; 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.resources.Resource; import java.util.Collections; @@ -169,7 +170,7 @@ void fetchHealth() { private static ImmutableList generateTestData() { return ImmutableList.of( - MetricData.createLongSum( + ImmutableMetricData.createLongSum( Resource.create(Attributes.of(stringKey("kr"), "vr")), InstrumentationLibraryInfo.create("grpc", "version"), "grpc.name", @@ -181,7 +182,7 @@ private static ImmutableList generateTestData() { Collections.singletonList( ImmutableLongPointData.create( 123, 456, Attributes.of(stringKey("kp"), "vp"), 5)))), - MetricData.createDoubleSum( + ImmutableMetricData.createDoubleSum( Resource.create(Attributes.of(stringKey("kr"), "vr")), InstrumentationLibraryInfo.create("http", "version"), "http.name", diff --git a/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/SerializerTest.java b/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/SerializerTest.java index 34678948d31..7ff1a5517c6 100644 --- a/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/SerializerTest.java +++ b/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/SerializerTest.java @@ -21,6 +21,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; @@ -39,7 +40,7 @@ class SerializerTest { 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", @@ -52,7 +53,7 @@ class SerializerTest { 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", @@ -65,7 +66,7 @@ class SerializerTest { 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", @@ -78,7 +79,7 @@ class SerializerTest { 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", @@ -91,7 +92,7 @@ class SerializerTest { 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", @@ -104,7 +105,7 @@ class SerializerTest { 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", @@ -117,7 +118,7 @@ class SerializerTest { 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", @@ -130,7 +131,7 @@ class SerializerTest { 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", @@ -144,7 +145,7 @@ class SerializerTest { 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", @@ -155,7 +156,7 @@ class SerializerTest { 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", @@ -166,7 +167,7 @@ class SerializerTest { 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", @@ -184,7 +185,7 @@ class SerializerTest { 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", @@ -211,7 +212,7 @@ class SerializerTest { TraceState.getDefault()), /* value= */ 4)))))); private static final MetricData DOUBLE_GAUGE_NO_ATTRIBUTES = - MetricData.createDoubleGauge( + ImmutableMetricData.createDoubleGauge( Resource.create(Attributes.of(stringKey("kr"), "vr")), InstrumentationLibraryInfo.create("full", "version"), "instrument.name", @@ -222,7 +223,7 @@ class SerializerTest { ImmutableDoublePointData.create( 1633947011000000000L, 1633950672000000000L, Attributes.empty(), 7)))); private static final MetricData DOUBLE_GAUGE_MULTIPLE_ATTRIBUTES = - MetricData.createDoubleGauge( + ImmutableMetricData.createDoubleGauge( Resource.create(Attributes.of(stringKey("kr"), "vr")), InstrumentationLibraryInfo.create("full", "version"), "instrument.name", diff --git a/opencensus-shim/src/main/java/io/opentelemetry/opencensusshim/internal/metrics/MetricAdapter.java b/opencensus-shim/src/main/java/io/opentelemetry/opencensusshim/internal/metrics/MetricAdapter.java index ba8401bf406..ea545dde4e0 100644 --- a/opencensus-shim/src/main/java/io/opentelemetry/opencensusshim/internal/metrics/MetricAdapter.java +++ b/opencensus-shim/src/main/java/io/opentelemetry/opencensusshim/internal/metrics/MetricAdapter.java @@ -39,6 +39,7 @@ import io.opentelemetry.sdk.metrics.internal.data.ImmutableHistogramData; import io.opentelemetry.sdk.metrics.internal.data.ImmutableHistogramPointData; 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; @@ -83,7 +84,7 @@ public static MetricData convert(Resource otelResource, Metric censusMetric) { // auto-value vs. pure interfaces. switch (censusMetric.getMetricDescriptor().getType()) { case GAUGE_INT64: - return MetricData.createLongGauge( + return ImmutableMetricData.createLongGauge( otelResource, INSTRUMENTATION_LIBRARY_INFO, censusMetric.getMetricDescriptor().getName(), @@ -91,7 +92,7 @@ public static MetricData convert(Resource otelResource, Metric censusMetric) { censusMetric.getMetricDescriptor().getUnit(), convertLongGauge(censusMetric)); case GAUGE_DOUBLE: - return MetricData.createDoubleGauge( + return ImmutableMetricData.createDoubleGauge( otelResource, INSTRUMENTATION_LIBRARY_INFO, censusMetric.getMetricDescriptor().getName(), @@ -99,7 +100,7 @@ public static MetricData convert(Resource otelResource, Metric censusMetric) { censusMetric.getMetricDescriptor().getUnit(), convertDoubleGauge(censusMetric)); case CUMULATIVE_INT64: - return MetricData.createLongSum( + return ImmutableMetricData.createLongSum( otelResource, INSTRUMENTATION_LIBRARY_INFO, censusMetric.getMetricDescriptor().getName(), @@ -107,7 +108,7 @@ public static MetricData convert(Resource otelResource, Metric censusMetric) { censusMetric.getMetricDescriptor().getUnit(), convertLongSum(censusMetric)); case CUMULATIVE_DOUBLE: - return MetricData.createDoubleSum( + return ImmutableMetricData.createDoubleSum( otelResource, INSTRUMENTATION_LIBRARY_INFO, censusMetric.getMetricDescriptor().getName(), @@ -115,7 +116,7 @@ public static MetricData convert(Resource otelResource, Metric censusMetric) { censusMetric.getMetricDescriptor().getUnit(), convertDoubleSum(censusMetric)); case CUMULATIVE_DISTRIBUTION: - return MetricData.createDoubleHistogram( + return ImmutableMetricData.createDoubleHistogram( otelResource, INSTRUMENTATION_LIBRARY_INFO, censusMetric.getMetricDescriptor().getName(), @@ -123,7 +124,7 @@ public static MetricData convert(Resource otelResource, Metric censusMetric) { censusMetric.getMetricDescriptor().getUnit(), convertHistogram(censusMetric)); case SUMMARY: - return MetricData.createDoubleSummary( + return ImmutableMetricData.createDoubleSummary( otelResource, INSTRUMENTATION_LIBRARY_INFO, censusMetric.getMetricDescriptor().getName(), @@ -131,7 +132,7 @@ public static MetricData convert(Resource otelResource, Metric censusMetric) { censusMetric.getMetricDescriptor().getUnit(), convertSummary(censusMetric)); case GAUGE_DISTRIBUTION: - return MetricData.createDoubleHistogram( + return ImmutableMetricData.createDoubleHistogram( otelResource, INSTRUMENTATION_LIBRARY_INFO, censusMetric.getMetricDescriptor().getName(), diff --git a/sdk-extensions/autoconfigure/src/testOtlpGrpc/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcServerExtension.java b/sdk-extensions/autoconfigure/src/testOtlpGrpc/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcServerExtension.java index edc5f6f8292..742b9f91a1c 100644 --- a/sdk-extensions/autoconfigure/src/testOtlpGrpc/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcServerExtension.java +++ b/sdk-extensions/autoconfigure/src/testOtlpGrpc/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcServerExtension.java @@ -32,6 +32,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 io.opentelemetry.sdk.testing.trace.TestSpanData; @@ -145,7 +146,7 @@ static SpanData generateFakeSpan() { } static MetricData generateFakeMetric() { - return MetricData.createLongSum( + return ImmutableMetricData.createLongSum( Resource.empty(), InstrumentationLibraryInfo.empty(), "metric_name", diff --git a/sdk-extensions/autoconfigure/src/testOtlpHttp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpServerExtension.java b/sdk-extensions/autoconfigure/src/testOtlpHttp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpServerExtension.java index d74882c4da8..2bf826514ad 100644 --- a/sdk-extensions/autoconfigure/src/testOtlpHttp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpServerExtension.java +++ b/sdk-extensions/autoconfigure/src/testOtlpHttp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpServerExtension.java @@ -27,6 +27,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 io.opentelemetry.sdk.testing.trace.TestSpanData; @@ -128,7 +129,7 @@ static SpanData generateFakeSpan() { } static MetricData generateFakeMetric() { - return MetricData.createLongSum( + return ImmutableMetricData.createLongSum( Resource.empty(), InstrumentationLibraryInfo.empty(), "metric_name", diff --git a/sdk/metrics-testing/src/test/java/io/opentelemetry/sdk/testing/assertj/MetricAssertionsTest.java b/sdk/metrics-testing/src/test/java/io/opentelemetry/sdk/testing/assertj/MetricAssertionsTest.java index 05285575351..e44558bb309 100644 --- a/sdk/metrics-testing/src/test/java/io/opentelemetry/sdk/testing/assertj/MetricAssertionsTest.java +++ b/sdk/metrics-testing/src/test/java/io/opentelemetry/sdk/testing/assertj/MetricAssertionsTest.java @@ -30,6 +30,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; @@ -46,7 +47,7 @@ public class MetricAssertionsTest { private static final InstrumentationLibraryInfo INSTRUMENTATION_LIBRARY_INFO = InstrumentationLibraryInfo.create("instrumentation_library", null); private static final MetricData HISTOGRAM_METRIC = - MetricData.createDoubleHistogram( + ImmutableMetricData.createDoubleHistogram( RESOURCE, INSTRUMENTATION_LIBRARY_INFO, /* name= */ "histogram", @@ -58,7 +59,7 @@ public class MetricAssertionsTest { Collections.emptyList())); private static final MetricData HISTOGRAM_DELTA_METRIC = - MetricData.createDoubleHistogram( + ImmutableMetricData.createDoubleHistogram( RESOURCE, INSTRUMENTATION_LIBRARY_INFO, /* name= */ "histogram_delta", @@ -70,7 +71,7 @@ public class MetricAssertionsTest { Collections.emptyList())); private static final MetricData EXPONENTIAL_HISTOGRAM_METRIC = - MetricData.createExponentialHistogram( + ImmutableMetricData.createExponentialHistogram( RESOURCE, INSTRUMENTATION_LIBRARY_INFO, /* name= */ "exponential_histogram", @@ -82,7 +83,7 @@ public class MetricAssertionsTest { Collections.emptyList())); private static final MetricData EXPONENTIAL_HISTOGRAM_DELTA_METRIC = - MetricData.createExponentialHistogram( + ImmutableMetricData.createExponentialHistogram( RESOURCE, INSTRUMENTATION_LIBRARY_INFO, /* name= */ "exponential_histogram_delta", @@ -94,7 +95,7 @@ public class MetricAssertionsTest { Collections.emptyList())); private static final MetricData DOUBLE_SUMMARY_METRIC = - MetricData.createDoubleSummary( + ImmutableMetricData.createDoubleSummary( RESOURCE, INSTRUMENTATION_LIBRARY_INFO, /* name= */ "summary", @@ -105,7 +106,7 @@ public class MetricAssertionsTest { Collections.emptyList())); private static final MetricData DOUBLE_GAUGE_METRIC = - MetricData.createDoubleGauge( + ImmutableMetricData.createDoubleGauge( RESOURCE, INSTRUMENTATION_LIBRARY_INFO, /* name= */ "gauge", @@ -116,7 +117,7 @@ public class MetricAssertionsTest { Collections.emptyList())); private static final MetricData DOUBLE_SUM_METRIC = - MetricData.createDoubleSum( + ImmutableMetricData.createDoubleSum( RESOURCE, INSTRUMENTATION_LIBRARY_INFO, /* name= */ "sum", @@ -129,7 +130,7 @@ public class MetricAssertionsTest { Collections.emptyList())); private static final MetricData DOUBLE_DELTA_SUM_METRIC = - MetricData.createDoubleSum( + ImmutableMetricData.createDoubleSum( RESOURCE, INSTRUMENTATION_LIBRARY_INFO, /* name= */ "sum_delta", @@ -160,7 +161,7 @@ public class MetricAssertionsTest { 1, 2, Attributes.empty(), 3.0, Collections.singletonList(DOUBLE_EXEMPLAR)); private static final MetricData LONG_GAUGE_METRIC = - MetricData.createLongGauge( + ImmutableMetricData.createLongGauge( RESOURCE, INSTRUMENTATION_LIBRARY_INFO, /* name= */ "gauge", @@ -171,7 +172,7 @@ public class MetricAssertionsTest { Collections.emptyList())); private static final MetricData LONG_SUM_METRIC = - MetricData.createLongSum( + ImmutableMetricData.createLongSum( RESOURCE, INSTRUMENTATION_LIBRARY_INFO, /* name= */ "sum", @@ -184,7 +185,7 @@ public class MetricAssertionsTest { Collections.emptyList())); private static final MetricData LONG_DELTA_SUM_METRIC = - MetricData.createLongSum( + ImmutableMetricData.createLongSum( RESOURCE, INSTRUMENTATION_LIBRARY_INFO, /* name= */ "sum_delta", diff --git a/sdk/metrics-testing/src/test/java/io/opentelemetry/sdk/testing/exporter/InMemoryMetricExporterTest.java b/sdk/metrics-testing/src/test/java/io/opentelemetry/sdk/testing/exporter/InMemoryMetricExporterTest.java index cb3dc0c76d8..e957ffd7e9b 100644 --- a/sdk/metrics-testing/src/test/java/io/opentelemetry/sdk/testing/exporter/InMemoryMetricExporterTest.java +++ b/sdk/metrics-testing/src/test/java/io/opentelemetry/sdk/testing/exporter/InMemoryMetricExporterTest.java @@ -12,6 +12,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.util.ArrayList; @@ -28,7 +29,7 @@ class InMemoryMetricExporterTest { 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", diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/data/MetricData.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/data/MetricData.java index 17dc2ed329d..582f55c71b8 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/data/MetricData.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/data/MetricData.java @@ -8,173 +8,19 @@ import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; import io.opentelemetry.sdk.metrics.internal.data.ImmutableGaugeData; import io.opentelemetry.sdk.metrics.internal.data.ImmutableHistogramData; +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.exponentialhistogram.ExponentialHistogramData; import io.opentelemetry.sdk.resources.Resource; import javax.annotation.concurrent.Immutable; /** - * A {@link MetricDataImpl} represents the data exported as part of aggregating one {@code + * A {@link ImmutableMetricData} represents the data exported as part of aggregating one {@code * Instrument}. */ @Immutable public interface MetricData { - /** - * Returns a new MetricData wih a {@link MetricDataType#DOUBLE_GAUGE} type. - * - * @return a new MetricData wih a {@link MetricDataType#DOUBLE_GAUGE} type. - */ - static MetricData createDoubleGauge( - Resource resource, - InstrumentationLibraryInfo instrumentationLibraryInfo, - String name, - String description, - String unit, - GaugeData data) { - return MetricDataImpl.create( - resource, - instrumentationLibraryInfo, - name, - description, - unit, - MetricDataType.DOUBLE_GAUGE, - data); - } - - /** - * Returns a new MetricData wih a {@link MetricDataType#LONG_GAUGE} type. - * - * @return a new MetricData wih a {@link MetricDataType#LONG_GAUGE} type. - */ - static MetricData createLongGauge( - Resource resource, - InstrumentationLibraryInfo instrumentationLibraryInfo, - String name, - String description, - String unit, - GaugeData data) { - return MetricDataImpl.create( - resource, - instrumentationLibraryInfo, - name, - description, - unit, - MetricDataType.LONG_GAUGE, - data); - } - - /** - * Returns a new MetricData wih a {@link MetricDataType#DOUBLE_SUM} type. - * - * @return a new MetricData wih a {@link MetricDataType#DOUBLE_SUM} type. - */ - static MetricData createDoubleSum( - Resource resource, - InstrumentationLibraryInfo instrumentationLibraryInfo, - String name, - String description, - String unit, - SumData data) { - return MetricDataImpl.create( - resource, - instrumentationLibraryInfo, - name, - description, - unit, - MetricDataType.DOUBLE_SUM, - data); - } - - /** - * Returns a new MetricData wih a {@link MetricDataType#LONG_SUM} type. - * - * @return a new MetricData wih a {@link MetricDataType#LONG_SUM} type. - */ - static MetricData createLongSum( - Resource resource, - InstrumentationLibraryInfo instrumentationLibraryInfo, - String name, - String description, - String unit, - SumData data) { - return MetricDataImpl.create( - resource, - instrumentationLibraryInfo, - name, - description, - unit, - MetricDataType.LONG_SUM, - data); - } - - /** - * Returns a new MetricData wih a {@link MetricDataType#SUMMARY} type. - * - * @return a new MetricData wih a {@link MetricDataType#SUMMARY} type. - */ - static MetricData createDoubleSummary( - Resource resource, - InstrumentationLibraryInfo instrumentationLibraryInfo, - String name, - String description, - String unit, - SummaryData data) { - return MetricDataImpl.create( - resource, - instrumentationLibraryInfo, - name, - description, - unit, - MetricDataType.SUMMARY, - data); - } - - /** - * Returns a new MetricData with a {@link MetricDataType#HISTOGRAM} type. - * - * @return a new MetricData wih a {@link MetricDataType#HISTOGRAM} type. - */ - static MetricData createDoubleHistogram( - Resource resource, - InstrumentationLibraryInfo instrumentationLibraryInfo, - String name, - String description, - String unit, - HistogramData data) { - return MetricDataImpl.create( - resource, - instrumentationLibraryInfo, - name, - description, - unit, - MetricDataType.HISTOGRAM, - data); - } - - /** - * Returns a new MetricData with a {@link MetricDataType#EXPONENTIAL_HISTOGRAM} type. - * - * @return a new MetricData wih a {@link MetricDataType#EXPONENTIAL_HISTOGRAM} type. - */ - static MetricData createExponentialHistogram( - Resource resource, - InstrumentationLibraryInfo instrumentationLibraryInfo, - String name, - String description, - String unit, - ExponentialHistogramData data) { - return MetricDataImpl.create( - resource, - instrumentationLibraryInfo, - name, - description, - unit, - MetricDataType.EXPONENTIAL_HISTOGRAM, - data); - } - /** * Returns the resource of this {@code MetricData}. * diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/data/MetricDataImpl.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/data/MetricDataImpl.java deleted file mode 100644 index c0494431fa3..00000000000 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/data/MetricDataImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.sdk.metrics.data; - -import com.google.auto.value.AutoValue; -import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; -import io.opentelemetry.sdk.resources.Resource; -import javax.annotation.concurrent.Immutable; - -@Immutable -@AutoValue -abstract class MetricDataImpl implements MetricData { - - MetricDataImpl() {} - - static MetricDataImpl create( - Resource resource, - InstrumentationLibraryInfo instrumentationLibraryInfo, - String name, - String description, - String unit, - MetricDataType type, - Data data) { - return new AutoValue_MetricDataImpl( - resource, instrumentationLibraryInfo, name, description, unit, type, data); - } -} diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleExponentialHistogramAggregator.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleExponentialHistogramAggregator.java index 0a79f21a12a..ea8c0f48dda 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleExponentialHistogramAggregator.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleExponentialHistogramAggregator.java @@ -11,6 +11,7 @@ import io.opentelemetry.sdk.metrics.data.ExemplarData; import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.metrics.exemplar.ExemplarReservoir; +import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData; import io.opentelemetry.sdk.metrics.internal.data.exponentialhistogram.ExponentialHistogramData; import io.opentelemetry.sdk.metrics.internal.descriptor.MetricDescriptor; import io.opentelemetry.sdk.metrics.internal.state.ExponentialCounterFactory; @@ -126,7 +127,7 @@ public MetricData toMetricData( long startEpochNanos, long lastCollectionEpoch, long epochNanos) { - return MetricData.createExponentialHistogram( + return ImmutableMetricData.createExponentialHistogram( resource, instrumentationLibrary, metricDescriptor.getName(), diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleHistogramAggregator.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleHistogramAggregator.java index d5f94d743ee..db710ec0b47 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleHistogramAggregator.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleHistogramAggregator.java @@ -13,6 +13,7 @@ import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.metrics.exemplar.ExemplarReservoir; import io.opentelemetry.sdk.metrics.internal.data.ImmutableHistogramData; +import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData; import io.opentelemetry.sdk.metrics.internal.descriptor.MetricDescriptor; import io.opentelemetry.sdk.resources.Resource; import java.util.ArrayList; @@ -98,7 +99,7 @@ public MetricData toMetricData( long startEpochNanos, long lastCollectionEpoch, long epochNanos) { - return MetricData.createDoubleHistogram( + return ImmutableMetricData.createDoubleHistogram( resource, instrumentationLibraryInfo, metricDescriptor.getName(), diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleLastValueAggregator.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleLastValueAggregator.java index 5503214de36..f20c56c9f81 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleLastValueAggregator.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleLastValueAggregator.java @@ -12,6 +12,7 @@ import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.metrics.exemplar.ExemplarReservoir; import io.opentelemetry.sdk.metrics.internal.data.ImmutableGaugeData; +import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData; import io.opentelemetry.sdk.metrics.internal.descriptor.MetricDescriptor; import io.opentelemetry.sdk.resources.Resource; import java.util.List; @@ -67,7 +68,7 @@ public MetricData toMetricData( long epochNanos) { // Gauge does not need a start time, but we send one as advised by the data model // for identifying resets. - return MetricData.createDoubleGauge( + return ImmutableMetricData.createDoubleGauge( resource, instrumentationLibraryInfo, descriptor.getName(), diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleSumAggregator.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleSumAggregator.java index a339e03b9dd..371040f5eb0 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleSumAggregator.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleSumAggregator.java @@ -14,6 +14,7 @@ import io.opentelemetry.sdk.metrics.exemplar.ExemplarReservoir; import io.opentelemetry.sdk.metrics.internal.concurrent.AdderUtil; import io.opentelemetry.sdk.metrics.internal.concurrent.DoubleAdder; +import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData; import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData; import io.opentelemetry.sdk.metrics.internal.descriptor.InstrumentDescriptor; import io.opentelemetry.sdk.metrics.internal.descriptor.MetricDescriptor; @@ -79,7 +80,7 @@ public MetricData toMetricData( long startEpochNanos, long lastCollectionEpoch, long epochNanos) { - return MetricData.createDoubleSum( + return ImmutableMetricData.createDoubleSum( resource, instrumentationLibraryInfo, descriptor.getName(), diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregator.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregator.java index 613c0f65552..89db5d77125 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregator.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregator.java @@ -12,6 +12,7 @@ import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.metrics.exemplar.ExemplarReservoir; import io.opentelemetry.sdk.metrics.internal.data.ImmutableGaugeData; +import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData; import io.opentelemetry.sdk.metrics.internal.descriptor.MetricDescriptor; import io.opentelemetry.sdk.resources.Resource; import java.util.List; @@ -64,7 +65,7 @@ public MetricData toMetricData( long lastCollectionEpoch, long epochNanos) { // Last-Value ignores temporality generally, but we can set a start time on the gauge. - return MetricData.createLongGauge( + return ImmutableMetricData.createLongGauge( resource, instrumentationLibraryInfo, descriptor.getName(), diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongSumAggregator.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongSumAggregator.java index 013d570b49d..1509b46d7be 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongSumAggregator.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongSumAggregator.java @@ -13,6 +13,7 @@ import io.opentelemetry.sdk.metrics.exemplar.ExemplarReservoir; import io.opentelemetry.sdk.metrics.internal.concurrent.AdderUtil; import io.opentelemetry.sdk.metrics.internal.concurrent.LongAdder; +import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData; import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData; import io.opentelemetry.sdk.metrics.internal.descriptor.InstrumentDescriptor; import io.opentelemetry.sdk.metrics.internal.descriptor.MetricDescriptor; @@ -66,7 +67,7 @@ public MetricData toMetricData( long startEpochNanos, long lastCollectionEpoch, long epochNanos) { - return MetricData.createLongSum( + return ImmutableMetricData.createLongSum( resource, instrumentationLibraryInfo, descriptor.getName(), diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/data/ImmutableMetricData.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/data/ImmutableMetricData.java new file mode 100644 index 00000000000..22eb75c8b2f --- /dev/null +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/data/ImmutableMetricData.java @@ -0,0 +1,201 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.metrics.internal.data; + +import com.google.auto.value.AutoValue; +import io.opentelemetry.sdk.common.InstrumentationLibraryInfo; +import io.opentelemetry.sdk.metrics.data.Data; +import io.opentelemetry.sdk.metrics.data.DoublePointData; +import io.opentelemetry.sdk.metrics.data.GaugeData; +import io.opentelemetry.sdk.metrics.data.HistogramData; +import io.opentelemetry.sdk.metrics.data.LongPointData; +import io.opentelemetry.sdk.metrics.data.MetricData; +import io.opentelemetry.sdk.metrics.data.MetricDataType; +import io.opentelemetry.sdk.metrics.data.SumData; +import io.opentelemetry.sdk.metrics.data.SummaryData; +import io.opentelemetry.sdk.metrics.internal.data.exponentialhistogram.ExponentialHistogramData; +import io.opentelemetry.sdk.resources.Resource; +import javax.annotation.concurrent.Immutable; + +/** + * A container of metrics. + * + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. + */ +@Immutable +@AutoValue +public abstract class ImmutableMetricData implements MetricData { + + /** + * Returns a new MetricData wih a {@link MetricDataType#DOUBLE_GAUGE} type. + * + * @return a new MetricData wih a {@link MetricDataType#DOUBLE_GAUGE} type. + */ + public static MetricData createDoubleGauge( + Resource resource, + InstrumentationLibraryInfo instrumentationLibraryInfo, + String name, + String description, + String unit, + GaugeData data) { + return create( + resource, + instrumentationLibraryInfo, + name, + description, + unit, + MetricDataType.DOUBLE_GAUGE, + data); + } + + /** + * Returns a new MetricData wih a {@link MetricDataType#LONG_GAUGE} type. + * + * @return a new MetricData wih a {@link MetricDataType#LONG_GAUGE} type. + */ + public static MetricData createLongGauge( + Resource resource, + InstrumentationLibraryInfo instrumentationLibraryInfo, + String name, + String description, + String unit, + GaugeData data) { + return create( + resource, + instrumentationLibraryInfo, + name, + description, + unit, + MetricDataType.LONG_GAUGE, + data); + } + + /** + * Returns a new MetricData wih a {@link MetricDataType#DOUBLE_SUM} type. + * + * @return a new MetricData wih a {@link MetricDataType#DOUBLE_SUM} type. + */ + public static MetricData createDoubleSum( + Resource resource, + InstrumentationLibraryInfo instrumentationLibraryInfo, + String name, + String description, + String unit, + SumData data) { + return create( + resource, + instrumentationLibraryInfo, + name, + description, + unit, + MetricDataType.DOUBLE_SUM, + data); + } + + /** + * Returns a new MetricData wih a {@link MetricDataType#LONG_SUM} type. + * + * @return a new MetricData wih a {@link MetricDataType#LONG_SUM} type. + */ + public static MetricData createLongSum( + Resource resource, + InstrumentationLibraryInfo instrumentationLibraryInfo, + String name, + String description, + String unit, + SumData data) { + return create( + resource, + instrumentationLibraryInfo, + name, + description, + unit, + MetricDataType.LONG_SUM, + data); + } + + /** + * Returns a new MetricData wih a {@link MetricDataType#SUMMARY} type. + * + * @return a new MetricData wih a {@link MetricDataType#SUMMARY} type. + */ + public static MetricData createDoubleSummary( + Resource resource, + InstrumentationLibraryInfo instrumentationLibraryInfo, + String name, + String description, + String unit, + SummaryData data) { + return create( + resource, + instrumentationLibraryInfo, + name, + description, + unit, + MetricDataType.SUMMARY, + data); + } + + /** + * Returns a new MetricData with a {@link MetricDataType#HISTOGRAM} type. + * + * @return a new MetricData wih a {@link MetricDataType#HISTOGRAM} type. + */ + public static MetricData createDoubleHistogram( + Resource resource, + InstrumentationLibraryInfo instrumentationLibraryInfo, + String name, + String description, + String unit, + HistogramData data) { + return create( + resource, + instrumentationLibraryInfo, + name, + description, + unit, + MetricDataType.HISTOGRAM, + data); + } + + /** + * Returns a new MetricData with a {@link MetricDataType#EXPONENTIAL_HISTOGRAM} type. + * + * @return a new MetricData wih a {@link MetricDataType#EXPONENTIAL_HISTOGRAM} type. + */ + public static MetricData createExponentialHistogram( + Resource resource, + InstrumentationLibraryInfo instrumentationLibraryInfo, + String name, + String description, + String unit, + ExponentialHistogramData data) { + return create( + resource, + instrumentationLibraryInfo, + name, + description, + unit, + MetricDataType.EXPONENTIAL_HISTOGRAM, + data); + } + + // Visible for testing + static ImmutableMetricData create( + Resource resource, + InstrumentationLibraryInfo instrumentationLibraryInfo, + String name, + String description, + String unit, + MetricDataType type, + Data data) { + return new AutoValue_ImmutableMetricData( + resource, instrumentationLibraryInfo, name, description, unit, type, data); + } + + ImmutableMetricData() {} +} diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/data/MetricDataImplTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/data/ImmutableMetricDataTest.java similarity index 95% rename from sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/data/MetricDataImplTest.java rename to sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/data/ImmutableMetricDataTest.java index a697701751c..346e4249c71 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/data/MetricDataImplTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/data/ImmutableMetricDataTest.java @@ -17,6 +17,7 @@ import io.opentelemetry.sdk.metrics.internal.data.ImmutableHistogramData; import io.opentelemetry.sdk.metrics.internal.data.ImmutableHistogramPointData; 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; @@ -28,7 +29,7 @@ import org.junit.jupiter.api.Test; /** Unit tests for {@link io.opentelemetry.sdk.metrics.data.MetricData}. */ -class MetricDataImplTest { +class ImmutableMetricDataTest { private static final long START_EPOCH_NANOS = TimeUnit.MILLISECONDS.toNanos(1000); private static final long EPOCH_NANOS = TimeUnit.MILLISECONDS.toNanos(2000); private static final long LONG_VALUE = 10; @@ -66,7 +67,7 @@ class MetricDataImplTest { @Test void metricData_Getters() { MetricData metricData = - MetricData.createDoubleGauge( + ImmutableMetricData.createDoubleGauge( Resource.empty(), InstrumentationLibraryInfo.empty(), "metric_name", @@ -91,7 +92,7 @@ void metricData_LongPoints() { assertThat(LONG_POINT.getAttributes().get(KEY)).isEqualTo("value"); assertThat(LONG_POINT.getValue()).isEqualTo(LONG_VALUE); MetricData metricData = - MetricData.createLongGauge( + ImmutableMetricData.createLongGauge( Resource.empty(), InstrumentationLibraryInfo.empty(), "metric_name", @@ -101,7 +102,7 @@ void metricData_LongPoints() { assertThat(metricData.isEmpty()).isFalse(); assertThat(metricData.getLongGaugeData().getPoints()).containsExactly(LONG_POINT); metricData = - MetricData.createLongSum( + ImmutableMetricData.createLongSum( Resource.empty(), InstrumentationLibraryInfo.empty(), "metric_name", @@ -123,7 +124,7 @@ void metricData_DoublePoints() { assertThat(DOUBLE_POINT.getAttributes().get(KEY)).isEqualTo("value"); assertThat(DOUBLE_POINT.getValue()).isEqualTo(DOUBLE_VALUE); MetricData metricData = - MetricData.createDoubleGauge( + ImmutableMetricData.createDoubleGauge( Resource.empty(), InstrumentationLibraryInfo.empty(), "metric_name", @@ -133,7 +134,7 @@ void metricData_DoublePoints() { assertThat(metricData.isEmpty()).isFalse(); assertThat(metricData.getDoubleGaugeData().getPoints()).containsExactly(DOUBLE_POINT); metricData = - MetricData.createDoubleSum( + ImmutableMetricData.createDoubleSum( Resource.empty(), InstrumentationLibraryInfo.empty(), "metric_name", @@ -157,7 +158,7 @@ void metricData_SummaryPoints() { assertThat(SUMMARY_POINT.getSum()).isEqualTo(DOUBLE_VALUE); assertThat(SUMMARY_POINT.getValues()).isEqualTo(Arrays.asList(MINIMUM_VALUE, MAXIMUM_VALUE)); MetricData metricData = - MetricData.createDoubleSummary( + ImmutableMetricData.createDoubleSummary( Resource.empty(), InstrumentationLibraryInfo.empty(), "metric_name", @@ -179,7 +180,7 @@ void metricData_HistogramPoints() { assertThat(HISTOGRAM_POINT.getCounts()).isEqualTo(ImmutableList.of(1L, 1L)); MetricData metricData = - MetricData.createDoubleHistogram( + ImmutableMetricData.createDoubleHistogram( Resource.empty(), InstrumentationLibraryInfo.empty(), "metric_name", @@ -219,7 +220,7 @@ void metricData_HistogramPoints() { @Test void metricData_GetDefault() { MetricData metricData = - MetricData.createDoubleSummary( + ImmutableMetricData.createDoubleSummary( Resource.empty(), InstrumentationLibraryInfo.empty(), "metric_name", @@ -234,7 +235,7 @@ void metricData_GetDefault() { assertThat(metricData.getHistogramData().getPoints()).isEmpty(); metricData = - MetricData.createDoubleGauge( + ImmutableMetricData.createDoubleGauge( Resource.empty(), InstrumentationLibraryInfo.empty(), "metric_name", diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/export/PeriodicMetricReaderTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/export/PeriodicMetricReaderTest.java index 316e412dcb6..78385104ef2 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/export/PeriodicMetricReaderTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/export/PeriodicMetricReaderTest.java @@ -22,6 +22,7 @@ import io.opentelemetry.sdk.metrics.data.LongPointData; 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; @@ -53,7 +54,7 @@ class PeriodicMetricReaderTest { ImmutableLongPointData.create(1000, 3000, Attributes.empty(), 1234567)); private static final MetricData METRIC_DATA = - MetricData.createLongSum( + ImmutableMetricData.createLongSum( Resource.empty(), InstrumentationLibraryInfo.create("IntervalMetricReaderTest", null), "my metric", diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregatorTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregatorTest.java index d132486ce31..d5cffff6671 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregatorTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregatorTest.java @@ -19,6 +19,7 @@ import io.opentelemetry.sdk.metrics.internal.data.ImmutableGaugeData; 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.descriptor.MetricDescriptor; import io.opentelemetry.sdk.resources.Resource; import java.util.Collections; @@ -114,7 +115,7 @@ void toMetricData() { 100); assertThat(metricData) .isEqualTo( - MetricData.createLongGauge( + ImmutableMetricData.createLongGauge( Resource.getDefault(), InstrumentationLibraryInfo.empty(), "name",