diff options
author | Kristen Kozak <sebright@google.com> | 2018-02-05 17:33:54 -0800 |
---|---|---|
committer | Kristen Kozak <sebright@google.com> | 2018-02-05 18:27:41 -0800 |
commit | 420201505eb0ae4e79e9dba65807ff7c1cf32714 (patch) | |
tree | 6c36a09615e0bc18deeb613714fcb475b36f84d6 /api/src/main/java/io/opencensus | |
parent | d853e3a2da22cbc8c5a6d5d18cee82a8bc344a4d (diff) | |
download | opencensus-java-420201505eb0ae4e79e9dba65807ff7c1cf32714.tar.gz |
Add '@since' Javadoc tag to all tracing APIs (issue #864).
This commit also adds missing Javadocs.
Diffstat (limited to 'api/src/main/java/io/opencensus')
30 files changed, 632 insertions, 61 deletions
diff --git a/api/src/main/java/io/opencensus/trace/Annotation.java b/api/src/main/java/io/opencensus/trace/Annotation.java index 3a893647..233968d3 100644 --- a/api/src/main/java/io/opencensus/trace/Annotation.java +++ b/api/src/main/java/io/opencensus/trace/Annotation.java @@ -24,7 +24,11 @@ import java.util.HashMap; import java.util.Map; import javax.annotation.concurrent.Immutable; -/** A text annotation with a set of attributes. */ +/** + * A text annotation with a set of attributes. + * + * @since 0.5 + */ @Immutable @AutoValue // Suppress Checker Framework warning about missing @Nullable in generated equals method. @@ -40,6 +44,7 @@ public abstract class Annotation { * @param description the text description of the {@code Annotation}. * @return a new {@code Annotation} with the given description. * @throws NullPointerException if {@code description} is {@code null}. + * @since 0.5 */ public static Annotation fromDescription(String description) { return new AutoValue_Annotation(description, EMPTY_ATTRIBUTES); @@ -52,6 +57,7 @@ public abstract class Annotation { * @param attributes the attributes of the {@code Annotation}. * @return a new {@code Annotation} with the given description and set of attributes. * @throws NullPointerException if {@code description} or {@code attributes} are {@code null}. + * @since 0.5 */ public static Annotation fromDescriptionAndAttributes( String description, Map<String, AttributeValue> attributes) { @@ -65,6 +71,7 @@ public abstract class Annotation { * Return the description of the {@code Annotation}. * * @return the description of the {@code Annotation}. + * @since 0.5 */ public abstract String getDescription(); @@ -72,6 +79,7 @@ public abstract class Annotation { * Return the attributes of the {@code Annotation}. * * @return the attributes of the {@code Annotation}. + * @since 0.5 */ public abstract Map<String, AttributeValue> getAttributes(); diff --git a/api/src/main/java/io/opencensus/trace/AttributeValue.java b/api/src/main/java/io/opencensus/trace/AttributeValue.java index 6c938bd6..ed59830e 100644 --- a/api/src/main/java/io/opencensus/trace/AttributeValue.java +++ b/api/src/main/java/io/opencensus/trace/AttributeValue.java @@ -25,6 +25,8 @@ import javax.annotation.concurrent.Immutable; /** * A class that represents all the possible values for an attribute. An attribute can have 3 types * of values: {@code String}, {@code Boolean} or {@code Long}. + * + * @since 0.5 */ @Immutable public abstract class AttributeValue { @@ -34,6 +36,7 @@ public abstract class AttributeValue { * @param stringValue The new value. * @return an {@code AttributeValue} with a string value. * @throws NullPointerException if {@code stringValue} is {@code null}. + * @since 0.5 */ public static AttributeValue stringAttributeValue(String stringValue) { return AttributeValueString.create(stringValue); @@ -44,6 +47,7 @@ public abstract class AttributeValue { * * @param booleanValue The new value. * @return an {@code AttributeValue} with a boolean value. + * @since 0.5 */ public static AttributeValue booleanAttributeValue(boolean booleanValue) { return AttributeValueBoolean.create(booleanValue); @@ -54,6 +58,7 @@ public abstract class AttributeValue { * * @param longValue The new value. * @return an {@code AttributeValue} with a long value. + * @since 0.5 */ public static AttributeValue longAttributeValue(long longValue) { return AttributeValueLong.create(longValue); @@ -73,6 +78,7 @@ public abstract class AttributeValue { * added after this {@code match} method was added to the API. See {@link * io.opencensus.common.Functions} for some common functions for handling unknown types. * @return the result of the function applied to the underlying value. + * @since 0.5 */ public abstract <T> T match( Function<? super String, T> stringFunction, diff --git a/api/src/main/java/io/opencensus/trace/BlankSpan.java b/api/src/main/java/io/opencensus/trace/BlankSpan.java index 0c35a885..0f11a034 100644 --- a/api/src/main/java/io/opencensus/trace/BlankSpan.java +++ b/api/src/main/java/io/opencensus/trace/BlankSpan.java @@ -24,10 +24,16 @@ import javax.annotation.concurrent.Immutable; * no {@code Span} implementation is available. All operations are no-op. * * <p>Used also to stop tracing, see {@link Tracer#withSpan}. + * + * @since 0.5 */ @Immutable public final class BlankSpan extends Span { - /** Singleton instance of this class. */ + /** + * Singleton instance of this class. + * + * @since 0.5 + */ public static final BlankSpan INSTANCE = new BlankSpan(); private BlankSpan() { diff --git a/api/src/main/java/io/opencensus/trace/EndSpanOptions.java b/api/src/main/java/io/opencensus/trace/EndSpanOptions.java index 5c46e06f..d9e31e63 100644 --- a/api/src/main/java/io/opencensus/trace/EndSpanOptions.java +++ b/api/src/main/java/io/opencensus/trace/EndSpanOptions.java @@ -25,6 +25,8 @@ import javax.annotation.concurrent.Immutable; /** * A class that enables overriding the default values used when ending a {@link Span}. Allows * overriding the {@link Status status}. + * + * @since 0.5 */ @Immutable @AutoValue @@ -32,13 +34,18 @@ import javax.annotation.concurrent.Immutable; @AutoValue.CopyAnnotations @SuppressWarnings("nullness") public abstract class EndSpanOptions { - /** The default {@code EndSpanOptions}. */ + /** + * The default {@code EndSpanOptions}. + * + * @since 0.5 + */ public static final EndSpanOptions DEFAULT = builder().build(); /** * Returns a new {@link Builder} with default options. * * @return a new {@code Builder} with default options. + * @since 0.5 */ public static Builder builder() { return new AutoValue_EndSpanOptions.Builder().setSampleToLocalSpanStore(false); @@ -55,6 +62,7 @@ public abstract class EndSpanOptions { * * @return {@code true} if the name of the {@code Span} should be registered to the {@code * io.opencensus.trace.export.SampledSpanStore}. + * @since 0.8 */ @ExperimentalApi public abstract boolean getSampleToLocalSpanStore(); @@ -66,11 +74,16 @@ public abstract class EndSpanOptions { * Span#setStatus(Status)} or the default {@link Status#OK} if no status was set. * * @return the status. + * @since 0.5 */ @Nullable public abstract Status getStatus(); - /** Builder class for {@link EndSpanOptions}. */ + /** + * Builder class for {@link EndSpanOptions}. + * + * @since 0.5 + */ @AutoValue.Builder public abstract static class Builder { /** @@ -80,6 +93,7 @@ public abstract class EndSpanOptions { * * @param status the status. * @return this. + * @since 0.5 */ public abstract Builder setStatus(Status status); @@ -96,6 +110,7 @@ public abstract class EndSpanOptions { * instead. * * @return this. + * @since 0.8 */ @ExperimentalApi public abstract Builder setSampleToLocalSpanStore(boolean sampleToLocalSpanStore); @@ -104,6 +119,7 @@ public abstract class EndSpanOptions { * Builds and returns a {@code EndSpanOptions} with the desired settings. * * @return a {@code EndSpanOptions} with the desired settings. + * @since 0.5 */ public abstract EndSpanOptions build(); diff --git a/api/src/main/java/io/opencensus/trace/Link.java b/api/src/main/java/io/opencensus/trace/Link.java index 77b17206..e877a010 100644 --- a/api/src/main/java/io/opencensus/trace/Link.java +++ b/api/src/main/java/io/opencensus/trace/Link.java @@ -30,6 +30,8 @@ import javax.annotation.concurrent.Immutable; * * <p>Used (for example) in batching operations, where a single batch handler processes multiple * requests from different traces. + * + * @since 0.5 */ @Immutable @AutoValue @@ -39,11 +41,23 @@ import javax.annotation.concurrent.Immutable; public abstract class Link { private static final Map<String, AttributeValue> EMPTY_ATTRIBUTES = Collections.emptyMap(); - /** The relationship with the linked {@code Span} relative to the current {@code Span}. */ + /** + * The relationship with the linked {@code Span} relative to the current {@code Span}. + * + * @since 0.5 + */ public enum Type { - /** When the linked {@code Span} is a child of the current {@code Span}. */ + /** + * When the linked {@code Span} is a child of the current {@code Span}. + * + * @since 0.5 + */ CHILD_LINKED_SPAN, - /** When the linked {@code Span} is a parent of the current {@code Span}. */ + /** + * When the linked {@code Span} is a parent of the current {@code Span}. + * + * @since 0.5 + */ PARENT_LINKED_SPAN } @@ -53,6 +67,7 @@ public abstract class Link { * @param context the context of the linked {@code Span}. * @param type the type of the relationship with the linked {@code Span}. * @return a new {@code Link}. + * @since 0.5 */ public static Link fromSpanContext(SpanContext context, Type type) { return new AutoValue_Link(context.getTraceId(), context.getSpanId(), type, EMPTY_ATTRIBUTES); @@ -65,6 +80,7 @@ public abstract class Link { * @param type the type of the relationship with the linked {@code Span}. * @param attributes the attributes of the {@code Link}. * @return a new {@code Link}. + * @since 0.5 */ public static Link fromSpanContext( SpanContext context, Type type, Map<String, AttributeValue> attributes) { @@ -79,6 +95,7 @@ public abstract class Link { * Returns the {@code TraceId}. * * @return the {@code TraceId}. + * @since 0.5 */ public abstract TraceId getTraceId(); @@ -86,6 +103,7 @@ public abstract class Link { * Returns the {@code SpanId}. * * @return the {@code SpanId} + * @since 0.5 */ public abstract SpanId getSpanId(); @@ -93,6 +111,7 @@ public abstract class Link { * Returns the {@code Type}. * * @return the {@code Type}. + * @since 0.5 */ public abstract Type getType(); @@ -100,6 +119,7 @@ public abstract class Link { * Returns the set of attributes. * * @return the set of attributes. + * @since 0.5 */ public abstract Map<String, AttributeValue> getAttributes(); diff --git a/api/src/main/java/io/opencensus/trace/NetworkEvent.java b/api/src/main/java/io/opencensus/trace/NetworkEvent.java index a38bbdb8..a8dfdb70 100644 --- a/api/src/main/java/io/opencensus/trace/NetworkEvent.java +++ b/api/src/main/java/io/opencensus/trace/NetworkEvent.java @@ -27,6 +27,8 @@ import javax.annotation.concurrent.Immutable; * A class that represents a network event. It requires a {@link Type type} and a message id that * serves to uniquely identify each network message. It can optionally can have information about * the kernel time and message size. + * + * @since 0.5 */ @Immutable @AutoValue @@ -34,11 +36,23 @@ import javax.annotation.concurrent.Immutable; @AutoValue.CopyAnnotations @SuppressWarnings("nullness") public abstract class NetworkEvent { - /** Available types for a {@code NetworkEvent}. */ + /** + * Available types for a {@code NetworkEvent}. + * + * @since 0.5 + */ public enum Type { - /** When the message was sent. */ + /** + * When the message was sent. + * + * @since 0.5 + */ SENT, - /** When the message was received. */ + /** + * When the message was received. + * + * @since 0.5 + */ RECV, } @@ -49,6 +63,7 @@ public abstract class NetworkEvent { * @param messageId serves to uniquely identify each network message. * @return a new {@code Builder} with default values. * @throws NullPointerException if {@code type} is {@code null}. + * @since 0.5 */ public static Builder builder(Type type, long messageId) { return new AutoValue_NetworkEvent.Builder() @@ -66,6 +81,7 @@ public abstract class NetworkEvent { * * @return the kernel timestamp associated with the {@code NetworkEvent} or {@code null} if not * set. + * @since 0.5 */ @Nullable public abstract Timestamp getKernelTimestamp(); @@ -74,6 +90,7 @@ public abstract class NetworkEvent { * Returns the type of the {@code NetworkEvent}. * * @return the type of the {@code NetworkEvent}. + * @since 0.5 */ public abstract Type getType(); @@ -81,6 +98,7 @@ public abstract class NetworkEvent { * Returns the message id argument that serves to uniquely identify each network message. * * @return the message id of the {@code NetworkEvent}. + * @since 0.5 */ public abstract long getMessageId(); @@ -88,6 +106,7 @@ public abstract class NetworkEvent { * Returns the uncompressed size in bytes of the {@code NetworkEvent}. * * @return the uncompressed size in bytes of the {@code NetworkEvent}. + * @since 0.6 */ public abstract long getUncompressedMessageSize(); @@ -95,19 +114,25 @@ public abstract class NetworkEvent { * Returns the compressed size in bytes of the {@code NetworkEvent}. * * @return the compressed size in bytes of the {@code NetworkEvent}. + * @since 0.6 */ public abstract long getCompressedMessageSize(); /** * @deprecated Use {@link #getUncompressedMessageSize}. * @return the uncompressed size in bytes of the {@code NetworkEvent}. + * @since 0.5 */ @Deprecated public long getMessageSize() { return getUncompressedMessageSize(); } - /** Builder class for {@link NetworkEvent}. */ + /** + * Builder class for {@link NetworkEvent}. + * + * @since 0.5 + */ @AutoValue.Builder public abstract static class Builder { // Package protected methods because these values are mandatory and set only in the @@ -121,6 +146,7 @@ public abstract class NetworkEvent { * * @param kernelTimestamp The kernel timestamp of the event. * @return this. + * @since 0.5 */ public abstract Builder setKernelTimestamp(@Nullable Timestamp kernelTimestamp); @@ -128,6 +154,7 @@ public abstract class NetworkEvent { * @deprecated Use {@link #setUncompressedMessageSize}. * @param messageSize represents the uncompressed size in bytes of this message. * @return this. + * @since 0.5 */ @Deprecated public Builder setMessageSize(long messageSize) { @@ -139,6 +166,7 @@ public abstract class NetworkEvent { * * @param uncompressedMessageSize represents the uncompressed size in bytes of this message. * @return this. + * @since 0.6 */ public abstract Builder setUncompressedMessageSize(long uncompressedMessageSize); @@ -147,6 +175,7 @@ public abstract class NetworkEvent { * * @param compressedMessageSize represents the compressed size in bytes of this message. * @return this. + * @since 0.6 */ public abstract Builder setCompressedMessageSize(long compressedMessageSize); @@ -154,6 +183,7 @@ public abstract class NetworkEvent { * Builds and returns a {@code NetworkEvent} with the desired values. * * @return a {@code NetworkEvent} with the desired values. + * @since 0.5 */ public abstract NetworkEvent build(); diff --git a/api/src/main/java/io/opencensus/trace/Sampler.java b/api/src/main/java/io/opencensus/trace/Sampler.java index e30b5fdd..e89af89b 100644 --- a/api/src/main/java/io/opencensus/trace/Sampler.java +++ b/api/src/main/java/io/opencensus/trace/Sampler.java @@ -19,7 +19,11 @@ package io.opencensus.trace; import java.util.List; import javax.annotation.Nullable; -/** Sampler is used to make decisions on {@link Span} sampling. */ +/** + * Sampler is used to make decisions on {@link Span} sampling. + * + * @since 0.5 + */ public abstract class Sampler { /** * Called during {@link Span} creation to make a sampling decision. @@ -34,6 +38,7 @@ public abstract class Sampler { * @param name the name of the new {@code Span}. * @param parentLinks the parentLinks associated with the new {@code Span}. * @return {@code true} if the {@code Span} is sampled. + * @since 0.5 */ public abstract boolean shouldSample( @Nullable SpanContext parentContext, @@ -50,6 +55,7 @@ public abstract class Sampler { * <p>Example: "ProbabilitySampler{0.000100}" * * @return the description of this {@code Sampler}. + * @since 0.6 */ public abstract String getDescription(); } diff --git a/api/src/main/java/io/opencensus/trace/Span.java b/api/src/main/java/io/opencensus/trace/Span.java index 16aac33f..29673930 100644 --- a/api/src/main/java/io/opencensus/trace/Span.java +++ b/api/src/main/java/io/opencensus/trace/Span.java @@ -32,6 +32,8 @@ import javax.annotation.Nullable; * <p>Spans are created by the {@link SpanBuilder#startSpan} method. * * <p>{@code Span} <b>must</b> be ended by calling {@link #end()} or {@link #end(EndSpanOptions)} + * + * @since 0.5 */ public abstract class Span { private static final Map<String, AttributeValue> EMPTY_ATTRIBUTES = Collections.emptyMap(); @@ -45,11 +47,15 @@ public abstract class Span { /** * {@code Span} options. These options are NOT propagated to child spans. These options determine * features such as whether a {@code Span} should record any annotations or events. + * + * @since 0.5 */ public enum Options { /** * This option is set if the Span is part of a sampled distributed trace OR {@link * SpanBuilder#setRecordEvents(boolean)} was called with true. + * + * @since 0.5 */ RECORD_EVENTS; } @@ -66,6 +72,7 @@ public abstract class Span { * @throws NullPointerException if context is {@code null}. * @throws IllegalArgumentException if the {@code SpanContext} is sampled but no RECORD_EVENTS * options. + * @since 0.5 */ protected Span(SpanContext context, @Nullable EnumSet<Options> options) { this.context = checkNotNull(context, "context"); @@ -84,6 +91,7 @@ public abstract class Span { * * @param key the key for this attribute. * @param value the value for this attribute. + * @since 0.6 */ public void putAttribute(String key, AttributeValue value) { // Not final because for performance reasons we want to override this in the implementation. @@ -98,6 +106,7 @@ public abstract class Span { * map. * * @param attributes the attributes that will be added and associated with the {@code Span}. + * @since 0.6 */ public void putAttributes(Map<String, AttributeValue> attributes) { // Not final because we want to start overriding this method from the beginning, this will @@ -108,6 +117,7 @@ public abstract class Span { /** * @deprecated Use {@link #putAttributes(Map)} * @param attributes the attributes that will be added and associated with the {@code Span}. + * @since 0.5 */ @Deprecated public void addAttributes(Map<String, AttributeValue> attributes) { @@ -118,6 +128,7 @@ public abstract class Span { * Adds an annotation to the {@code Span}. * * @param description the description of the annotation time event. + * @since 0.5 */ public final void addAnnotation(String description) { addAnnotation(description, EMPTY_ATTRIBUTES); @@ -129,6 +140,7 @@ public abstract class Span { * @param description the description of the annotation time event. * @param attributes the attributes that will be added; these are associated with this annotation, * not the {@code Span} as for {@link #putAttributes(Map)}. + * @since 0.5 */ public abstract void addAnnotation(String description, Map<String, AttributeValue> attributes); @@ -136,6 +148,7 @@ public abstract class Span { * Adds an annotation to the {@code Span}. * * @param annotation the annotations to add. + * @since 0.5 */ public abstract void addAnnotation(Annotation annotation); @@ -146,6 +159,7 @@ public abstract class Span { * higher level applications. * * @param networkEvent the network event to add. + * @since 0.5 */ public abstract void addNetworkEvent(NetworkEvent networkEvent); @@ -156,6 +170,7 @@ public abstract class Span { * requests from different traces. * * @param link the link to add. + * @since 0.5 */ public abstract void addLink(Link link); @@ -169,6 +184,7 @@ public abstract class Span { * will always be the last call. * * @param status the {@link Status} to set. + * @since 0.9 */ public void setStatus(Status status) { // Implemented as no-op for backwards compatibility (for example gRPC extends Span in tests). @@ -182,6 +198,7 @@ public abstract class Span { * implementations are free to ignore all further calls. * * @param options the options to be used for the end of the {@code Span}. + * @since 0.5 */ public abstract void end(EndSpanOptions options); @@ -190,6 +207,8 @@ public abstract class Span { * * <p>Only the timing of the first end call for a given {@code Span} will be recorded, and * implementations are free to ignore all further calls. + * + * @since 0.5 */ public final void end() { end(EndSpanOptions.DEFAULT); @@ -199,6 +218,7 @@ public abstract class Span { * Returns the {@code SpanContext} associated with this {@code Span}. * * @return the {@code SpanContext} associated with this {@code Span}. + * @since 0.5 */ public final SpanContext getContext() { return context; @@ -208,6 +228,7 @@ public abstract class Span { * Returns the options associated with this {@code Span}. * * @return the options associated with this {@code Span}. + * @since 0.5 */ public final Set<Options> getOptions() { return options; diff --git a/api/src/main/java/io/opencensus/trace/SpanBuilder.java b/api/src/main/java/io/opencensus/trace/SpanBuilder.java index 04c339ff..ee68d109 100644 --- a/api/src/main/java/io/opencensus/trace/SpanBuilder.java +++ b/api/src/main/java/io/opencensus/trace/SpanBuilder.java @@ -104,6 +104,8 @@ import javax.annotation.Nullable; * * <p>If your Java version is less than Java SE 7, see {@link SpanBuilder#startSpan} and {@link * SpanBuilder#startScopedSpan} for usage examples. + * + * @since 0.5 */ public abstract class SpanBuilder { @@ -112,6 +114,7 @@ public abstract class SpanBuilder { * * @param sampler The {@code Sampler} to use when determining sampling for a {@code Span}. * @return this. + * @since 0.5 */ public abstract SpanBuilder setSampler(Sampler sampler); @@ -123,6 +126,7 @@ public abstract class SpanBuilder { * @param parentLinks New links to be added. * @return this. * @throws NullPointerException if {@code parentLinks} is {@code null}. + * @since 0.5 */ public abstract SpanBuilder setParentLinks(List<Span> parentLinks); @@ -132,6 +136,7 @@ public abstract class SpanBuilder { * * @param recordEvents New value determining if this {@code Span} should have events recorded. * @return this. + * @since 0.5 */ public abstract SpanBuilder setRecordEvents(boolean recordEvents); @@ -162,6 +167,7 @@ public abstract class SpanBuilder { * }</pre> * * @return the newly created {@code Span}. + * @since 0.5 */ public abstract Span startSpan(); @@ -218,6 +224,7 @@ public abstract class SpanBuilder { * * @return an object that defines a scope where the newly created {@code Span} will be set to the * current Context. + * @since 0.5 */ @MustBeClosed public final Scope startScopedSpan() { diff --git a/api/src/main/java/io/opencensus/trace/SpanContext.java b/api/src/main/java/io/opencensus/trace/SpanContext.java index 6084c674..cdc74886 100644 --- a/api/src/main/java/io/opencensus/trace/SpanContext.java +++ b/api/src/main/java/io/opencensus/trace/SpanContext.java @@ -26,6 +26,8 @@ import javax.annotation.concurrent.Immutable; * child {@link Span}s and across process boundaries. It contains the identifiers (a {@link TraceId * trace_id} and {@link SpanId span_id}) associated with the {@link Span} and a set of {@link * TraceOptions options}. + * + * @since 0.5 */ @Immutable public final class SpanContext { @@ -33,7 +35,11 @@ public final class SpanContext { private final SpanId spanId; private final TraceOptions traceOptions; - /** The invalid {@code SpanContext}. */ + /** + * The invalid {@code SpanContext}. + * + * @since 0.5 + */ public static final SpanContext INVALID = new SpanContext(TraceId.INVALID, SpanId.INVALID, TraceOptions.DEFAULT); @@ -44,6 +50,7 @@ public final class SpanContext { * @param spanId the span identifier of the span context. * @param traceOptions the trace options for the span context. * @return a new {@code SpanContext} with the given identifiers and options. + * @since 0.5 */ public static SpanContext create(TraceId traceId, SpanId spanId, TraceOptions traceOptions) { return new SpanContext(traceId, spanId, traceOptions); @@ -53,6 +60,7 @@ public final class SpanContext { * Returns the trace identifier associated with this {@code SpanContext}. * * @return the trace identifier associated with this {@code SpanContext}. + * @since 0.5 */ public TraceId getTraceId() { return traceId; @@ -62,6 +70,7 @@ public final class SpanContext { * Returns the span identifier associated with this {@code SpanContext}. * * @return the span identifier associated with this {@code SpanContext}. + * @since 0.5 */ public SpanId getSpanId() { return spanId; @@ -71,6 +80,7 @@ public final class SpanContext { * Returns the trace options associated with this {@code SpanContext}. * * @return the trace options associated with this {@code SpanContext}. + * @since 0.5 */ public TraceOptions getTraceOptions() { return traceOptions; @@ -80,6 +90,7 @@ public final class SpanContext { * Returns true if this {@code SpanContext} is valid. * * @return true if this {@code SpanContext} is valid. + * @since 0.5 */ public boolean isValid() { return traceId.isValid() && spanId.isValid(); diff --git a/api/src/main/java/io/opencensus/trace/SpanId.java b/api/src/main/java/io/opencensus/trace/SpanId.java index 76747acf..eee5f497 100644 --- a/api/src/main/java/io/opencensus/trace/SpanId.java +++ b/api/src/main/java/io/opencensus/trace/SpanId.java @@ -29,13 +29,23 @@ import javax.annotation.concurrent.Immutable; /** * A class that represents a span identifier. A valid span identifier is an 8-byte array with at * least one non-zero byte. + * + * @since 0.5 */ @Immutable public final class SpanId implements Comparable<SpanId> { - /** The size in bytes of the {@code SpanId}. */ + /** + * The size in bytes of the {@code SpanId}. + * + * @since 0.5 + */ public static final int SIZE = 8; - /** The invalid {@code SpanId}. All bytes are 0. */ + /** + * The invalid {@code SpanId}. All bytes are 0. + * + * @since 0.5 + */ public static final SpanId INVALID = new SpanId(new byte[SIZE]); // The internal representation of the SpanId. @@ -58,6 +68,7 @@ public final class SpanId implements Comparable<SpanId> { * @return a {@code SpanId} whose representation is given by the {@code buffer} parameter. * @throws NullPointerException if {@code buffer} is null. * @throws IllegalArgumentException if {@code buffer.length} is not {@link SpanId#SIZE}. + * @since 0.5 */ public static SpanId fromBytes(byte[] buffer) { checkNotNull(buffer, "buffer"); @@ -77,6 +88,7 @@ public final class SpanId implements Comparable<SpanId> { * @throws NullPointerException if {@code src} is null. * @throws IndexOutOfBoundsException if {@code srcOffset+SpanId.SIZE} is greater than {@code * src.length}. + * @since 0.5 */ public static SpanId fromBytes(byte[] src, int srcOffset) { byte[] bytes = new byte[SIZE]; @@ -92,6 +104,7 @@ public final class SpanId implements Comparable<SpanId> { * @throws NullPointerException if {@code src} is null. * @throws IllegalArgumentException if {@code src.length} is not {@code 2 * SpanId.SIZE} OR if the * {@code str} has invalid characters. + * @since 0.11 */ public static SpanId fromLowerBase16(CharSequence src) { checkArgument( @@ -105,6 +118,7 @@ public final class SpanId implements Comparable<SpanId> { * * @param random The random number generator. * @return a valid new {@code SpanId}. + * @since 0.5 */ public static SpanId generateRandomId(Random random) { byte[] bytes = new byte[SIZE]; @@ -118,6 +132,7 @@ public final class SpanId implements Comparable<SpanId> { * Returns the byte representation of the {@code SpanId}. * * @return the byte representation of the {@code SpanId}. + * @since 0.5 */ public byte[] getBytes() { return Arrays.copyOf(bytes, SIZE); @@ -138,6 +153,7 @@ public final class SpanId implements Comparable<SpanId> { * @throws NullPointerException if {@code dest} is null. * @throws IndexOutOfBoundsException if {@code destOffset+SpanId.SIZE} is greater than {@code * dest.length}. + * @since 0.5 */ public void copyBytesTo(byte[] dest, int destOffset) { System.arraycopy(bytes, 0, dest, destOffset, SIZE); @@ -148,6 +164,7 @@ public final class SpanId implements Comparable<SpanId> { * at least one non-zero byte. * * @return {@code true} if the span identifier is valid. + * @since 0.5 */ public boolean isValid() { return !Arrays.equals(bytes, INVALID.bytes); @@ -157,6 +174,7 @@ public final class SpanId implements Comparable<SpanId> { * Returns the lowercase base16 encoding of this {@code SpanId}. * * @return the lowercase base16 encoding of this {@code SpanId}. + * @since 0.11 */ public String toLowerBase16() { return BaseEncoding.base16().lowerCase().encode(bytes); diff --git a/api/src/main/java/io/opencensus/trace/Status.java b/api/src/main/java/io/opencensus/trace/Status.java index f5a275bf..b8c6b7a1 100644 --- a/api/src/main/java/io/opencensus/trace/Status.java +++ b/api/src/main/java/io/opencensus/trace/Status.java @@ -38,18 +38,30 @@ import org.checkerframework.dataflow.qual.Deterministic; * the template for the appropriate {@link Status.CanonicalCode} and supplementing it with * additional information: {@code Status.NOT_FOUND.withDescription("Could not find * 'important_file.txt'");} + * + * @since 0.5 */ @Immutable public final class Status { /** * The set of canonical status codes. If new codes are added over time they must choose a * numerical value that does not collide with any previously used value. + * + * @since 0.5 */ public enum CanonicalCode { - /** The operation completed successfully. */ + /** + * The operation completed successfully. + * + * @since 0.5 + */ OK(0), - /** The operation was cancelled (typically by the caller). */ + /** + * The operation was cancelled (typically by the caller). + * + * @since 0.5 + */ CANCELLED(1), /** @@ -57,6 +69,8 @@ public final class Status { * from another address space belongs to an error-space that is not known in this address space. * Also errors raised by APIs that do not return enough error information may be converted to * this error. + * + * @since 0.5 */ UNKNOWN(2), @@ -64,6 +78,8 @@ public final class Status { * Client specified an invalid argument. Note that this differs from FAILED_PRECONDITION. * INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of the * system (e.g., a malformed file name). + * + * @since 0.5 */ INVALID_ARGUMENT(3), @@ -72,13 +88,23 @@ public final class Status { * system, this error may be returned even if the operation has completed successfully. For * example, a successful response from a server could have been delayed long enough for the * deadline to expire. + * + * @since 0.5 */ DEADLINE_EXCEEDED(4), - /** Some requested entity (e.g., file or directory) was not found. */ + /** + * Some requested entity (e.g., file or directory) was not found. + * + * @since 0.5 + */ NOT_FOUND(5), - /** Some entity that we attempted to create (e.g., file or directory) already exists. */ + /** + * Some entity that we attempted to create (e.g., file or directory) already exists. + * + * @since 0.5 + */ ALREADY_EXISTS(6), /** @@ -86,12 +112,16 @@ public final class Status { * must not be used for rejections caused by exhausting some resource (use RESOURCE_EXHAUSTED * instead for those errors). PERMISSION_DENIED must not be used if the caller cannot be * identified (use UNAUTHENTICATED instead for those errors). + * + * @since 0.5 */ PERMISSION_DENIED(7), /** * Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system * is out of space. + * + * @since 0.5 */ RESOURCE_EXHAUSTED(8), @@ -107,6 +137,8 @@ public final class Status { * the system state has been explicitly fixed. E.g., if an "rmdir" fails because the directory * is non-empty, FAILED_PRECONDITION should be returned since the client should not retry unless * they have first fixed up the directory by deleting files from it. + * + * @since 0.5 */ FAILED_PRECONDITION(9), @@ -115,6 +147,8 @@ public final class Status { * failures, transaction aborts, etc. * * <p>See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE. + * + * @since 0.5 */ ABORTED(10), @@ -130,15 +164,23 @@ public final class Status { * using OUT_OF_RANGE (the more specific error) when it applies so that callers who are * iterating through a space can easily look for an OUT_OF_RANGE error to detect when they are * done. + * + * @since 0.5 */ OUT_OF_RANGE(11), - /** Operation is not implemented or not supported/enabled in this service. */ + /** + * Operation is not implemented or not supported/enabled in this service. + * + * @since 0.5 + */ UNIMPLEMENTED(12), /** * Internal errors. Means some invariants expected by underlying system has been broken. If you * see one of these errors, something is very broken. + * + * @since 0.5 */ INTERNAL(13), @@ -147,13 +189,23 @@ public final class Status { * corrected by retrying with a backoff. * * <p>See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE. + * + * @since 0.5 */ UNAVAILABLE(14), - /** Unrecoverable data loss or corruption. */ + /** + * Unrecoverable data loss or corruption. + * + * @since 0.5 + */ DATA_LOSS(15), - /** The request does not have valid authentication credentials for the operation. */ + /** + * The request does not have valid authentication credentials for the operation. + * + * @since 0.5 + */ UNAUTHENTICATED(16); private final int value; @@ -166,6 +218,7 @@ public final class Status { * Returns the numerical value of the code. * * @return the numerical value of the code. + * @since 0.5 */ public int value() { return value; @@ -175,6 +228,7 @@ public final class Status { * Returns the status that has the current {@code CanonicalCode}.. * * @return the status that has the current {@code CanonicalCode}. + * @since 0.5 */ @VisibleForTesting public Status toStatus() { @@ -202,53 +256,127 @@ public final class Status { // A pseudo-enum of Status instances mapped 1:1 with values in CanonicalCode. This simplifies // construction patterns for derived instances of Status. - /** The operation completed successfully. */ + /** + * The operation completed successfully. + * + * @since 0.5 + */ public static final Status OK = CanonicalCode.OK.toStatus(); - /** The operation was cancelled (typically by the caller). */ + + /** + * The operation was cancelled (typically by the caller). + * + * @since 0.5 + */ public static final Status CANCELLED = CanonicalCode.CANCELLED.toStatus(); - /** Unknown error. See {@link CanonicalCode#UNKNOWN}. */ + + /** + * Unknown error. See {@link CanonicalCode#UNKNOWN}. + * + * @since 0.5 + */ public static final Status UNKNOWN = CanonicalCode.UNKNOWN.toStatus(); - /** Client specified an invalid argument. See {@link CanonicalCode#INVALID_ARGUMENT}. */ + + /** + * Client specified an invalid argument. See {@link CanonicalCode#INVALID_ARGUMENT}. + * + * @since 0.5 + */ public static final Status INVALID_ARGUMENT = CanonicalCode.INVALID_ARGUMENT.toStatus(); + /** * Deadline expired before operation could complete. See {@link CanonicalCode#DEADLINE_EXCEEDED}. + * + * @since 0.5 */ public static final Status DEADLINE_EXCEEDED = CanonicalCode.DEADLINE_EXCEEDED.toStatus(); - /** Some requested entity (e.g., file or directory) was not found. */ + + /** + * Some requested entity (e.g., file or directory) was not found. + * + * @since 0.5 + */ public static final Status NOT_FOUND = CanonicalCode.NOT_FOUND.toStatus(); - /** Some entity that we attempted to create (e.g., file or directory) already exists. */ + + /** + * Some entity that we attempted to create (e.g., file or directory) already exists. + * + * @since 0.5 + */ public static final Status ALREADY_EXISTS = CanonicalCode.ALREADY_EXISTS.toStatus(); + /** * The caller does not have permission to execute the specified operation. See {@link * CanonicalCode#PERMISSION_DENIED}. + * + * @since 0.5 */ public static final Status PERMISSION_DENIED = CanonicalCode.PERMISSION_DENIED.toStatus(); - /** The request does not have valid authentication credentials for the operation. */ + + /** + * The request does not have valid authentication credentials for the operation. + * + * @since 0.5 + */ public static final Status UNAUTHENTICATED = CanonicalCode.UNAUTHENTICATED.toStatus(); + /** * Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system * is out of space. + * + * @since 0.5 */ public static final Status RESOURCE_EXHAUSTED = CanonicalCode.RESOURCE_EXHAUSTED.toStatus(); + /** * Operation was rejected because the system is not in a state required for the operation's * execution. See {@link CanonicalCode#FAILED_PRECONDITION}. + * + * @since 0.5 */ public static final Status FAILED_PRECONDITION = CanonicalCode.FAILED_PRECONDITION.toStatus(); + /** * The operation was aborted, typically due to a concurrency issue like sequencer check failures, * transaction aborts, etc. See {@link CanonicalCode#ABORTED}. + * + * @since 0.5 */ public static final Status ABORTED = CanonicalCode.ABORTED.toStatus(); - /** Operation was attempted past the valid range. See {@link CanonicalCode#OUT_OF_RANGE}. */ + + /** + * Operation was attempted past the valid range. See {@link CanonicalCode#OUT_OF_RANGE}. + * + * @since 0.5 + */ public static final Status OUT_OF_RANGE = CanonicalCode.OUT_OF_RANGE.toStatus(); - /** Operation is not implemented or not supported/enabled in this service. */ + + /** + * Operation is not implemented or not supported/enabled in this service. + * + * @since 0.5 + */ public static final Status UNIMPLEMENTED = CanonicalCode.UNIMPLEMENTED.toStatus(); - /** Internal errors. See {@link CanonicalCode#INTERNAL}. */ + + /** + * Internal errors. See {@link CanonicalCode#INTERNAL}. + * + * @since 0.5 + */ public static final Status INTERNAL = CanonicalCode.INTERNAL.toStatus(); - /** The service is currently unavailable. See {@link CanonicalCode#UNAVAILABLE}. */ + + /** + * The service is currently unavailable. See {@link CanonicalCode#UNAVAILABLE}. + * + * @since 0.5 + */ public static final Status UNAVAILABLE = CanonicalCode.UNAVAILABLE.toStatus(); - /** Unrecoverable data loss or corruption. */ + + /** + * Unrecoverable data loss or corruption. + * + * @since 0.5 + */ public static final Status DATA_LOSS = CanonicalCode.DATA_LOSS.toStatus(); // The canonical code of this message. @@ -267,6 +395,7 @@ public final class Status { * * @param description the new description of the {@code Status}. * @return The newly created {@code Status} with the given description. + * @since 0.5 */ public Status withDescription(String description) { if (Objects.equal(this.description, description)) { @@ -279,6 +408,7 @@ public final class Status { * Returns the canonical status code. * * @return the canonical status code. + * @since 0.5 */ public CanonicalCode getCanonicalCode() { return canonicalCode; @@ -288,6 +418,7 @@ public final class Status { * Returns the description of this {@code Status} for human consumption. * * @return the description of this {@code Status}. + * @since 0.5 */ @Nullable /*@Deterministic*/ @@ -299,6 +430,7 @@ public final class Status { * Returns {@code true} if this {@code Status} is OK, i.e., not an error. * * @return {@code true} if this {@code Status} is OK. + * @since 0.5 */ public boolean isOk() { return CanonicalCode.OK == canonicalCode; diff --git a/api/src/main/java/io/opencensus/trace/TraceComponent.java b/api/src/main/java/io/opencensus/trace/TraceComponent.java index a781f045..d98d0f9e 100644 --- a/api/src/main/java/io/opencensus/trace/TraceComponent.java +++ b/api/src/main/java/io/opencensus/trace/TraceComponent.java @@ -27,6 +27,8 @@ import io.opencensus.trace.propagation.PropagationComponent; * {@link Clock}, {@link ExportComponent} and {@link TraceConfig}. * * <p>Unless otherwise noted all methods (on component) results are cacheable. + * + * @since 0.5 */ public abstract class TraceComponent { @@ -35,6 +37,7 @@ public abstract class TraceComponent { * then no-op implementations will be used. * * @return the {@code Tracer} implementation. + * @since 0.5 */ public abstract Tracer getTracer(); @@ -43,6 +46,7 @@ public abstract class TraceComponent { * is provided then no-op implementation will be used. * * @return the {@code PropagationComponent} implementation. + * @since 0.5 */ public abstract PropagationComponent getPropagationComponent(); @@ -50,6 +54,7 @@ public abstract class TraceComponent { * Returns the {@link Clock} with the provided implementation. * * @return the {@code Clock} implementation. + * @since 0.5 */ public abstract Clock getClock(); @@ -58,6 +63,7 @@ public abstract class TraceComponent { * provided then no-op implementations will be used. * * @return the {@link ExportComponent} implementation. + * @since 0.5 */ public abstract ExportComponent getExportComponent(); @@ -66,6 +72,7 @@ public abstract class TraceComponent { * provided then no-op implementations will be used. * * @return the {@link TraceConfig} implementation. + * @since 0.5 */ public abstract TraceConfig getTraceConfig(); diff --git a/api/src/main/java/io/opencensus/trace/TraceId.java b/api/src/main/java/io/opencensus/trace/TraceId.java index 2fad8949..6378bf58 100644 --- a/api/src/main/java/io/opencensus/trace/TraceId.java +++ b/api/src/main/java/io/opencensus/trace/TraceId.java @@ -30,13 +30,23 @@ import javax.annotation.concurrent.Immutable; /** * A class that represents a trace identifier. A valid trace identifier is a 16-byte array with at * least one non-zero byte. + * + * @since 0.5 */ @Immutable public final class TraceId implements Comparable<TraceId> { - /** The size in bytes of the {@code TraceId}. */ + /** + * The size in bytes of the {@code TraceId}. + * + * @since 0.5 + */ public static final int SIZE = 16; - /** The invalid {@code TraceId}. All bytes are '\0'. */ + /** + * The invalid {@code TraceId}. All bytes are '\0'. + * + * @since 0.5 + */ public static final TraceId INVALID = new TraceId(new byte[SIZE]); // The internal representation of the TraceId. @@ -59,6 +69,7 @@ public final class TraceId implements Comparable<TraceId> { * @return a {@code TraceId} whose representation is given by the {@code buffer} parameter. * @throws NullPointerException if {@code buffer} is null. * @throws IllegalArgumentException if {@code buffer.length} is not {@link TraceId#SIZE}. + * @since 0.5 */ public static TraceId fromBytes(byte[] buffer) { checkNotNull(buffer, "buffer"); @@ -78,6 +89,7 @@ public final class TraceId implements Comparable<TraceId> { * @throws NullPointerException if {@code src} is null. * @throws IndexOutOfBoundsException if {@code srcOffset+TraceId.SIZE} is greater than {@code * src.length}. + * @since 0.5 */ public static TraceId fromBytes(byte[] src, int srcOffset) { byte[] bytes = new byte[SIZE]; @@ -93,6 +105,7 @@ public final class TraceId implements Comparable<TraceId> { * @throws NullPointerException if {@code src} is null. * @throws IllegalArgumentException if {@code src.length} is not {@code 2 * TraceId.SIZE} OR if * the {@code str} has invalid characters. + * @since 0.11 */ public static TraceId fromLowerBase16(CharSequence src) { checkArgument( @@ -106,6 +119,7 @@ public final class TraceId implements Comparable<TraceId> { * * @param random the random number generator. * @return a new valid {@code TraceId}. + * @since 0.5 */ public static TraceId generateRandomId(Random random) { byte[] bytes = new byte[SIZE]; @@ -119,6 +133,7 @@ public final class TraceId implements Comparable<TraceId> { * Returns the 16-bytes array representation of the {@code TraceId}. * * @return the 16-bytes array representation of the {@code TraceId}. + * @since 0.5 */ public byte[] getBytes() { return Arrays.copyOf(bytes, SIZE); @@ -139,6 +154,7 @@ public final class TraceId implements Comparable<TraceId> { * @throws NullPointerException if {@code dest} is null. * @throws IndexOutOfBoundsException if {@code destOffset+TraceId.SIZE} is greater than {@code * dest.length}. + * @since 0.5 */ public void copyBytesTo(byte[] dest, int destOffset) { System.arraycopy(bytes, 0, dest, destOffset, SIZE); @@ -149,6 +165,7 @@ public final class TraceId implements Comparable<TraceId> { * at least one non-zero byte. * * @return {@code true} if the {@code TraceId} is valid. + * @since 0.5 */ public boolean isValid() { return !Arrays.equals(bytes, INVALID.bytes); @@ -158,6 +175,7 @@ public final class TraceId implements Comparable<TraceId> { * Returns the lowercase base16 encoding of this {@code TraceId}. * * @return the lowercase base16 encoding of this {@code TraceId}. + * @since 0.11 */ public String toLowerBase16() { return BaseEncoding.base16().lowerCase().encode(bytes); diff --git a/api/src/main/java/io/opencensus/trace/TraceOptions.java b/api/src/main/java/io/opencensus/trace/TraceOptions.java index 2f57f3a7..bd6fe6bd 100644 --- a/api/src/main/java/io/opencensus/trace/TraceOptions.java +++ b/api/src/main/java/io/opencensus/trace/TraceOptions.java @@ -30,6 +30,8 @@ import javax.annotation.concurrent.Immutable; * A class that represents global trace options. These options are propagated to all child {@link * io.opencensus.trace.Span spans}. These determine features such as whether a {@code Span} should * be traced. It is implemented as a bitmask. + * + * @since 0.5 */ @Immutable public final class TraceOptions { @@ -38,10 +40,18 @@ public final class TraceOptions { // Bit to represent whether trace is sampled or not. private static final byte IS_SAMPLED = 0x1; - /** The size in bytes of the {@code TraceOptions}. */ + /** + * The size in bytes of the {@code TraceOptions}. + * + * @since 0.5 + */ public static final int SIZE = 1; - /** The default {@code TraceOptions}. */ + /** + * The default {@code TraceOptions}. + * + * @since 0.5 + */ public static final TraceOptions DEFAULT = new TraceOptions(DEFAULT_OPTIONS); // The set of enabled features is determined by all the enabled bits. @@ -65,6 +75,7 @@ public final class TraceOptions { * @return a {@code TraceOptions} whose representation is given by the {@code buffer} parameter. * @throws NullPointerException if {@code buffer} is null. * @throws IllegalArgumentException if {@code buffer.length} is not {@link TraceOptions#SIZE}. + * @since 0.5 */ public static TraceOptions fromBytes(byte[] buffer) { checkNotNull(buffer, "buffer"); @@ -83,6 +94,7 @@ public final class TraceOptions { * @throws NullPointerException if {@code src} is null. * @throws IndexOutOfBoundsException if {@code srcOffset+TraceOptions.SIZE} is greater than {@code * src.length}. + * @since 0.5 */ public static TraceOptions fromBytes(byte[] src, int srcOffset) { checkElementIndex(srcOffset, src.length); @@ -93,6 +105,7 @@ public final class TraceOptions { * Returns the 1-byte array representation of the {@code TraceOptions}. * * @return the 1-byte array representation of the {@code TraceOptions}. + * @since 0.5 */ public byte[] getBytes() { byte[] bytes = new byte[SIZE]; @@ -115,6 +128,7 @@ public final class TraceOptions { * @throws NullPointerException if {@code dest} is null. * @throws IndexOutOfBoundsException if {@code destOffset+TraceOptions.SIZE} is greater than * {@code dest.length}. + * @since 0.5 */ public void copyBytesTo(byte[] dest, int destOffset) { checkElementIndex(destOffset, dest.length); @@ -125,6 +139,7 @@ public final class TraceOptions { * Returns a new {@link Builder} with default options. * * @return a new {@code Builder} with default options. + * @since 0.5 */ public static Builder builder() { return new Builder(DEFAULT_OPTIONS); @@ -135,6 +150,7 @@ public final class TraceOptions { * * @param traceOptions the given options set. * @return a new {@code Builder} with all given options set. + * @since 0.5 */ public static Builder builder(TraceOptions traceOptions) { return new Builder(traceOptions.options); @@ -145,6 +161,7 @@ public final class TraceOptions { * should be exported to a persistent store. * * @return a boolean indicating whether the trace is sampled. + * @since 0.5 */ public boolean isSampled() { return hasOption(IS_SAMPLED); @@ -174,7 +191,11 @@ public final class TraceOptions { return MoreObjects.toStringHelper(this).add("sampled", isSampled()).toString(); } - /** Builder class for {@link TraceOptions}. */ + /** + * Builder class for {@link TraceOptions}. + * + * @since 0.5 + */ public static final class Builder { private byte options; @@ -185,6 +206,7 @@ public final class TraceOptions { /** * @deprecated Use {@code Builder.setIsSampled(true)}. * @return this. + * @since 0.5 */ @Deprecated public Builder setIsSampled() { @@ -196,6 +218,7 @@ public final class TraceOptions { * * @param isSampled the sampling bit. * @return this. + * @since 0.7 */ public Builder setIsSampled(boolean isSampled) { if (isSampled) { @@ -211,6 +234,7 @@ public final class TraceOptions { * Builds and returns a {@code TraceOptions} with the desired options. * * @return a {@code TraceOptions} with the desired options. + * @since 0.5 */ public TraceOptions build() { return new TraceOptions(options); diff --git a/api/src/main/java/io/opencensus/trace/Tracer.java b/api/src/main/java/io/opencensus/trace/Tracer.java index 22b98da5..f4ac8c65 100644 --- a/api/src/main/java/io/opencensus/trace/Tracer.java +++ b/api/src/main/java/io/opencensus/trace/Tracer.java @@ -67,6 +67,8 @@ import javax.annotation.Nullable; * } * } * }</pre> + * + * @since 0.5 */ public abstract class Tracer { private static final NoopTracer noopTracer = new NoopTracer(); @@ -91,6 +93,7 @@ public abstract class Tracer { * @return a default {@code Span} that does nothing and has an invalid {@link SpanContext} if no * {@code Span} is associated with the current Context, otherwise the current {@code Span} * from the Context. + * @since 0.5 */ public final Span getCurrentSpan() { Span currentSpan = CurrentSpanUtils.getCurrentSpan(); @@ -145,6 +148,7 @@ public abstract class Tracer { * @return an object that defines a scope where the given {@link Span} will be set to the current * Context. * @throws NullPointerException if {@code span} is {@code null}. + * @since 0.5 */ @MustBeClosed public final Scope withSpan(Span span) { @@ -299,6 +303,7 @@ public abstract class Tracer { * @param spanName The name of the returned Span. * @return a {@code SpanBuilder} to create and start a new {@code Span}. * @throws NullPointerException if {@code spanName} is {@code null}. + * @since 0.5 */ public final SpanBuilder spanBuilder(String spanName) { return spanBuilderWithExplicitParent(spanName, CurrentSpanUtils.getCurrentSpan()); @@ -319,6 +324,7 @@ public abstract class Tracer { * build a root {@code Span}. * @return a {@code SpanBuilder} to create and start a new {@code Span}. * @throws NullPointerException if {@code spanName} is {@code null}. + * @since 0.5 */ public abstract SpanBuilder spanBuilderWithExplicitParent(String spanName, @Nullable Span parent); @@ -339,6 +345,7 @@ public abstract class Tracer { * @param remoteParentSpanContext The remote parent of the returned Span. * @return a {@code SpanBuilder} to create and start a new {@code Span}. * @throws NullPointerException if {@code spanName} is {@code null}. + * @since 0.5 */ public abstract SpanBuilder spanBuilderWithRemoteParent( String spanName, @Nullable SpanContext remoteParentSpanContext); diff --git a/api/src/main/java/io/opencensus/trace/Tracing.java b/api/src/main/java/io/opencensus/trace/Tracing.java index 31d8cdc2..f3673020 100644 --- a/api/src/main/java/io/opencensus/trace/Tracing.java +++ b/api/src/main/java/io/opencensus/trace/Tracing.java @@ -26,7 +26,11 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nullable; -/** Class that manages a global instance of the {@link TraceComponent}. */ +/** + * Class that manages a global instance of the {@link TraceComponent}. + * + * @since 0.5 + */ public final class Tracing { private static final Logger logger = Logger.getLogger(Tracing.class.getName()); private static final TraceComponent traceComponent = @@ -36,6 +40,7 @@ public final class Tracing { * Returns the global {@link Tracer}. * * @return the global {@code Tracer}. + * @since 0.5 */ public static Tracer getTracer() { return traceComponent.getTracer(); @@ -45,6 +50,7 @@ public final class Tracing { * Returns the global {@link PropagationComponent}. * * @return the global {@code PropagationComponent}. + * @since 0.5 */ public static PropagationComponent getPropagationComponent() { return traceComponent.getPropagationComponent(); @@ -54,6 +60,7 @@ public final class Tracing { * Returns the global {@link Clock}. * * @return the global {@code Clock}. + * @since 0.5 */ public static Clock getClock() { return traceComponent.getClock(); @@ -63,6 +70,7 @@ public final class Tracing { * Returns the global {@link ExportComponent}. * * @return the global {@code ExportComponent}. + * @since 0.5 */ public static ExportComponent getExportComponent() { return traceComponent.getExportComponent(); @@ -72,6 +80,7 @@ public final class Tracing { * Returns the global {@link TraceConfig}. * * @return the global {@code TraceConfig}. + * @since 0.5 */ public static TraceConfig getTraceConfig() { return traceComponent.getTraceConfig(); diff --git a/api/src/main/java/io/opencensus/trace/config/TraceConfig.java b/api/src/main/java/io/opencensus/trace/config/TraceConfig.java index bebf4a7f..ff701e20 100644 --- a/api/src/main/java/io/opencensus/trace/config/TraceConfig.java +++ b/api/src/main/java/io/opencensus/trace/config/TraceConfig.java @@ -19,6 +19,8 @@ package io.opencensus.trace.config; /** * Global configuration of the trace service. This allows users to change configs for the default * sampler, maximum events to be kept, etc. (see {@link TraceParams} for details). + * + * @since 0.5 */ public abstract class TraceConfig { private static final NoopTraceConfig NOOP_TRACE_CONFIG = new NoopTraceConfig(); @@ -27,6 +29,7 @@ public abstract class TraceConfig { * Returns the active {@code TraceParams}. * * @return the active {@code TraceParams}. + * @since 0.5 */ public abstract TraceParams getActiveTraceParams(); @@ -34,6 +37,7 @@ public abstract class TraceConfig { * Updates the active {@link TraceParams}. * * @param traceParams the new active {@code TraceParams}. + * @since 0.5 */ public abstract void updateActiveTraceParams(TraceParams traceParams); @@ -41,6 +45,7 @@ public abstract class TraceConfig { * Returns the no-op implementation of the {@code TraceConfig}. * * @return the no-op implementation of the {@code TraceConfig}. + * @since 0.5 */ public static TraceConfig getNoopTraceConfig() { return NOOP_TRACE_CONFIG; diff --git a/api/src/main/java/io/opencensus/trace/config/TraceParams.java b/api/src/main/java/io/opencensus/trace/config/TraceParams.java index c56cc9f7..17dbbb9d 100644 --- a/api/src/main/java/io/opencensus/trace/config/TraceParams.java +++ b/api/src/main/java/io/opencensus/trace/config/TraceParams.java @@ -27,7 +27,11 @@ import io.opencensus.trace.Span; import io.opencensus.trace.samplers.Samplers; import javax.annotation.concurrent.Immutable; -/** Class that holds global trace parameters. */ +/** + * Class that holds global trace parameters. + * + * @since 0.5 + */ @AutoValue @Immutable // Suppress Checker Framework warning about missing @Nullable in generated equals method. @@ -42,6 +46,11 @@ public abstract class TraceParams { private static final int DEFAULT_SPAN_MAX_NUM_NETWORK_EVENTS = 128; private static final int DEFAULT_SPAN_MAX_NUM_LINKS = 128; + /** + * Default {@code TraceParams}. + * + * @since 0.5 + */ public static final TraceParams DEFAULT = TraceParams.builder() .setSampler(DEFAULT_SAMPLER) @@ -56,6 +65,7 @@ public abstract class TraceParams { * io.opencensus.trace.SpanBuilder#setSampler(Sampler)}. * * @return the global default {@code Sampler}. + * @since 0.5 */ public abstract Sampler getSampler(); @@ -63,6 +73,7 @@ public abstract class TraceParams { * Returns the global default max number of attributes per {@link Span}. * * @return the global default max number of attributes per {@link Span}. + * @since 0.5 */ public abstract int getMaxNumberOfAttributes(); @@ -70,6 +81,7 @@ public abstract class TraceParams { * Returns the global default max number of {@link Annotation} events per {@link Span}. * * @return the global default max number of {@code Annotation} events per {@code Span}. + * @since 0.5 */ public abstract int getMaxNumberOfAnnotations(); @@ -77,6 +89,7 @@ public abstract class TraceParams { * Returns the global default max number of {@link NetworkEvent} events per {@link Span}. * * @return the global default max number of {@code NetworkEvent} events per {@code Span}. + * @since 0.5 */ public abstract int getMaxNumberOfNetworkEvents(); @@ -84,6 +97,7 @@ public abstract class TraceParams { * Returns the global default max number of {@link Link} entries per {@link Span}. * * @return the global default max number of {@code Link} entries per {@code Span}. + * @since 0.5 */ public abstract int getMaxNumberOfLinks(); @@ -95,10 +109,15 @@ public abstract class TraceParams { * Returns a {@link Builder} initialized to the same property values as the current instance. * * @return a {@link Builder} initialized to the same property values as the current instance. + * @since 0.5 */ public abstract Builder toBuilder(); - /** A {@code Builder} class for {@link TraceParams}. */ + /** + * A {@code Builder} class for {@link TraceParams}. + * + * @since 0.5 + */ @AutoValue.Builder public abstract static class Builder { @@ -108,6 +127,7 @@ public abstract class TraceParams { * * @param sampler the global default {@code Sampler}. * @return this. + * @since 0.5 */ public abstract Builder setSampler(Sampler sampler); @@ -117,6 +137,7 @@ public abstract class TraceParams { * @param maxNumberOfAttributes the global default max number of attributes per {@link Span}. It * must be positive otherwise {@link #build()} will throw an exception. * @return this. + * @since 0.5 */ public abstract Builder setMaxNumberOfAttributes(int maxNumberOfAttributes); @@ -126,6 +147,7 @@ public abstract class TraceParams { * @param maxNumberOfAnnotations the global default max number of {@link Annotation} events per * {@link Span}. It must be positive otherwise {@link #build()} will throw an exception. * @return this. + * @since 0.5 */ public abstract Builder setMaxNumberOfAnnotations(int maxNumberOfAnnotations); @@ -135,6 +157,7 @@ public abstract class TraceParams { * @param maxNumberOfNetworkEvents the global default max number of {@link NetworkEvent} events * per {@link Span}. It must be positive otherwise {@link #build()} will throw an exception. * @return this. + * @since 0.5 */ public abstract Builder setMaxNumberOfNetworkEvents(int maxNumberOfNetworkEvents); @@ -144,6 +167,7 @@ public abstract class TraceParams { * @param maxNumberOfLinks the global default max number of {@link Link} entries per {@link * Span}. It must be positive otherwise {@link #build()} will throw an exception. * @return this. + * @since 0.5 */ public abstract Builder setMaxNumberOfLinks(int maxNumberOfLinks); @@ -155,6 +179,7 @@ public abstract class TraceParams { * @return a {@code TraceParams} with the desired values. * @throws NullPointerException if the sampler is {@code null}. * @throws IllegalArgumentException if any of the max numbers are not positive. + * @since 0.5 */ public TraceParams build() { TraceParams traceParams = autoBuild(); diff --git a/api/src/main/java/io/opencensus/trace/export/ExportComponent.java b/api/src/main/java/io/opencensus/trace/export/ExportComponent.java index 7e2eb88e..63447a76 100644 --- a/api/src/main/java/io/opencensus/trace/export/ExportComponent.java +++ b/api/src/main/java/io/opencensus/trace/export/ExportComponent.java @@ -23,6 +23,8 @@ import io.opencensus.trace.TraceOptions; * and {@link SampledSpanStore}. * * <p>Unless otherwise noted all methods (on component) results are cacheable. + * + * @since 0.5 */ public abstract class ExportComponent { @@ -30,6 +32,7 @@ public abstract class ExportComponent { * Returns the no-op implementation of the {@code ExportComponent}. * * @return the no-op implementation of the {@code ExportComponent}. + * @since 0.5 */ public static ExportComponent newNoopExportComponent() { return new NoopExportComponent(); @@ -41,6 +44,7 @@ public abstract class ExportComponent { * * @return the implementation of the {@code SpanExporter} or no-op if no implementation linked in * the binary. + * @since 0.5 */ public abstract SpanExporter getSpanExporter(); @@ -49,6 +53,7 @@ public abstract class ExportComponent { * all the current active spans. * * @return the {@code RunningSpanStore}. + * @since 0.5 */ public abstract RunningSpanStore getRunningSpanStore(); @@ -57,6 +62,7 @@ public abstract class ExportComponent { * as latency based sampled spans, error based sampled spans. * * @return the {@code SampledSpanStore}. + * @since 0.5 */ public abstract SampledSpanStore getSampledSpanStore(); diff --git a/api/src/main/java/io/opencensus/trace/export/RunningSpanStore.java b/api/src/main/java/io/opencensus/trace/export/RunningSpanStore.java index 209afe05..fbfc5ff1 100644 --- a/api/src/main/java/io/opencensus/trace/export/RunningSpanStore.java +++ b/api/src/main/java/io/opencensus/trace/export/RunningSpanStore.java @@ -33,6 +33,8 @@ import javax.annotation.concurrent.ThreadSafe; * <p>The running spans tracking is available for all the spans with the option {@link * io.opencensus.trace.Span.Options#RECORD_EVENTS}. This functionality allows users to debug stuck * operations or long living operations. + * + * @since 0.5 */ @ThreadSafe public abstract class RunningSpanStore { @@ -54,6 +56,7 @@ public abstract class RunningSpanStore { * Returns the summary of all available data such, as number of running spans. * * @return the summary of all available data. + * @since 0.5 */ public abstract Summary getSummary(); @@ -62,10 +65,15 @@ public abstract class RunningSpanStore { * * @param filter used to filter the returned spans. * @return a list of running spans that match the {@code Filter}. + * @since 0.5 */ public abstract Collection<SpanData> getRunningSpans(Filter filter); - /** The summary of all available data. */ + /** + * The summary of all available data. + * + * @since 0.5 + */ @AutoValue @Immutable // Suppress Checker Framework warning about missing @Nullable in generated equals method. @@ -81,6 +89,7 @@ public abstract class RunningSpanStore { * @param perSpanNameSummary a map with summary for each span name. * @return a new instance of {@code Summary}. * @throws NullPointerException if {@code perSpanNameSummary} is {@code null}. + * @since 0.5 */ public static Summary create(Map<String, PerSpanNameSummary> perSpanNameSummary) { return new AutoValue_RunningSpanStore_Summary( @@ -93,11 +102,16 @@ public abstract class RunningSpanStore { * Returns a map with summary of available data for each span name. * * @return a map with all the span names and the summary. + * @since 0.5 */ public abstract Map<String, PerSpanNameSummary> getPerSpanNameSummary(); } - /** Summary of all available data for a span name. */ + /** + * Summary of all available data for a span name. + * + * @since 0.5 + */ @AutoValue @Immutable // Suppress Checker Framework warning about missing @Nullable in generated equals method. @@ -113,6 +127,7 @@ public abstract class RunningSpanStore { * @param numRunningSpans the number of running spans. * @return a new instance of {@code PerSpanNameSummary}. * @throws IllegalArgumentException if {@code numRunningSpans} is negative. + * @since 0.5 */ public static PerSpanNameSummary create(int numRunningSpans) { checkArgument(numRunningSpans >= 0, "Negative numRunningSpans."); @@ -123,6 +138,7 @@ public abstract class RunningSpanStore { * Returns the number of running spans. * * @return the number of running spans. + * @since 0.5 */ public abstract int getNumRunningSpans(); } @@ -130,6 +146,8 @@ public abstract class RunningSpanStore { /** * Filter for running spans. Used to filter results returned by the {@link * #getRunningSpans(Filter)} request. + * + * @since 0.5 */ @AutoValue @Immutable @@ -151,6 +169,7 @@ public abstract class RunningSpanStore { * @return a new instance of {@code Filter}. * @throws NullPointerException if {@code spanName} is {@code null}. * @throws IllegalArgumentException if {@code maxSpansToReturn} is negative. + * @since 0.5 */ public static Filter create(String spanName, int maxSpansToReturn) { checkArgument(maxSpansToReturn >= 0, "Negative maxSpansToReturn."); @@ -161,6 +180,7 @@ public abstract class RunningSpanStore { * Returns the span name. * * @return the span name. + * @since 0.5 */ public abstract String getSpanName(); @@ -168,6 +188,7 @@ public abstract class RunningSpanStore { * Returns the maximum number of spans to be returned. {@code 0} means all. * * @return the maximum number of spans to be returned. + * @since 0.5 */ public abstract int getMaxSpansToReturn(); } diff --git a/api/src/main/java/io/opencensus/trace/export/SampledSpanStore.java b/api/src/main/java/io/opencensus/trace/export/SampledSpanStore.java index c04b19f6..67a40567 100644 --- a/api/src/main/java/io/opencensus/trace/export/SampledSpanStore.java +++ b/api/src/main/java/io/opencensus/trace/export/SampledSpanStore.java @@ -45,6 +45,8 @@ import javax.annotation.concurrent.ThreadSafe; * store samples based on latency for succeeded operations or based on error code for failed * operations. To activate this, users MUST manually configure all the span names for which samples * will be collected (see {@link #registerSpanNamesForCollection(Collection)}). + * + * @since 0.5 */ @ThreadSafe public abstract class SampledSpanStore { @@ -70,6 +72,7 @@ public abstract class SampledSpanStore { * #registerSpanNamesForCollection(Collection)}. * * @return the summary of all available data. + * @since 0.5 */ public abstract Summary getSummary(); @@ -82,6 +85,7 @@ public abstract class SampledSpanStore { * * @param filter used to filter the returned sampled spans. * @return a list of succeeded spans that match the {@code filter}. + * @since 0.5 */ public abstract Collection<SpanData> getLatencySampledSpans(LatencyFilter filter); @@ -94,6 +98,7 @@ public abstract class SampledSpanStore { * * @param filter used to filter the returned sampled spans. * @return a list of failed spans that match the {@code filter}. + * @since 0.5 */ public abstract Collection<SpanData> getErrorSampledSpans(ErrorFilter filter); @@ -104,6 +109,7 @@ public abstract class SampledSpanStore { * <p>If called multiple times the library keeps the list of unique span names from all the calls. * * @param spanNames list of span names for which the library will collect samples. + * @since 0.5 */ public abstract void registerSpanNamesForCollection(Collection<String> spanNames); @@ -115,6 +121,7 @@ public abstract class SampledSpanStore { * This method allows users to remove span names from that list. * * @param spanNames list of span names for which the library will no longer collect samples. + * @since 0.5 */ public abstract void unregisterSpanNamesForCollection(Collection<String> spanNames); @@ -123,11 +130,16 @@ public abstract class SampledSpanStore { * library will collect latency based sampled spans and error based sampled spans. * * @return the set of unique span names registered to the library. + * @since 0.7 */ @VisibleForTesting public abstract Set<String> getRegisteredSpanNamesForCollection(); - /** The summary of all available data. */ + /** + * The summary of all available data. + * + * @since 0.5 + */ @AutoValue @Immutable // Suppress Checker Framework warning about missing @Nullable in generated equals method. @@ -143,6 +155,7 @@ public abstract class SampledSpanStore { * @param perSpanNameSummary a map with summary for each span name. * @return a new instance of {@code Summary}. * @throws NullPointerException if {@code perSpanNameSummary} is {@code null}. + * @since 0.5 */ public static Summary create(Map<String, PerSpanNameSummary> perSpanNameSummary) { return new AutoValue_SampledSpanStore_Summary( @@ -155,11 +168,16 @@ public abstract class SampledSpanStore { * Returns a map with summary of available data for each span name. * * @return a map with all the span names and the summary. + * @since 0.5 */ public abstract Map<String, PerSpanNameSummary> getPerSpanNameSummary(); } - /** Summary of all available data for a span name. */ + /** + * Summary of all available data for a span name. + * + * @since 0.5 + */ @AutoValue @Immutable // Suppress Checker Framework warning about missing @Nullable in generated equals method. @@ -177,6 +195,7 @@ public abstract class SampledSpanStore { * @return a new instance of {@code PerSpanNameSummary}. * @throws NullPointerException if {@code numbersOfLatencySampledSpans} or {@code * numbersOfErrorSampledSpans} are {@code null}. + * @since 0.5 */ public static PerSpanNameSummary create( Map<LatencyBucketBoundaries, Integer> numbersOfLatencySampledSpans, @@ -197,6 +216,7 @@ public abstract class SampledSpanStore { * #registerSpanNamesForCollection(Collection)}. * * @return the number of sampled spans in all the latency buckets. + * @since 0.5 */ public abstract Map<LatencyBucketBoundaries, Integer> getNumbersOfLatencySampledSpans(); @@ -207,6 +227,7 @@ public abstract class SampledSpanStore { * #registerSpanNamesForCollection(Collection)}. * * @return the number of sampled spans in all the error buckets. + * @since 0.5 */ public abstract Map<CanonicalCode, Integer> getNumbersOfErrorSampledSpans(); } @@ -215,25 +236,71 @@ public abstract class SampledSpanStore { * The latency buckets boundaries. Samples based on latency for successful spans (the status of * the span has a canonical code equal to {@link CanonicalCode#OK}) are collected in one of these * latency buckets. + * + * @since 0.5 */ public enum LatencyBucketBoundaries { - // Stores finished successful requests of duration within the interval [0, 10us) + /** + * Stores finished successful requests of duration within the interval [0, 10us) + * + * @since 0.5 + */ ZERO_MICROSx10(0, TimeUnit.MICROSECONDS.toNanos(10)), - // Stores finished successful requests of duration within the interval [10us, 100us) + + /** + * Stores finished successful requests of duration within the interval [10us, 100us) + * + * @since 0.5 + */ MICROSx10_MICROSx100(TimeUnit.MICROSECONDS.toNanos(10), TimeUnit.MICROSECONDS.toNanos(100)), - // Stores finished successful requests of duration within the interval [100us, 1ms) + + /** + * Stores finished successful requests of duration within the interval [100us, 1ms) + * + * @since 0.5 + */ MICROSx100_MILLIx1(TimeUnit.MICROSECONDS.toNanos(100), TimeUnit.MILLISECONDS.toNanos(1)), - // Stores finished successful requests of duration within the interval [1ms, 10ms) + + /** + * Stores finished successful requests of duration within the interval [1ms, 10ms) + * + * @since 0.5 + */ MILLIx1_MILLIx10(TimeUnit.MILLISECONDS.toNanos(1), TimeUnit.MILLISECONDS.toNanos(10)), - // Stores finished successful requests of duration within the interval [10ms, 100ms) + + /** + * Stores finished successful requests of duration within the interval [10ms, 100ms) + * + * @since 0.5 + */ MILLIx10_MILLIx100(TimeUnit.MILLISECONDS.toNanos(10), TimeUnit.MILLISECONDS.toNanos(100)), - // Stores finished successful requests of duration within the interval [100ms, 1sec) + + /** + * Stores finished successful requests of duration within the interval [100ms, 1sec) + * + * @since 0.5 + */ MILLIx100_SECONDx1(TimeUnit.MILLISECONDS.toNanos(100), TimeUnit.SECONDS.toNanos(1)), - // Stores finished successful requests of duration within the interval [1sec, 10sec) + + /** + * Stores finished successful requests of duration within the interval [1sec, 10sec) + * + * @since 0.5 + */ SECONDx1_SECONDx10(TimeUnit.SECONDS.toNanos(1), TimeUnit.SECONDS.toNanos(10)), - // Stores finished successful requests of duration within the interval [10sec, 100sec) + + /** + * Stores finished successful requests of duration within the interval [10sec, 100sec) + * + * @since 0.5 + */ SECONDx10_SECONDx100(TimeUnit.SECONDS.toNanos(10), TimeUnit.SECONDS.toNanos(100)), - // Stores finished successful requests of duration >= 100sec + + /** + * Stores finished successful requests of duration >= 100sec + * + * @since 0.5 + */ SECONDx100_MAX(TimeUnit.SECONDS.toNanos(100), Long.MAX_VALUE); /** @@ -251,6 +318,7 @@ public abstract class SampledSpanStore { * Returns the latency lower bound of the bucket. * * @return the latency lower bound of the bucket. + * @since 0.5 */ public long getLatencyLowerNs() { return latencyLowerNs; @@ -260,6 +328,7 @@ public abstract class SampledSpanStore { * Returns the latency upper bound of the bucket. * * @return the latency upper bound of the bucket. + * @since 0.5 */ public long getLatencyUpperNs() { return latencyUpperNs; @@ -272,6 +341,8 @@ public abstract class SampledSpanStore { /** * Filter for latency based sampled spans. Used to filter results returned by the {@link * #getLatencySampledSpans(LatencyFilter)} request. + * + * @since 0.5 */ @AutoValue @Immutable @@ -296,6 +367,7 @@ public abstract class SampledSpanStore { * @throws NullPointerException if {@code spanName} is {@code null}. * @throws IllegalArgumentException if {@code maxSpansToReturn} or {@code latencyLowerNs} or * {@code latencyUpperNs} are negative. + * @since 0.5 */ public static LatencyFilter create( String spanName, long latencyLowerNs, long latencyUpperNs, int maxSpansToReturn) { @@ -310,6 +382,7 @@ public abstract class SampledSpanStore { * Returns the span name used by this filter. * * @return the span name used by this filter. + * @since 0.5 */ public abstract String getSpanName(); @@ -317,6 +390,7 @@ public abstract class SampledSpanStore { * Returns the latency lower bound of this bucket (inclusive). * * @return the latency lower bound of this bucket. + * @since 0.5 */ public abstract long getLatencyLowerNs(); @@ -324,6 +398,7 @@ public abstract class SampledSpanStore { * Returns the latency upper bound of this bucket (exclusive). * * @return the latency upper bound of this bucket. + * @since 0.5 */ public abstract long getLatencyUpperNs(); @@ -331,6 +406,7 @@ public abstract class SampledSpanStore { * Returns the maximum number of spans to be returned. {@code 0} means all. * * @return the maximum number of spans to be returned. + * @since 0.5 */ public abstract int getMaxSpansToReturn(); } @@ -338,6 +414,8 @@ public abstract class SampledSpanStore { /** * Filter for error based sampled spans. Used to filter results returned by the {@link * #getErrorSampledSpans(ErrorFilter)} request. + * + * @since 0.5 */ @AutoValue @Immutable @@ -362,6 +440,7 @@ public abstract class SampledSpanStore { * @throws NullPointerException if {@code spanName} is {@code null}. * @throws IllegalArgumentException if {@code canonicalCode} is {@link CanonicalCode#OK} or * {@code maxSpansToReturn} is negative. + * @since 0.5 */ public static ErrorFilter create( String spanName, @Nullable CanonicalCode canonicalCode, int maxSpansToReturn) { @@ -376,6 +455,7 @@ public abstract class SampledSpanStore { * Returns the span name used by this filter. * * @return the span name used by this filter. + * @since 0.5 */ public abstract String getSpanName(); @@ -384,6 +464,7 @@ public abstract class SampledSpanStore { * CanonicalCode#OK}. If {@code null} then all errors match. * * @return the canonical code used by this filter. + * @since 0.5 */ @Nullable public abstract CanonicalCode getCanonicalCode(); @@ -393,6 +474,7 @@ public abstract class SampledSpanStore { * {@code SpanData}. {@code 0} means all. * * @return the maximum number of spans to be returned. + * @since 0.5 */ public abstract int getMaxSpansToReturn(); } diff --git a/api/src/main/java/io/opencensus/trace/export/SpanData.java b/api/src/main/java/io/opencensus/trace/export/SpanData.java index 498c142e..546b65b6 100644 --- a/api/src/main/java/io/opencensus/trace/export/SpanData.java +++ b/api/src/main/java/io/opencensus/trace/export/SpanData.java @@ -40,7 +40,11 @@ import javax.annotation.concurrent.Immutable; import org.checkerframework.dataflow.qual.Deterministic; */ -/** Immutable representation of all data collected by the {@link Span} class. */ +/** + * Immutable representation of all data collected by the {@link Span} class. + * + * @since 0.5 + */ @Immutable @AutoValue // Suppress Checker Framework warning about missing @Nullable in generated equals method. @@ -68,6 +72,7 @@ public abstract class SpanData { * @param endTimestamp the end {@code Timestamp} of the {@code Span}. {@code null} if the {@code * Span} is still active. * @return a new immutable {@code SpanData}. + * @since 0.5 */ public static SpanData create( SpanContext context, @@ -101,6 +106,7 @@ public abstract class SpanData { * Returns the {@code SpanContext} associated with this {@code Span}. * * @return the {@code SpanContext} associated with this {@code Span}. + * @since 0.5 */ public abstract SpanContext getContext(); @@ -108,6 +114,7 @@ public abstract class SpanData { * Returns the parent {@code SpanId} or {@code null} if the {@code Span} is a root {@code Span}. * * @return the parent {@code SpanId} or {@code null} if the {@code Span} is a root {@code Span}. + * @since 0.5 */ @Nullable /*@Deterministic*/ @@ -119,6 +126,7 @@ public abstract class SpanData { * * @return {@code true} if the parent is on a different process. {@code null} if this is a root * span. + * @since 0.5 */ @Nullable public abstract Boolean getHasRemoteParent(); @@ -127,6 +135,7 @@ public abstract class SpanData { * Returns the name of this {@code Span}. * * @return the name of this {@code Span}. + * @since 0.5 */ public abstract String getName(); @@ -134,6 +143,7 @@ public abstract class SpanData { * Returns the start {@code Timestamp} of this {@code Span}. * * @return the start {@code Timestamp} of this {@code Span}. + * @since 0.5 */ public abstract Timestamp getStartTimestamp(); @@ -141,6 +151,7 @@ public abstract class SpanData { * Returns the attributes recorded for this {@code Span}. * * @return the attributes recorded for this {@code Span}. + * @since 0.5 */ public abstract Attributes getAttributes(); @@ -148,6 +159,7 @@ public abstract class SpanData { * Returns the annotations recorded for this {@code Span}. * * @return the annotations recorded for this {@code Span}. + * @since 0.5 */ public abstract TimedEvents<Annotation> getAnnotations(); @@ -155,6 +167,7 @@ public abstract class SpanData { * Returns network events recorded for this {@code Span}. * * @return network events recorded for this {@code Span}. + * @since 0.5 */ public abstract TimedEvents<NetworkEvent> getNetworkEvents(); @@ -162,6 +175,7 @@ public abstract class SpanData { * Returns links recorded for this {@code Span}. * * @return links recorded for this {@code Span}. + * @since 0.5 */ public abstract Links getLinks(); @@ -172,6 +186,7 @@ public abstract class SpanData { * <p>This information is not always available. * * @return the number of child spans that were generated while the {@code Span} was running. + * @since 0.5 */ @Nullable public abstract Integer getChildSpanCount(); @@ -180,6 +195,7 @@ public abstract class SpanData { * Returns the {@code Status} or {@code null} if {@code Span} is still active. * * @return the {@code Status} or {@code null} if {@code Span} is still active. + * @since 0.5 */ @Nullable /*@Deterministic*/ @@ -189,6 +205,7 @@ public abstract class SpanData { * Returns the end {@code Timestamp} or {@code null} if the {@code Span} is still active. * * @return the end {@code Timestamp} or {@code null} if the {@code Span} is still active. + * @since 0.5 */ @Nullable /*@Deterministic*/ @@ -200,6 +217,7 @@ public abstract class SpanData { * A timed event representation. * * @param <T> the type of value that is timed. + * @since 0.5 */ @Immutable @AutoValue @@ -214,6 +232,7 @@ public abstract class SpanData { * @param event the event. * @param <T> the type of value that is timed. * @return a new immutable {@code TimedEvent<T>} + * @since 0.5 */ public static <T> TimedEvent<T> create(Timestamp timestamp, T event) { return new AutoValue_SpanData_TimedEvent<T>(timestamp, event); @@ -223,6 +242,7 @@ public abstract class SpanData { * Returns the {@code Timestamp} of this event. * * @return the {@code Timestamp} of this event. + * @since 0.5 */ public abstract Timestamp getTimestamp(); @@ -230,6 +250,7 @@ public abstract class SpanData { * Returns the event. * * @return the event. + * @since 0.5 */ /*@Deterministic*/ public abstract T getEvent(); @@ -241,6 +262,7 @@ public abstract class SpanData { * A list of timed events and the number of dropped events representation. * * @param <T> the type of value that is timed. + * @since 0.5 */ @Immutable @AutoValue @@ -255,6 +277,7 @@ public abstract class SpanData { * @param droppedEventsCount the number of dropped events. * @param <T> the type of value that is timed. * @return a new immutable {@code TimedEvents<T>} + * @since 0.5 */ public static <T> TimedEvents<T> create(List<TimedEvent<T>> events, int droppedEventsCount) { return new AutoValue_SpanData_TimedEvents<T>( @@ -267,6 +290,7 @@ public abstract class SpanData { * Returns the list of events. * * @return the list of events. + * @since 0.5 */ public abstract List<TimedEvent<T>> getEvents(); @@ -274,13 +298,18 @@ public abstract class SpanData { * Returns the number of dropped events. * * @return the number of dropped events. + * @since 0.5 */ public abstract int getDroppedEventsCount(); TimedEvents() {} } - /** A set of attributes and the number of dropped attributes representation. */ + /** + * A set of attributes and the number of dropped attributes representation. + * + * @since 0.5 + */ @Immutable @AutoValue // Suppress Checker Framework warning about missing @Nullable in generated equals method. @@ -293,6 +322,7 @@ public abstract class SpanData { * @param attributeMap the set of attributes. * @param droppedAttributesCount the number of dropped attributes. * @return a new immutable {@code Attributes}. + * @since 0.5 */ public static Attributes create( Map<String, AttributeValue> attributeMap, int droppedAttributesCount) { @@ -308,6 +338,7 @@ public abstract class SpanData { * Returns the set of attributes. * * @return the set of attributes. + * @since 0.5 */ public abstract Map<String, AttributeValue> getAttributeMap(); @@ -315,13 +346,18 @@ public abstract class SpanData { * Returns the number of dropped attributes. * * @return the number of dropped attributes. + * @since 0.5 */ public abstract int getDroppedAttributesCount(); Attributes() {} } - /** A list of links and the number of dropped links representation. */ + /** + * A list of links and the number of dropped links representation. + * + * @since 0.5 + */ @Immutable @AutoValue // Suppress Checker Framework warning about missing @Nullable in generated equals method. @@ -334,6 +370,7 @@ public abstract class SpanData { * @param links the list of links. * @param droppedLinksCount the number of dropped links. * @return a new immutable {@code Links}. + * @since 0.5 */ public static Links create(List<Link> links, int droppedLinksCount) { return new AutoValue_SpanData_Links( @@ -345,6 +382,7 @@ public abstract class SpanData { * Returns the list of links. * * @return the list of links. + * @since 0.5 */ public abstract List<Link> getLinks(); @@ -352,6 +390,7 @@ public abstract class SpanData { * Returns the number of dropped links. * * @return the number of dropped links. + * @since 0.5 */ public abstract int getDroppedLinksCount(); diff --git a/api/src/main/java/io/opencensus/trace/export/SpanExporter.java b/api/src/main/java/io/opencensus/trace/export/SpanExporter.java index e872904f..73ac5265 100644 --- a/api/src/main/java/io/opencensus/trace/export/SpanExporter.java +++ b/api/src/main/java/io/opencensus/trace/export/SpanExporter.java @@ -24,6 +24,8 @@ import javax.annotation.concurrent.ThreadSafe; /** * A service that is used by the library to export {@code SpanData} for all the spans that are part * of a distributed sampled trace (see {@link TraceOptions#isSampled()}). + * + * @since 0.5 */ @ThreadSafe public abstract class SpanExporter { @@ -33,6 +35,7 @@ public abstract class SpanExporter { * Returns the no-op implementation of the {@code ExportComponent}. * * @return the no-op implementation of the {@code ExportComponent}. + * @since 0.5 */ public static SpanExporter getNoopSpanExporter() { return NOOP_SPAN_EXPORTER; @@ -44,6 +47,7 @@ public abstract class SpanExporter { * * @param name the name of the service handler. Must be unique for each service. * @param handler the service handler that is called for each ended sampled span. + * @since 0.5 */ public abstract void registerHandler(String name, Handler handler); @@ -51,6 +55,7 @@ public abstract class SpanExporter { * Unregisters the service handler with the provided name. * * @param name the name of the service handler that will be unregistered. + * @since 0.5 */ public abstract void unregisterHandler(String name); @@ -60,6 +65,8 @@ public abstract class SpanExporter { * * <p>To export data this MUST be register to to the ExportComponent using {@link * #registerHandler(String, Handler)}. + * + * @since 0.5 */ public abstract static class Handler { @@ -73,6 +80,7 @@ public abstract class SpanExporter { * different thread if possible. * * @param spanDataList a list of {@code SpanData} objects to be exported. + * @since 0.5 */ public abstract void export(Collection<SpanData> spanDataList); } diff --git a/api/src/main/java/io/opencensus/trace/propagation/BinaryFormat.java b/api/src/main/java/io/opencensus/trace/propagation/BinaryFormat.java index f9c59142..e07afd12 100644 --- a/api/src/main/java/io/opencensus/trace/propagation/BinaryFormat.java +++ b/api/src/main/java/io/opencensus/trace/propagation/BinaryFormat.java @@ -60,6 +60,8 @@ import java.text.ParseException; * } * } * }</pre> + * + * @since 0.5 */ public abstract class BinaryFormat { static final NoopBinaryFormat NOOP_BINARY_FORMAT = new NoopBinaryFormat(); @@ -69,6 +71,7 @@ public abstract class BinaryFormat { * @param spanContext the {@code SpanContext} to serialize. * @return the serialized binary value. * @throws NullPointerException if the {@code spanContext} is {@code null}. + * @since 0.5 */ @Deprecated public byte[] toBinaryValue(SpanContext spanContext) { @@ -81,6 +84,7 @@ public abstract class BinaryFormat { * @param spanContext the {@code SpanContext} to serialize. * @return the serialized binary value. * @throws NullPointerException if the {@code spanContext} is {@code null}. + * @since 0.7 */ public byte[] toByteArray(SpanContext spanContext) { // Implementation must override this method. @@ -93,6 +97,7 @@ public abstract class BinaryFormat { * @return the parsed {@code SpanContext}. * @throws NullPointerException if the {@code input} is {@code null}. * @throws ParseException if the version is not supported or the input is invalid + * @since 0.5 */ @Deprecated public SpanContext fromBinaryValue(byte[] bytes) throws ParseException { @@ -110,6 +115,7 @@ public abstract class BinaryFormat { * @return the parsed {@code SpanContext}. * @throws NullPointerException if the {@code input} is {@code null}. * @throws SpanContextParseException if the version is not supported or the input is invalid + * @since 0.7 */ public SpanContext fromByteArray(byte[] bytes) throws SpanContextParseException { // Implementation must override this method. diff --git a/api/src/main/java/io/opencensus/trace/propagation/PropagationComponent.java b/api/src/main/java/io/opencensus/trace/propagation/PropagationComponent.java index a56c6d13..a90f0419 100644 --- a/api/src/main/java/io/opencensus/trace/propagation/PropagationComponent.java +++ b/api/src/main/java/io/opencensus/trace/propagation/PropagationComponent.java @@ -22,6 +22,8 @@ import io.opencensus.common.ExperimentalApi; * Container class for all the supported propagation formats. Currently supports only Binary format * (see {@link BinaryFormat}) and B3 Text format (see {@link TextFormat}) but more formats will be * added. + * + * @since 0.5 */ public abstract class PropagationComponent { private static final PropagationComponent NOOP_PROPAGATION_COMPONENT = @@ -32,6 +34,7 @@ public abstract class PropagationComponent { * provided then no-op implementation will be used. * * @return the {@code BinaryFormat} implementation. + * @since 0.5 */ public abstract BinaryFormat getBinaryFormat(); @@ -50,6 +53,7 @@ public abstract class PropagationComponent { * Returns an instance that contains no-op implementations for all the instances. * * @return an instance that contains no-op implementations for all the instances. + * @since 0.5 */ public static PropagationComponent getNoopPropagationComponent() { return NOOP_PROPAGATION_COMPONENT; diff --git a/api/src/main/java/io/opencensus/trace/propagation/SpanContextParseException.java b/api/src/main/java/io/opencensus/trace/propagation/SpanContextParseException.java index fa7f2d4e..80d42af5 100644 --- a/api/src/main/java/io/opencensus/trace/propagation/SpanContextParseException.java +++ b/api/src/main/java/io/opencensus/trace/propagation/SpanContextParseException.java @@ -16,7 +16,11 @@ package io.opencensus.trace.propagation; -/** Exception thrown when a {@link io.opencensus.trace.SpanContext} cannot be parsed. */ +/** + * Exception thrown when a {@link io.opencensus.trace.SpanContext} cannot be parsed. + * + * @since 0.7 + */ public final class SpanContextParseException extends Exception { private static final long serialVersionUID = 0L; @@ -24,6 +28,7 @@ public final class SpanContextParseException extends Exception { * Constructs a new {@code SpanContextParseException} with the given message. * * @param message a message describing the parse error. + * @since 0.7 */ public SpanContextParseException(String message) { super(message); @@ -34,6 +39,7 @@ public final class SpanContextParseException extends Exception { * * @param message a message describing the parse error. * @param cause the cause of the parse error. + * @since 0.7 */ public SpanContextParseException(String message, Throwable cause) { super(message, cause); diff --git a/api/src/main/java/io/opencensus/trace/propagation/TextFormat.java b/api/src/main/java/io/opencensus/trace/propagation/TextFormat.java index 25880917..eaa7bf00 100644 --- a/api/src/main/java/io/opencensus/trace/propagation/TextFormat.java +++ b/api/src/main/java/io/opencensus/trace/propagation/TextFormat.java @@ -73,6 +73,8 @@ import javax.annotation.Nullable; * span.end() * } * }</pre> + * + * @since 0.11 */ @ExperimentalApi public abstract class TextFormat { @@ -85,6 +87,8 @@ public abstract class TextFormat { * <p>For example, if the carrier is a single-use or immutable request object, you don't need to * clear fields as they couldn't have been set before. If it is a mutable, retryable object, * successive calls should clear these fields first. + * + * @since 0.11 */ // The use cases of this are: // * allow pre-allocation of fields, especially in systems like gRPC Metadata @@ -97,6 +101,7 @@ public abstract class TextFormat { * @param spanContext possibly not sampled. * @param carrier holds propagation fields. For example, an outgoing message or http request. * @param setter invoked for each propagation key to add or remove. + * @since 0.11 */ public abstract <C> void inject(SpanContext spanContext, C carrier, Setter<C> setter); @@ -107,6 +112,7 @@ public abstract class TextFormat { * allocations. * * @param <C> carrier of propagation fields, such as an http request + * @since 0.11 */ public abstract static class Setter<C> { @@ -119,6 +125,7 @@ public abstract class TextFormat { * @param carrier holds propagation fields. For example, an outgoing message or http request. * @param key the key of the field. * @param value the value of the field. + * @since 0.11 */ public abstract void put(C carrier, String key, String value); } @@ -129,6 +136,7 @@ public abstract class TextFormat { * @param carrier holds propagation fields. For example, an outgoing message or http request. * @param getter invoked for each propagation key to get. * @throws SpanContextParseException if the input is invalid + * @since 0.11 */ public abstract <C> SpanContext extract(C carrier, Getter<C> getter) throws SpanContextParseException; @@ -140,6 +148,7 @@ public abstract class TextFormat { * allocations. * * @param <C> carrier of propagation fields, such as an http request + * @since 0.11 */ public abstract static class Getter<C> { @@ -149,6 +158,7 @@ public abstract class TextFormat { * @param carrier carrier of propagation fields, such as an http request * @param key the key of the field. * @return the first value of the given propagation {@code key} or returns {@code null}. + * @since 0.11 */ @Nullable public abstract String get(C carrier, String key); diff --git a/api/src/main/java/io/opencensus/trace/samplers/Samplers.java b/api/src/main/java/io/opencensus/trace/samplers/Samplers.java index 3d33a7f1..c10610a0 100644 --- a/api/src/main/java/io/opencensus/trace/samplers/Samplers.java +++ b/api/src/main/java/io/opencensus/trace/samplers/Samplers.java @@ -19,7 +19,11 @@ package io.opencensus.trace.samplers; import io.opencensus.trace.Sampler; import io.opencensus.trace.Span; -/** Static class to access a set of pre-defined {@link Sampler Samplers}. */ +/** + * Static class to access a set of pre-defined {@link Sampler Samplers}. + * + * @since 0.5 + */ public final class Samplers { private static final Sampler ALWAYS_SAMPLE = new AlwaysSampleSampler(); private static final Sampler NEVER_SAMPLE = new NeverSampleSampler(); @@ -31,6 +35,7 @@ public final class Samplers { * Returns a {@link Sampler} that always makes a "yes" decision on {@link Span} sampling. * * @return a {@code Sampler} that always makes a "yes" decision on {@code Span} sampling. + * @since 0.5 */ public static Sampler alwaysSample() { return ALWAYS_SAMPLE; @@ -40,6 +45,7 @@ public final class Samplers { * Returns a {@link Sampler} that always makes a "no" decision on {@link Span} sampling. * * @return a {@code Sampler} that always makes a "no" decision on {@code Span} sampling. + * @since 0.5 */ public static Sampler neverSample() { return NEVER_SAMPLE; @@ -51,6 +57,7 @@ public final class Samplers { * @param probability The desired probability of sampling. Must be within [0.0, 1.0]. * @return a {@code Sampler} that makes a "yes" decision with a given probability. * @throws IllegalArgumentException if {@code probability} is out of range + * @since 0.5 */ public static Sampler probabilitySampler(double probability) { return ProbabilitySampler.create(probability); diff --git a/api/src/main/java/io/opencensus/trace/unsafe/ContextUtils.java b/api/src/main/java/io/opencensus/trace/unsafe/ContextUtils.java index cf0d2a65..f7905c25 100644 --- a/api/src/main/java/io/opencensus/trace/unsafe/ContextUtils.java +++ b/api/src/main/java/io/opencensus/trace/unsafe/ContextUtils.java @@ -24,11 +24,17 @@ import io.opencensus.trace.Span; * * <p>Users must interact with the current Context via the public APIs in {@link * io.opencensus.trace.Tracer} and avoid usages of the {@link #CONTEXT_SPAN_KEY} directly. + * + * @since 0.5 */ public final class ContextUtils { // No instance of this class. private ContextUtils() {} - /** The {@link io.grpc.Context.Key} used to interact with {@link io.grpc.Context}. */ + /** + * The {@link io.grpc.Context.Key} used to interact with {@link io.grpc.Context}. + * + * @since 0.5 + */ public static final Context.Key<Span> CONTEXT_SPAN_KEY = Context.key("opencensus-trace-span-key"); } |