Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import javax.annotation.Nullable;

class ArrayBackedAttributesBuilder implements AttributesBuilder {
private final List<Object> data;
Expand Down Expand Up @@ -38,7 +37,7 @@ public <T> AttributesBuilder put(AttributeKey<Long> key, int value) {
}

@Override
public <T> AttributesBuilder put(AttributeKey<T> key, @Nullable T value) {
public <T> AttributesBuilder put(AttributeKey<T> key, T value) {
if (key == null || key.getKey().isEmpty() || value == null) {
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import javax.annotation.Nullable;

/** A builder of {@link Attributes} supporting an arbitrary number of key-value pairs. */
public interface AttributesBuilder {
Expand All @@ -40,7 +39,7 @@ public interface AttributesBuilder {
* Puts an {@link AttributeKey} with an associated value into this if the value is non-null.
* Providing a null value does not remove or unset previously set values.
*/
<T> AttributesBuilder put(AttributeKey<T> key, @Nullable T value);
<T> AttributesBuilder put(AttributeKey<T> key, T value);

/**
* Puts a String attribute into this if the value is non-null. Providing a null value does not
Expand All @@ -51,7 +50,7 @@ public interface AttributesBuilder {
*
* @return this Builder
*/
default AttributesBuilder put(String key, @Nullable String value) {
default AttributesBuilder put(String key, String value) {
return put(stringKey(key), value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import io.opentelemetry.context.Context;
import java.time.Instant;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;

class DefaultLogger implements Logger {

Expand Down Expand Up @@ -78,7 +77,7 @@ public LogRecordBuilder setBody(Value<?> body) {
}

@Override
public <T> LogRecordBuilder setAttribute(AttributeKey<T> key, @Nullable T value) {
public <T> LogRecordBuilder setAttribute(AttributeKey<T> key, T value) {
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import io.opentelemetry.context.Context;
import java.time.Instant;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;

/**
* Used to construct and emit log records from a {@link Logger}.
Expand Down Expand Up @@ -114,7 +113,7 @@ default LogRecordBuilder setAllAttributes(Attributes attributes) {
* @param value the value for this attribute.
* @return this.
*/
<T> LogRecordBuilder setAttribute(AttributeKey<T> key, @Nullable T value);
<T> LogRecordBuilder setAttribute(AttributeKey<T> key, T value);

/**
* Sets a String attribute on the {@code LogRecord}. If the {@code LogRecord} previously contained
Expand All @@ -130,7 +129,7 @@ default LogRecordBuilder setAllAttributes(Attributes attributes) {
* @return this.
* @since 1.48.0
*/
default LogRecordBuilder setAttribute(String key, @Nullable String value) {
default LogRecordBuilder setAttribute(String key, String value) {
return setAttribute(stringKey(key), value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

/**
Expand Down Expand Up @@ -43,7 +42,7 @@ private PropagatedSpan(SpanContext spanContext) {
}

@Override
public Span setAttribute(String key, @Nullable String value) {
public Span setAttribute(String key, String value) {
return this;
}

Expand All @@ -63,7 +62,7 @@ public Span setAttribute(String key, boolean value) {
}

@Override
public <T> Span setAttribute(AttributeKey<T> key, @Nullable T value) {
public <T> Span setAttribute(AttributeKey<T> key, T value) {
return this;
}

Expand Down
4 changes: 2 additions & 2 deletions api/all/src/main/java/io/opentelemetry/api/trace/Span.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static Span wrap(SpanContext spanContext) {
* @param value the value for this attribute.
* @return this.
*/
default Span setAttribute(String key, @Nullable String value) {
default Span setAttribute(String key, String value) {
return setAttribute(AttributeKey.stringKey(key), value);
}

Expand Down Expand Up @@ -158,7 +158,7 @@ default Span setAttribute(String key, boolean value) {
* @param value the value for this attribute.
* @return this.
*/
<T> Span setAttribute(AttributeKey<T> key, @Nullable T value);
<T> Span setAttribute(AttributeKey<T> key, T value);

/**
* Sets an attribute to the {@code Span}. If the {@code Span} previously contained a mapping for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nullable;
import org.junit.jupiter.api.Test;

/** Unit tests for {@link Attributes}s. */
Expand Down Expand Up @@ -566,7 +565,7 @@ public <T> AttributesBuilder put(AttributeKey<Long> key, int value) {
}

@Override
public <T> AttributesBuilder put(AttributeKey<T> key, @Nullable T value) {
public <T> AttributesBuilder put(AttributeKey<T> key, T value) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import io.opentelemetry.context.Context;
import java.time.Instant;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;

class ExtendedDefaultLogger implements ExtendedLogger {

Expand Down Expand Up @@ -52,7 +51,7 @@ public <T> ExtendedLogRecordBuilder setAttribute(ExtendedAttributeKey<T> key, T
}

@Override
public <T> ExtendedLogRecordBuilder setAttribute(AttributeKey<T> key, @Nullable T value) {
public <T> ExtendedLogRecordBuilder setAttribute(AttributeKey<T> key, T value) {
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import io.opentelemetry.context.Context;
import java.time.Instant;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;

/** Extended {@link LogRecordBuilder} with experimental APIs. */
public interface ExtendedLogRecordBuilder extends LogRecordBuilder {
Expand Down Expand Up @@ -120,7 +119,7 @@ default ExtendedLogRecordBuilder setAllAttributes(ExtendedAttributes attributes)
* attribute APIs.
*/
@Override
<T> ExtendedLogRecordBuilder setAttribute(AttributeKey<T> key, @Nullable T value);
<T> ExtendedLogRecordBuilder setAttribute(AttributeKey<T> key, T value);

/**
* Set an attribute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import io.opentelemetry.context.Scope;
import java.time.Instant;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;

/**
* Delegates <i>all</i> {@link Span} methods to some underlying Span via {@link
Expand Down Expand Up @@ -53,12 +52,12 @@ default boolean isRecording() {
}

@Override
default <T> Span setAttribute(AttributeKey<T> key, @Nullable T value) {
default <T> Span setAttribute(AttributeKey<T> key, T value) {
return getDelegate().setAttribute(key, value);
}

@Override
default Span setAttribute(String key, @Nullable String value) {
default Span setAttribute(String key, String value) {
return getDelegate().setAttribute(key, value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import java.util.EnumSet;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import javax.annotation.Nonnull;

final class OpenTelemetryNoRecordEventsSpanImpl extends Span
implements io.opentelemetry.api.trace.Span {
Expand Down Expand Up @@ -110,7 +110,7 @@ public void end(long timestamp, TimeUnit unit) {
}

@Override
public io.opentelemetry.api.trace.Span setAttribute(String key, @Nullable String value) {
public io.opentelemetry.api.trace.Span setAttribute(String key, @Nonnull String value) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I restored this despite it being inconsistent with the API, but I didn't want to make any additional changes on a PR that is essentially a revert.

return this;
}

Expand All @@ -130,7 +130,7 @@ public io.opentelemetry.api.trace.Span setAttribute(String key, boolean value) {
}

@Override
public <T> io.opentelemetry.api.trace.Span setAttribute(AttributeKey<T> key, @Nullable T value) {
public <T> io.opentelemetry.api.trace.Span setAttribute(AttributeKey<T> key, @Nonnull T value) {
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public <T> ExtendedSdkLogRecordBuilder setAttribute(ExtendedAttributeKey<T> key,
}

@Override
public <T> ExtendedSdkLogRecordBuilder setAttribute(AttributeKey<T> key, @Nullable T value) {
public <T> ExtendedSdkLogRecordBuilder setAttribute(AttributeKey<T> key, T value) {
if (key == null || key.getKey().isEmpty() || value == null) {
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public SdkLogRecordBuilder setBody(Value<?> value) {
}

@Override
public <T> SdkLogRecordBuilder setAttribute(AttributeKey<T> key, @Nullable T value) {
public <T> SdkLogRecordBuilder setAttribute(AttributeKey<T> key, T value) {
if (key == null || key.getKey().isEmpty() || value == null) {
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ AnchoredClock getClock() {
}

@Override
public <T> ReadWriteSpan setAttribute(AttributeKey<T> key, @Nullable T value) {
public <T> ReadWriteSpan setAttribute(AttributeKey<T> key, T value) {
if (key == null || key.getKey().isEmpty() || value == null) {
return this;
}
Expand Down
Loading