diff --git a/dependencyManagement/build.gradle.kts b/dependencyManagement/build.gradle.kts index 11caefead..ded19dd39 100644 --- a/dependencyManagement/build.gradle.kts +++ b/dependencyManagement/build.gradle.kts @@ -2,7 +2,7 @@ plugins { `java-platform` } -val otelInstrumentationVersion = "2.25.0-alpha" +val otelInstrumentationVersion = "2.26.0-alpha" val semconvVersion = "1.40.0" javaPlatform { diff --git a/disk-buffering/build.gradle.kts b/disk-buffering/build.gradle.kts index 53ac9f242..d6360837a 100644 --- a/disk-buffering/build.gradle.kts +++ b/disk-buffering/build.gradle.kts @@ -16,7 +16,6 @@ val protos by configurations.creating dependencies { api("io.opentelemetry:opentelemetry-sdk") - implementation("io.opentelemetry:opentelemetry-api-incubator") implementation("io.opentelemetry:opentelemetry-exporter-otlp-common") compileOnly("com.google.auto.value:auto-value-annotations") annotationProcessor("com.google.auto.value:auto-value") diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/mapping/logs/models/LogRecordDataImpl.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/mapping/logs/models/LogRecordDataImpl.java index 3b3682b44..a9f77eb30 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/mapping/logs/models/LogRecordDataImpl.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/mapping/logs/models/LogRecordDataImpl.java @@ -8,17 +8,16 @@ import com.google.auto.value.AutoValue; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.Value; -import io.opentelemetry.api.incubator.common.ExtendedAttributes; import io.opentelemetry.api.logs.Severity; import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; import io.opentelemetry.sdk.logs.data.Body; -import io.opentelemetry.sdk.logs.data.internal.ExtendedLogRecordData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; import javax.annotation.Nullable; @AutoValue -public abstract class LogRecordDataImpl implements ExtendedLogRecordData { +public abstract class LogRecordDataImpl implements LogRecordData { public static Builder builder() { return new AutoValue_LogRecordDataImpl.Builder(); @@ -30,14 +29,6 @@ public Body getBody() { return valueBody == null ? Body.empty() : Body.string(valueBody.asString()); } - @Override - public ExtendedAttributes getExtendedAttributes() { - return ExtendedAttributes.builder().putAll(getAttributes()).build(); - } - - // It's only deprecated in the incubating interface for extended attributes, which are not yet - // supported in this module. - @SuppressWarnings("deprecation") @Override public abstract Attributes getAttributes(); diff --git a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/IntegrationTest.java b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/IntegrationTest.java index b93c9bfda..214f48ea0 100644 --- a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/IntegrationTest.java +++ b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/IntegrationTest.java @@ -43,6 +43,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.stream.Collectors; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -155,7 +156,7 @@ void verifyIntegration_defaultAutoDelete() throws InterruptedException { assertThat(storedSpans).hasSize(2); assertThat(storedLogs).hasSize(2); - assertThat(storedMetrics).hasSize(2); + assertThat(filterTestMetrics(storedMetrics)).hasSize(2); // Data is auto-deleted from disk assertDirectoryFileCount(spansDir, 0); @@ -198,7 +199,7 @@ void verifyIntegration_withoutAutoDelete() throws InterruptedException { assertThat(storedSpans).hasSize(2); assertThat(storedLogs).hasSize(2); - assertThat(storedMetrics).hasSize(2); + assertThat(filterTestMetrics(storedMetrics)).hasSize(2); // Data stays on disk assertDirectoryFileCount(spansDir, 2); @@ -253,7 +254,7 @@ void verifyIntegration_withoutAutoDelete_explicitRemove() throws InterruptedExce assertThat(storedSpans).hasSize(2); assertThat(storedLogs).hasSize(2); - assertThat(storedMetrics).hasSize(2); + assertThat(filterTestMetrics(storedMetrics)).hasSize(2); // Data explicitly cleared assertDirectoryFileCount(spansDir, 0); @@ -284,6 +285,23 @@ private void createMetric() { clearInvocations(metricCallback); } + private static final String TEST_METRIC_INSTRUMENTATION_SCOPE_NAME = "MetricInstrumentationScope"; + + /** + * Filters out upstream's self-instrumentation metrics (e.g. {@code + * otel.sdk.metric_reader.collection.duration}) that {@link PeriodicMetricReader} automatically + * records, returning only metrics from the test's instrumentation scope. + */ + private static List filterTestMetrics(List metrics) { + return metrics.stream() + .filter( + m -> + m.getInstrumentationScopeInfo() + .getName() + .equals(TEST_METRIC_INSTRUMENTATION_SCOPE_NAME)) + .collect(Collectors.toList()); + } + private static void assertDirectoryFileCount(File directory, int fileCount) { assertThat(directory).isDirectory(); assertThat(directory.listFiles()).hasSize(fileCount); diff --git a/noop-api/src/main/java/io/opentelemetry/contrib/noopapi/NoopTracerProvider.java b/noop-api/src/main/java/io/opentelemetry/contrib/noopapi/NoopTracerProvider.java index c707fd7e5..2eda98624 100644 --- a/noop-api/src/main/java/io/opentelemetry/contrib/noopapi/NoopTracerProvider.java +++ b/noop-api/src/main/java/io/opentelemetry/contrib/noopapi/NoopTracerProvider.java @@ -15,6 +15,7 @@ import io.opentelemetry.api.trace.TracerProvider; import io.opentelemetry.context.Context; import java.util.concurrent.TimeUnit; +import javax.annotation.Nullable; enum NoopTracerProvider implements TracerProvider { INSTANCE; @@ -62,7 +63,7 @@ public SpanBuilder addLink(SpanContext spanContext, Attributes attributes) { } @Override - public SpanBuilder setAttribute(String key, String value) { + public SpanBuilder setAttribute(String key, @Nullable String value) { return this; } @@ -82,7 +83,7 @@ public SpanBuilder setAttribute(String key, boolean value) { } @Override - public SpanBuilder setAttribute(AttributeKey key, T value) { + public SpanBuilder setAttribute(AttributeKey key, @Nullable T value) { return this; }