diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/db/SqlStatementSanitizer.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/db/SqlStatementSanitizer.java index 5d553d1e0afd..cd50d557e563 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/db/SqlStatementSanitizer.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/db/SqlStatementSanitizer.java @@ -10,6 +10,7 @@ import io.opentelemetry.instrumentation.api.caching.Cache; import io.opentelemetry.instrumentation.api.internal.SupportabilityMetrics; +import org.checkerframework.checker.nullness.qual.Nullable; /** * This class is responsible for masking potentially sensitive parameters in SQL (and SQL-like) @@ -21,7 +22,7 @@ public final class SqlStatementSanitizer { private static final Cache sqlToStatementInfoCache = Cache.newBuilder().setMaximumSize(1000).build(); - public static SqlStatementInfo sanitize(String statement) { + public static SqlStatementInfo sanitize(@Nullable String statement) { if (!isStatementSanitizationEnabled() || statement == null) { return SqlStatementInfo.create(statement, null, null); } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java index 8ab2a1aafa03..5caa1900f3a9 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractor.java @@ -42,7 +42,8 @@ protected abstract void onEnd( * Sets the {@code value} with the given {@code key} to the {@link AttributesBuilder} if {@code * value} is not {@code null}. */ - protected static void set(AttributesBuilder attributes, AttributeKey key, T value) { + protected static void set( + AttributesBuilder attributes, AttributeKey key, @Nullable T value) { if (value != null) { attributes.put(key, value); } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/EndTimeExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/EndTimeExtractor.java index db1fabe1bf24..234b00e00c81 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/EndTimeExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/EndTimeExtractor.java @@ -6,6 +6,7 @@ package io.opentelemetry.instrumentation.api.instrumenter; import java.time.Instant; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Extractor of the end time of response processing. An {@link EndTimeExtractor} should always use @@ -16,5 +17,5 @@ public interface EndTimeExtractor { /** Returns the timestamp marking the end of the response processing. */ - Instant extract(RESPONSE response); + Instant extract(@Nullable RESPONSE response); } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/code/CodeSpanNameExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/code/CodeSpanNameExtractor.java index ac0cc835cd53..2e96c9026b93 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/code/CodeSpanNameExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/code/CodeSpanNameExtractor.java @@ -7,6 +7,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.tracer.ClassNames; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A helper {@link SpanNameExtractor} implementation for instrumentations that target specific Java @@ -37,7 +38,7 @@ public String extract(REQUEST request) { return className + "." + methodName; } - private static String defaultString(String s) { + private static String defaultString(@Nullable String s) { return s == null ? "" : s; } } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/RpcAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/RpcAttributesExtractor.java index 1adc4f71259c..8e1216918a61 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/RpcAttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/RpcAttributesExtractor.java @@ -30,7 +30,8 @@ protected final void onStart(AttributesBuilder attributes, REQUEST request) { } @Override - protected final void onEnd(AttributesBuilder attributes, REQUEST request, RESPONSE response) { + protected final void onEnd( + AttributesBuilder attributes, REQUEST request, @Nullable RESPONSE response) { // No response attributes } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/ContextPropagationDebug.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/ContextPropagationDebug.java index 6e51b2a76c8f..6d3b90d2a858 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/ContextPropagationDebug.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/ContextPropagationDebug.java @@ -12,6 +12,7 @@ import java.util.Iterator; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; +import org.checkerframework.checker.nullness.qual.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,6 +69,7 @@ public static void debugContextLeakIfEnabled() { } } + @Nullable private static List getPropagations(Context context) { return context.get(THREAD_PROPAGATION_LOCATIONS); }