diff --git a/conventions/src/main/kotlin/otel.errorprone-conventions.gradle.kts b/conventions/src/main/kotlin/otel.errorprone-conventions.gradle.kts index d66ec3d6ac84..7fdb82eff87f 100644 --- a/conventions/src/main/kotlin/otel.errorprone-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.errorprone-conventions.gradle.kts @@ -112,6 +112,9 @@ tasks { // with older APIs. disable("InconsistentOverloads") + // lots of low level APIs use arrays + disable("AvoidObjectArrays") + if (name.contains("Jmh") || name.contains("Test")) { // Allow underscore in test-type method names disable("MemberName") diff --git a/dependencyManagement/build.gradle.kts b/dependencyManagement/build.gradle.kts index 0746730932b6..221b448bcce1 100644 --- a/dependencyManagement/build.gradle.kts +++ b/dependencyManagement/build.gradle.kts @@ -38,7 +38,7 @@ val DEPENDENCY_BOMS = listOf( val autoServiceVersion = "1.0.1" val autoValueVersion = "1.10.1" -val errorProneVersion = "2.16" +val errorProneVersion = "2.17.0" val byteBuddyVersion = "1.12.20" val asmVersion = "9.4" val jmhVersion = "1.36" diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/SpanLinksBuilder.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/SpanLinksBuilder.java index 328c138c1099..f87ffe4e678c 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/SpanLinksBuilder.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/SpanLinksBuilder.java @@ -5,6 +5,7 @@ package io.opentelemetry.instrumentation.api.instrumenter; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.trace.SpanBuilder; import io.opentelemetry.api.trace.SpanContext; @@ -19,6 +20,7 @@ public interface SpanLinksBuilder { * @return this. * @see SpanBuilder#addLink(SpanContext) */ + @CanIgnoreReturnValue SpanLinksBuilder addLink(SpanContext spanContext); /** @@ -29,5 +31,6 @@ public interface SpanLinksBuilder { * @return this. * @see SpanBuilder#addLink(SpanContext) */ + @CanIgnoreReturnValue SpanLinksBuilder addLink(SpanContext spanContext, Attributes attributes); } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/SpanStatusBuilder.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/SpanStatusBuilder.java index bc53432b487c..ff59a3c94f1b 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/SpanStatusBuilder.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/SpanStatusBuilder.java @@ -5,6 +5,7 @@ package io.opentelemetry.instrumentation.api.instrumenter; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.StatusCode; @@ -24,6 +25,7 @@ public interface SpanStatusBuilder { * @return this. * @see Span#setStatus(StatusCode) */ + @CanIgnoreReturnValue default SpanStatusBuilder setStatus(StatusCode statusCode) { return setStatus(statusCode, ""); } @@ -42,5 +44,6 @@ default SpanStatusBuilder setStatus(StatusCode statusCode) { * @return this. * @see Span#setStatus(StatusCode, String) */ + @CanIgnoreReturnValue SpanStatusBuilder setStatus(StatusCode statusCode, String description); } diff --git a/instrumentation/log4j/log4j-appender-2.17/library/src/main/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/OpenTelemetryAppender.java b/instrumentation/log4j/log4j-appender-2.17/library/src/main/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/OpenTelemetryAppender.java index 4f0e0d4275f3..a206423e6b67 100644 --- a/instrumentation/log4j/log4j-appender-2.17/library/src/main/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/OpenTelemetryAppender.java +++ b/instrumentation/log4j/log4j-appender-2.17/library/src/main/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/OpenTelemetryAppender.java @@ -7,6 +7,7 @@ import static java.util.Collections.emptyList; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import io.opentelemetry.api.logs.GlobalLoggerProvider; import io.opentelemetry.api.logs.LogRecordBuilder; import io.opentelemetry.instrumentation.log4j.appender.v2_17.internal.ContextDataAccessor; @@ -61,12 +62,14 @@ static class Builder> extends AbstractAppender.Builder * or removed in the future, so only enable this if you know you do not require attributes * filled by this instrumentation to be stable across versions. */ + @CanIgnoreReturnValue public B setCaptureExperimentalAttributes(boolean captureExperimentalAttributes) { this.captureExperimentalAttributes = captureExperimentalAttributes; return asBuilder(); } /** Sets whether log4j {@link MapMessage} attributes should be copied to logs. */ + @CanIgnoreReturnValue public B setCaptureMapMessageAttributes(boolean captureMapMessageAttributes) { this.captureMapMessageAttributes = captureMapMessageAttributes; return asBuilder(); @@ -77,12 +80,14 @@ public B setCaptureMapMessageAttributes(boolean captureMapMessageAttributes) { * * @param captureMarkerAttribute To enable or disable the marker attribute */ + @CanIgnoreReturnValue public B setCaptureMarkerAttribute(boolean captureMarkerAttribute) { this.captureMarkerAttribute = captureMarkerAttribute; return asBuilder(); } /** Configures the {@link ThreadContext} attributes that will be copied to logs. */ + @CanIgnoreReturnValue public B setCaptureContextDataAttributes(String captureContextDataAttributes) { this.captureContextDataAttributes = captureContextDataAttributes; return asBuilder(); diff --git a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/bootstrap/BootstrapPackagesBuilder.java b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/bootstrap/BootstrapPackagesBuilder.java index a34fe8c60a41..604321f5a858 100644 --- a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/bootstrap/BootstrapPackagesBuilder.java +++ b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/bootstrap/BootstrapPackagesBuilder.java @@ -5,6 +5,7 @@ package io.opentelemetry.javaagent.tooling.bootstrap; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Collection; /** @@ -21,6 +22,7 @@ public interface BootstrapPackagesBuilder { * * @return {@code this} */ + @CanIgnoreReturnValue BootstrapPackagesBuilder add(String classNameOrPrefix); /** @@ -29,5 +31,6 @@ public interface BootstrapPackagesBuilder { * * @return {@code this} */ + @CanIgnoreReturnValue BootstrapPackagesBuilder addAll(Collection classNamesOrPrefixes); } diff --git a/muzzle/src/test/java/io/opentelemetry/instrumentation/TestHelperClasses.java b/muzzle/src/test/java/io/opentelemetry/instrumentation/TestHelperClasses.java index b049d125b625..0b3338f802e3 100644 --- a/muzzle/src/test/java/io/opentelemetry/instrumentation/TestHelperClasses.java +++ b/muzzle/src/test/java/io/opentelemetry/instrumentation/TestHelperClasses.java @@ -45,7 +45,7 @@ public interface AnotherHelperInterface extends HelperInterface { Object clone(); - @SuppressWarnings("checkstyle:NoFinalizer") + @SuppressWarnings({"checkstyle:NoFinalizer", "Finalize"}) void finalize(); } diff --git a/muzzle/src/test/java/io/opentelemetry/test/AnotherTestInterface.java b/muzzle/src/test/java/io/opentelemetry/test/AnotherTestInterface.java index c8d7cd2e2019..29811a73a59b 100644 --- a/muzzle/src/test/java/io/opentelemetry/test/AnotherTestInterface.java +++ b/muzzle/src/test/java/io/opentelemetry/test/AnotherTestInterface.java @@ -18,6 +18,6 @@ public interface AnotherTestInterface extends TestInterface { Object clone(); - @SuppressWarnings("checkstyle:NoFinalizer") + @SuppressWarnings({"checkstyle:NoFinalizer", "Finalize"}) void finalize(); }