diff options
Diffstat (limited to 'impl_core')
9 files changed, 40 insertions, 29 deletions
diff --git a/impl_core/src/main/java/io/opencensus/implcore/stats/MutableViewData.java b/impl_core/src/main/java/io/opencensus/implcore/stats/MutableViewData.java index 559502bb..2c545aff 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/stats/MutableViewData.java +++ b/impl_core/src/main/java/io/opencensus/implcore/stats/MutableViewData.java @@ -62,6 +62,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import javax.annotation.Nullable; /** A mutable version of {@link ViewData}, used for recording stats and start/end time. */ abstract class MutableViewData { @@ -69,7 +70,8 @@ abstract class MutableViewData { private static final long MILLIS_PER_SECOND = 1000L; private static final long NANOS_PER_MILLI = 1000 * 1000; - @VisibleForTesting static final TagValue UNKNOWN_TAG_VALUE = null; + @Nullable @VisibleForTesting static final TagValue UNKNOWN_TAG_VALUE = null; + @VisibleForTesting static final Timestamp ZERO_TIMESTAMP = Timestamp.create(0, 0); private final View view; diff --git a/impl_core/src/main/java/io/opencensus/implcore/tags/CurrentTagContextUtils.java b/impl_core/src/main/java/io/opencensus/implcore/tags/CurrentTagContextUtils.java index 1a4ef81b..e6bb12f5 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/tags/CurrentTagContextUtils.java +++ b/impl_core/src/main/java/io/opencensus/implcore/tags/CurrentTagContextUtils.java @@ -20,7 +20,6 @@ import io.grpc.Context; import io.opencensus.common.Scope; import io.opencensus.tags.TagContext; import io.opencensus.tags.unsafe.ContextUtils; -import javax.annotation.Nullable; /** * Utility methods for accessing the {@link TagContext} contained in the {@link io.grpc.Context}. @@ -34,7 +33,6 @@ final class CurrentTagContextUtils { * * @return the {@code TagContext} from the current context. */ - @Nullable static TagContext getCurrentTagContext() { return ContextUtils.TAG_CONTEXT_KEY.get(); } diff --git a/impl_core/src/main/java/io/opencensus/implcore/tags/TagContextImpl.java b/impl_core/src/main/java/io/opencensus/implcore/tags/TagContextImpl.java index 177ce639..f7a8ff82 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/tags/TagContextImpl.java +++ b/impl_core/src/main/java/io/opencensus/implcore/tags/TagContextImpl.java @@ -25,6 +25,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; +import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; @Immutable @@ -50,7 +51,7 @@ public final class TagContextImpl extends TagContext { } @Override - public boolean equals(Object other) { + public boolean equals(@Nullable Object other) { // Directly compare the tags when both objects are TagContextImpls, for efficiency. if (other instanceof TagContextImpl) { return getTags().equals(((TagContextImpl) other).getTags()); diff --git a/impl_core/src/main/java/io/opencensus/implcore/trace/SpanBuilderImpl.java b/impl_core/src/main/java/io/opencensus/implcore/trace/SpanBuilderImpl.java index 80f904d6..45cf4261 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/trace/SpanBuilderImpl.java +++ b/impl_core/src/main/java/io/opencensus/implcore/trace/SpanBuilderImpl.java @@ -43,19 +43,19 @@ final class SpanBuilderImpl extends SpanBuilder { private final Options options; private final String name; - private final Span parent; - private final SpanContext remoteParentSpanContext; - private Sampler sampler; + @Nullable private final Span parent; + @Nullable private final SpanContext remoteParentSpanContext; + @Nullable private Sampler sampler; private List<Span> parentLinks = Collections.<Span>emptyList(); - private Boolean recordEvents; + @Nullable private Boolean recordEvents; private SpanImpl startSpanInternal( @Nullable SpanContext parent, @Nullable Boolean hasRemoteParent, String name, - Sampler sampler, + @Nullable Sampler sampler, List<Span> parentLinks, - Boolean recordEvents, + @Nullable Boolean recordEvents, @Nullable TimestampConverter timestampConverter) { TraceParams activeTraceParams = options.traceConfig.getActiveTraceParams(); Random random = options.randomHandler.current(); diff --git a/impl_core/src/main/java/io/opencensus/implcore/trace/SpanImpl.java b/impl_core/src/main/java/io/opencensus/implcore/trace/SpanImpl.java index 11d81747..c0682603 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/trace/SpanImpl.java +++ b/impl_core/src/main/java/io/opencensus/implcore/trace/SpanImpl.java @@ -55,9 +55,9 @@ public final class SpanImpl extends Span implements Element<SpanImpl> { private static final Logger logger = Logger.getLogger(Tracer.class.getName()); // The parent SpanId of this span. Null if this is a root span. - private final SpanId parentSpanId; + @Nullable private final SpanId parentSpanId; // True if the parent is on a different process. - private final Boolean hasRemoteParent; + @Nullable private final Boolean hasRemoteParent; // Active trace params when the Span was created. private final TraceParams traceParams; // Handler called when the span starts and ends. @@ -68,24 +68,29 @@ public final class SpanImpl extends Span implements Element<SpanImpl> { private final Clock clock; // The time converter used to convert nano time to Timestamp. This is needed because Java has // millisecond granularity for Timestamp and tracing events are recorded more often. - private final TimestampConverter timestampConverter; + @Nullable private final TimestampConverter timestampConverter; // The start time of the span. Set when the span is created iff the RECORD_EVENTS options is // set, otherwise 0. private final long startNanoTime; // Set of recorded attributes. DO NOT CALL any other method that changes the ordering of events. @GuardedBy("this") + @Nullable private AttributesWithCapacity attributes; // List of recorded annotations. @GuardedBy("this") + @Nullable private TraceEvents<EventWithNanoTime<Annotation>> annotations; // List of recorded network events. @GuardedBy("this") + @Nullable private TraceEvents<EventWithNanoTime<NetworkEvent>> networkEvents; // List of recorded links to parent and child spans. @GuardedBy("this") + @Nullable private TraceEvents<Link> links; // The status of the span. Set when the span is ended iff the RECORD_EVENTS options is set. @GuardedBy("this") + @Nullable private Status status; // The end time of the span. Set when the span is ended iff the RECORD_EVENTS options is set, // otherwise 0. @@ -99,8 +104,8 @@ public final class SpanImpl extends Span implements Element<SpanImpl> { private boolean sampleToLocalSpanStore; // Pointers for the ConcurrentIntrusiveList$Element. Guarded by the ConcurrentIntrusiveList. - private SpanImpl next = null; - private SpanImpl prev = null; + @Nullable private SpanImpl next = null; + @Nullable private SpanImpl prev = null; /** * Creates and starts a span with the given configuration. @@ -424,7 +429,7 @@ public final class SpanImpl extends Span implements Element<SpanImpl> { } private static <T> SpanData.TimedEvents<T> createTimedEvents( - TraceEvents<EventWithNanoTime<T>> events, TimestampConverter timestampConverter) { + TraceEvents<EventWithNanoTime<T>> events, @Nullable TimestampConverter timestampConverter) { if (events == null) { return SpanData.TimedEvents.create(Collections.<TimedEvent<T>>emptyList(), 0); } @@ -436,22 +441,24 @@ public final class SpanImpl extends Span implements Element<SpanImpl> { } @Override + @Nullable public SpanImpl getNext() { return next; } @Override - public void setNext(SpanImpl element) { + public void setNext(@Nullable SpanImpl element) { next = element; } @Override + @Nullable public SpanImpl getPrev() { return prev; } @Override - public void setPrev(SpanImpl element) { + public void setPrev(@Nullable SpanImpl element) { prev = element; } diff --git a/impl_core/src/main/java/io/opencensus/implcore/trace/StartEndHandlerImpl.java b/impl_core/src/main/java/io/opencensus/implcore/trace/StartEndHandlerImpl.java index fdb6147c..e22a86bd 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/trace/StartEndHandlerImpl.java +++ b/impl_core/src/main/java/io/opencensus/implcore/trace/StartEndHandlerImpl.java @@ -33,8 +33,8 @@ import javax.annotation.concurrent.ThreadSafe; @ThreadSafe public final class StartEndHandlerImpl implements StartEndHandler { private final SpanExporterImpl spanExporter; - private final RunningSpanStoreImpl runningSpanStore; - private final SampledSpanStoreImpl sampledSpanStore; + @Nullable private final RunningSpanStoreImpl runningSpanStore; + @Nullable private final SampledSpanStoreImpl sampledSpanStore; private final EventQueue eventQueue; // true if any of (runningSpanStore OR sampledSpanStore) are different than null, which // means the spans with RECORD_EVENTS should be enqueued in the queue. @@ -78,7 +78,7 @@ public final class StartEndHandlerImpl implements StartEndHandler { // An EventQueue entry that records the start of the span event. private static final class SpanStartEvent implements EventQueue.Entry { private final SpanImpl span; - private final RunningSpanStoreImpl activeSpansExporter; + @Nullable private final RunningSpanStoreImpl activeSpansExporter; SpanStartEvent(SpanImpl span, @Nullable RunningSpanStoreImpl activeSpansExporter) { this.span = span; @@ -96,9 +96,9 @@ public final class StartEndHandlerImpl implements StartEndHandler { // An EventQueue entry that records the end of the span event. private static final class SpanEndEvent implements EventQueue.Entry { private final SpanImpl span; - private final RunningSpanStoreImpl runningSpanStore; + @Nullable private final RunningSpanStoreImpl runningSpanStore; private final SpanExporterImpl spanExporter; - private final SampledSpanStoreImpl sampledSpanStore; + @Nullable private final SampledSpanStoreImpl sampledSpanStore; SpanEndEvent( SpanImpl span, diff --git a/impl_core/src/main/java/io/opencensus/implcore/trace/export/ExportComponentImpl.java b/impl_core/src/main/java/io/opencensus/implcore/trace/export/ExportComponentImpl.java index 26c9004a..9f17039c 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/trace/export/ExportComponentImpl.java +++ b/impl_core/src/main/java/io/opencensus/implcore/trace/export/ExportComponentImpl.java @@ -30,8 +30,8 @@ public final class ExportComponentImpl extends ExportComponent { private static final Duration EXPORTER_SCHEDULE_DELAY = Duration.create(5, 0); private final SpanExporterImpl spanExporter; - private final RunningSpanStoreImpl runningSpanStore; - private final SampledSpanStoreImpl sampledSpanStore; + @Nullable private final RunningSpanStoreImpl runningSpanStore; + @Nullable private final SampledSpanStoreImpl sampledSpanStore; @Override public SpanExporterImpl getSpanExporter() { diff --git a/impl_core/src/main/java/io/opencensus/implcore/trace/export/SampledSpanStoreImpl.java b/impl_core/src/main/java/io/opencensus/implcore/trace/export/SampledSpanStoreImpl.java index 60b1433c..0fad80fb 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/trace/export/SampledSpanStoreImpl.java +++ b/impl_core/src/main/java/io/opencensus/implcore/trace/export/SampledSpanStoreImpl.java @@ -208,7 +208,7 @@ public final class SampledSpanStoreImpl extends SampledSpanStore { return errorBucketSummaries; } - private List<SpanImpl> getErrorSamples(CanonicalCode code, int maxSpansToReturn) { + private List<SpanImpl> getErrorSamples(@Nullable CanonicalCode code, int maxSpansToReturn) { ArrayList<SpanImpl> output = new ArrayList<SpanImpl>(maxSpansToReturn); if (code != null) { getErrorBucket(code).getSamples(maxSpansToReturn, output); diff --git a/impl_core/src/main/java/io/opencensus/implcore/trace/internal/ConcurrentIntrusiveList.java b/impl_core/src/main/java/io/opencensus/implcore/trace/internal/ConcurrentIntrusiveList.java index ef0b2664..a1210b00 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/trace/internal/ConcurrentIntrusiveList.java +++ b/impl_core/src/main/java/io/opencensus/implcore/trace/internal/ConcurrentIntrusiveList.java @@ -22,6 +22,7 @@ import io.opencensus.implcore.trace.internal.ConcurrentIntrusiveList.Element; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import javax.annotation.Nullable; import javax.annotation.concurrent.ThreadSafe; /** @@ -60,7 +61,7 @@ import javax.annotation.concurrent.ThreadSafe; @ThreadSafe public final class ConcurrentIntrusiveList<T extends Element<T>> { private int size = 0; - private T head = null; + @Nullable private T head = null; public ConcurrentIntrusiveList() {} @@ -151,6 +152,7 @@ public final class ConcurrentIntrusiveList<T extends Element<T>> { * * @return a reference to the next element in the list. */ + @Nullable T getNext(); /** @@ -158,13 +160,14 @@ public final class ConcurrentIntrusiveList<T extends Element<T>> { * * @param element the reference to the next element in the list. */ - void setNext(T element); + void setNext(@Nullable T element); /** * Returns a reference to the previous element in the list. * * @return a reference to the previous element in the list. */ + @Nullable T getPrev(); /** @@ -172,6 +175,6 @@ public final class ConcurrentIntrusiveList<T extends Element<T>> { * * @param element the reference to the previous element in the list. */ - void setPrev(T element); + void setPrev(@Nullable T element); } } |