Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…y-java into deprecate-instrumentation-library
  • Loading branch information
jack-berg committed Mar 14, 2022
2 parents e4c175d + 26c0429 commit 9ef1f6c
Show file tree
Hide file tree
Showing 76 changed files with 981 additions and 803 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,
InstrumentationScopeInfo.create("instrumentation", "1", null),
"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,
InstrumentationScopeInfo.create("instrumentation2", "2", null),
"metric2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import io.opentelemetry.internal.testing.slf4j.SuppressLogger;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
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;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableValueAtPercentile;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableValueAtQuantile;
import io.opentelemetry.sdk.resources.Resource;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
Expand Down Expand Up @@ -63,7 +63,7 @@ void testExport() {
InstrumentationScopeInfo.create("manualInstrumentation", "1.0", null);
exporter.export(
Arrays.asList(
MetricData.createDoubleSummary(
ImmutableMetricData.createDoubleSummary(
resource,
instrumentationScopeInfo,
"measureOne",
Expand All @@ -78,9 +78,9 @@ void testExport() {
1010,
50000,
Arrays.asList(
ImmutableValueAtPercentile.create(0.0, 25),
ImmutableValueAtPercentile.create(100.0, 433)))))),
MetricData.createLongSum(
ImmutableValueAtQuantile.create(0.0, 25),
ImmutableValueAtQuantile.create(1.0, 433)))))),
ImmutableMetricData.createLongSum(
resource,
instrumentationScopeInfo,
"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,
instrumentationScopeInfo,
"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(),
InstrumentationScopeInfo.empty(),
"name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static SummaryDataPointMarshaler[] createRepeated(Collection<SummaryPointData> p

static SummaryDataPointMarshaler create(SummaryPointData point) {
ValueAtQuantileMarshaler[] quantileMarshalers =
ValueAtQuantileMarshaler.createRepeated(point.getPercentileValues());
ValueAtQuantileMarshaler.createRepeated(point.getValues());
KeyValueMarshaler[] attributeMarshalers =
KeyValueMarshaler.createRepeated(point.getAttributes());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize;
import io.opentelemetry.exporter.internal.marshal.Serializer;
import io.opentelemetry.proto.metrics.v1.internal.SummaryDataPoint;
import io.opentelemetry.sdk.metrics.data.ValueAtPercentile;
import io.opentelemetry.sdk.metrics.data.ValueAtQuantile;
import java.io.IOException;
import java.util.List;

final class ValueAtQuantileMarshaler extends MarshalerWithSize {
private final double quantile;
private final double value;

static ValueAtQuantileMarshaler[] createRepeated(List<ValueAtPercentile> values) {
static ValueAtQuantileMarshaler[] createRepeated(List<ValueAtQuantile> values) {
int numValues = values.size();
ValueAtQuantileMarshaler[] marshalers = new ValueAtQuantileMarshaler[numValues];
for (int i = 0; i < numValues; i++) {
Expand All @@ -26,8 +26,8 @@ static ValueAtQuantileMarshaler[] createRepeated(List<ValueAtPercentile> values)
return marshalers;
}

private static ValueAtQuantileMarshaler create(ValueAtPercentile value) {
return new ValueAtQuantileMarshaler(value.getPercentile() / 100.0, value.getValue());
private static ValueAtQuantileMarshaler create(ValueAtQuantile value) {
return new ValueAtQuantileMarshaler(value.getQuantile(), value.getValue());
}

private ValueAtQuantileMarshaler(double quantile, double value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,22 @@
import io.opentelemetry.proto.metrics.v1.SummaryDataPoint;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
import io.opentelemetry.sdk.metrics.data.DoubleExemplarData;
import io.opentelemetry.sdk.metrics.data.HistogramPointData;
import io.opentelemetry.sdk.metrics.data.LongExemplarData;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.data.PointData;
import io.opentelemetry.sdk.metrics.data.SummaryPointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableDoubleExemplarData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableDoublePointData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableGaugeData;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableHistogramData;
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;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableValueAtPercentile;
import io.opentelemetry.sdk.metrics.internal.data.ImmutableValueAtQuantile;
import io.opentelemetry.sdk.metrics.internal.data.exponentialhistogram.ExponentialHistogramBuckets;
import io.opentelemetry.sdk.metrics.internal.data.exponentialhistogram.ExponentialHistogramData;
import io.opentelemetry.sdk.metrics.internal.data.exponentialhistogram.ExponentialHistogramPointData;
Expand Down Expand Up @@ -92,7 +93,7 @@ void dataPoint_withDefaultValues() {
KV_ATTR,
0,
singletonList(
LongExemplarData.create(
ImmutableLongExemplarData.create(
Attributes.of(stringKey("test"), "value"),
2,
SpanContext.create(
Expand Down Expand Up @@ -134,7 +135,7 @@ void dataPoint_withDefaultValues() {
KV_ATTR,
0,
singletonList(
DoubleExemplarData.create(
ImmutableDoubleExemplarData.create(
Attributes.of(stringKey("test"), "value"),
2,
SpanContext.create(
Expand Down Expand Up @@ -180,7 +181,7 @@ void longDataPoints() {
KV_ATTR,
5,
singletonList(
LongExemplarData.create(
ImmutableLongExemplarData.create(
Attributes.of(stringKey("test"), "value"),
2,
SpanContext.create(
Expand Down Expand Up @@ -280,7 +281,7 @@ void summaryDataPoints() {
KV_ATTR,
5,
14.2,
singletonList(ImmutableValueAtPercentile.create(0.0, 1.1))))))
singletonList(ImmutableValueAtQuantile.create(0.0, 1.1))))))
.containsExactly(
SummaryDataPoint.newBuilder()
.setStartTimeUnixNano(123)
Expand Down Expand Up @@ -308,8 +309,8 @@ void summaryDataPoints() {
9,
18.3,
ImmutableList.of(
ImmutableValueAtPercentile.create(0.0, 1.1),
ImmutableValueAtPercentile.create(100.0, 20.3))))))
ImmutableValueAtQuantile.create(0.0, 1.1),
ImmutableValueAtQuantile.create(1.0, 20.3))))))
.containsExactly(
SummaryDataPoint.newBuilder()
.setStartTimeUnixNano(123)
Expand Down Expand Up @@ -353,7 +354,7 @@ void histogramDataPoints() {
ImmutableList.of(),
ImmutableList.of(7L),
ImmutableList.of(
DoubleExemplarData.create(
ImmutableDoubleExemplarData.create(
Attributes.of(stringKey("test"), "value"),
2,
SpanContext.create(
Expand Down Expand Up @@ -413,7 +414,7 @@ void exponentialHistogramDataPoints() {
456,
Attributes.of(stringKey("key"), "value"),
ImmutableList.of(
DoubleExemplarData.create(
ImmutableDoubleExemplarData.create(
Attributes.of(stringKey("test"), "value"),
2,
SpanContext.create(
Expand Down Expand Up @@ -462,7 +463,7 @@ void exponentialHistogramDataPoints() {
void toProtoMetric_monotonic() {
assertThat(
toProtoMetric(
MetricData.createLongSum(
ImmutableMetricData.createLongSum(
Resource.empty(),
InstrumentationScopeInfo.empty(),
"name",
Expand Down Expand Up @@ -497,7 +498,7 @@ void toProtoMetric_monotonic() {
.build());
assertThat(
toProtoMetric(
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
Resource.empty(),
InstrumentationScopeInfo.empty(),
"name",
Expand Down Expand Up @@ -536,7 +537,7 @@ void toProtoMetric_monotonic() {
void toProtoMetric_nonMonotonic() {
assertThat(
toProtoMetric(
MetricData.createLongSum(
ImmutableMetricData.createLongSum(
Resource.empty(),
InstrumentationScopeInfo.empty(),
"name",
Expand Down Expand Up @@ -571,7 +572,7 @@ void toProtoMetric_nonMonotonic() {
.build());
assertThat(
toProtoMetric(
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
Resource.empty(),
InstrumentationScopeInfo.empty(),
"name",
Expand Down Expand Up @@ -610,7 +611,7 @@ void toProtoMetric_nonMonotonic() {
void toProtoMetric_gauges() {
assertThat(
toProtoMetric(
MetricData.createLongGauge(
ImmutableMetricData.createLongGauge(
Resource.empty(),
InstrumentationScopeInfo.empty(),
"name",
Expand Down Expand Up @@ -641,7 +642,7 @@ void toProtoMetric_gauges() {
.build());
assertThat(
toProtoMetric(
MetricData.createDoubleGauge(
ImmutableMetricData.createDoubleGauge(
Resource.empty(),
InstrumentationScopeInfo.empty(),
"name",
Expand Down Expand Up @@ -676,7 +677,7 @@ void toProtoMetric_gauges() {
void toProtoMetric_summary() {
assertThat(
toProtoMetric(
MetricData.createDoubleSummary(
ImmutableMetricData.createDoubleSummary(
Resource.empty(),
InstrumentationScopeInfo.empty(),
"name",
Expand All @@ -691,8 +692,8 @@ void toProtoMetric_summary() {
5,
33d,
ImmutableList.of(
ImmutableValueAtPercentile.create(0, 1.1),
ImmutableValueAtPercentile.create(100.0, 20.3))))))))
ImmutableValueAtQuantile.create(0, 1.1),
ImmutableValueAtQuantile.create(1.0, 20.3))))))))
.isEqualTo(
Metric.newBuilder()
.setName("name")
Expand Down Expand Up @@ -731,7 +732,7 @@ void toProtoMetric_summary() {
void toProtoMetric_histogram() {
assertThat(
toProtoMetric(
MetricData.createDoubleHistogram(
ImmutableMetricData.createDoubleHistogram(
Resource.empty(),
InstrumentationScopeInfo.empty(),
"name",
Expand Down Expand Up @@ -777,7 +778,7 @@ void toProtoMetric_histogram() {
void toProtoMetric_exponentialHistogram() {
assertThat(
toProtoMetric(
MetricData.createExponentialHistogram(
ImmutableMetricData.createExponentialHistogram(
Resource.empty(),
InstrumentationScopeInfo.empty(),
"name",
Expand Down Expand Up @@ -882,7 +883,7 @@ void protoResourceMetrics() {
assertThat(
toProtoResourceMetrics(
ImmutableList.of(
MetricData.createDoubleSum(
ImmutableMetricData.createDoubleSum(
resource,
instrumentationScopeInfo,
"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,
instrumentationScopeInfo,
"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(),
instrumentationScopeInfo,
"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(),
InstrumentationScopeInfo.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(),
InstrumentationScopeInfo.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(),
InstrumentationScopeInfo.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(),
InstrumentationScopeInfo.empty(),
"name",
Expand Down
Loading

0 comments on commit 9ef1f6c

Please sign in to comment.