Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a few warnings and removed deprecated methods #47

Merged
merged 1 commit into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/src/main/java/openconsensus/internal/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public static void checkIndex(int index, int size) {
* @param arg the argument to check for null.
* @param errorMessage the message to use for the exception. Will be converted to a string using
* {@link String#valueOf(Object)}.
* @param <T> type of an argument to check.
* @return the argument, if it passes the null check.
*/
public static <T> T checkNotNull(T arg, @javax.annotation.Nullable Object errorMessage) {
Expand All @@ -117,6 +118,7 @@ public static <T> T checkNotNull(T arg, @javax.annotation.Nullable Object errorM
* @param list the argument list to check for null.
* @param errorMessage the message to use for the exception. Will be converted to a string using
* {@link String#valueOf(Object)}.
* @param <T> type of an argument to check.
*/
public static <T> void checkListElementNotNull(
List<T> list, @javax.annotation.Nullable Object errorMessage) {
Expand All @@ -130,6 +132,10 @@ public static <T> void checkListElementNotNull(
/**
* Compares two Objects for equality. This functionality is provided by {@code
* Objects.equal(Object, Object)} in Java 7.
*
* @param x object to compare with.
* @param y object to compare to.
* @return {@code true} if x is the same as the y; {@code false} otherwise.
*/
public static boolean equalsObjects(
@javax.annotation.Nullable Object x, @javax.annotation.Nullable Object y) {
Expand Down
18 changes: 0 additions & 18 deletions api/src/main/java/openconsensus/stats/MeasureMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import javax.annotation.concurrent.NotThreadSafe;
import openconsensus.internal.Utils;
import openconsensus.metrics.data.AttachmentValue;
import openconsensus.metrics.data.AttachmentValue.AttachmentValueString;
import openconsensus.stats.data.Measure;
import openconsensus.stats.data.Measure.MeasureDouble;
import openconsensus.stats.data.Measure.MeasureLong;
Expand Down Expand Up @@ -55,23 +54,6 @@ public abstract class MeasureMap {
*/
public abstract MeasureMap put(MeasureLong measure, long value);

/**
* Associate the contextual information of an {@code Exemplar} to this {@link MeasureMap}.
* Contextual information is represented as {@code String} key-value pairs.
*
* <p>If this method is called multiple times with the same key, only the last value will be kept.
*
* @param key the key of contextual information of an {@code Exemplar}.
* @param value the string representation of contextual information of an {@code Exemplar}.
* @return this
* @since 0.1.0
* @deprecated in favor of {@link #putAttachment(String, AttachmentValue)}.
*/
@Deprecated
public MeasureMap putAttachment(String key, String value) {
return putAttachment(key, AttachmentValueString.create(value));
}

/**
* Associate the contextual information of an {@code Exemplar} to this {@link MeasureMap}.
* Contextual information is represented as a {@code String} key and an {@link AttachmentValue}.
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/openconsensus/stats/Stats.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public final class Stats {
/**
* Returns the default {@link StatsRecorder}.
*
* @return stats recorder.
* @since 0.1.0
*/
public static StatsRecorder getStatsRecorder() {
Expand All @@ -40,6 +41,7 @@ public static StatsRecorder getStatsRecorder() {
/**
* Returns the default {@link ViewManager}.
*
* @return view manager.
* @since 0.1.0
*/
public static ViewManager getViewManager() {
Expand Down
1 change: 1 addition & 0 deletions api/src/main/java/openconsensus/stats/StatsComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public abstract class StatsComponent {
/**
* Returns the default {@link StatsRecorder}.
*
* @return stats recorder.
* @since 0.1.0
*/
public abstract StatsRecorder getStatsRecorder();
Expand Down
38 changes: 1 addition & 37 deletions api/src/main/java/openconsensus/stats/view/data/Aggregation.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,43 +124,6 @@ public final <T> T match(
}
}

/**
* Calculate mean on aggregated {@code MeasureValue}s.
*
* @since 0.1.0
* @deprecated since 0.13, use {@link Distribution} instead.
*/
@Immutable
@AutoValue
@Deprecated
@AutoValue.CopyAnnotations
public abstract static class Mean extends Aggregation {

Mean() {}

private static final Mean INSTANCE = new AutoValue_Aggregation_Mean();

/**
* Construct a {@code Mean}.
*
* @return a new {@code Mean}.
* @since 0.1.0
*/
public static Mean create() {
return INSTANCE;
}

@Override
public final <T> T match(
Function<? super Sum, T> p0,
Function<? super Count, T> p1,
Function<? super Distribution, T> p2,
Function<? super LastValue, T> p3,
Function<? super Aggregation, T> defaultFunction) {
return defaultFunction.apply(this);
}
}

/**
* Calculate distribution stats on aggregated {@code MeasureValue}s. Distribution includes mean,
* count, histogram, min, max and sum of squared deviations.
Expand All @@ -176,6 +139,7 @@ public abstract static class Distribution extends Aggregation {
/**
* Construct a {@code Distribution}.
*
* @param bucketBoundaries bucket boundaries to use for distribution.
* @return a new {@code Distribution}.
* @since 0.1.0
*/
Expand Down
5 changes: 5 additions & 0 deletions api/src/main/java/openconsensus/stats/view/data/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,31 @@ public abstract class View {
/**
* Name of view. Must be unique.
*
* @return name of the view.
* @since 0.1.0
*/
public abstract Name getName();

/**
* More detailed description, for documentation purposes.
*
* @return description of the view.
* @since 0.1.0
*/
public abstract String getDescription();

/**
* Measure type of this view.
*
* @return measure type of this view.
* @since 0.1.0
*/
public abstract Measure getMeasure();

/**
* The {@link Aggregation} associated with this {@link View}.
*
* @return the {@link Aggregation} associated with this {@link View}.
* @since 0.1.0
*/
public abstract Aggregation getAggregation();
Expand All @@ -74,6 +78,7 @@ public abstract class View {
* <p>{@link Measure} will be recorded in a "greedy" way. That is, every view aggregates every
* measure. This is similar to doing a GROUPBY on view’s columns. Columns must be unique.
*
* @return columns (a.k.a Tag Keys) to match with the associated {@link Measure}.
* @since 0.1.0
*/
public abstract List<TagKey> getColumns();
Expand Down
22 changes: 2 additions & 20 deletions api/src/main/java/openconsensus/tags/data/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,12 @@
@AutoValue
public abstract class Tag {

private static final TagMetadata METADATA_UNLIMITED_PROPAGATION =
/** Default propagation metadata - unlimited propagation. */
public static final TagMetadata METADATA_UNLIMITED_PROPAGATION =
TagMetadata.create(TagTtl.UNLIMITED_PROPAGATION);

Tag() {}

/**
* Creates a {@code Tag} from the given key and value.
*
* <p>For backwards-compatibility this method still produces propagating {@link Tag}s.
*
* <p>This is equivalent to calling {@code create(key, value,
* TagMetadata.create(TagTtl.UNLIMITED_PROPAGATION))}.
*
* @param key the tag key.
* @param value the tag value.
* @return a {@code Tag} with the given key and value.
* @since 0.1.0
* @deprecated in favor of {@link #create(TagKey, TagValue, TagMetadata)}.
*/
@Deprecated
public static Tag create(TagKey key, TagValue value) {
return create(key, value, METADATA_UNLIMITED_PROPAGATION);
}

/**
* Creates a {@code Tag} from the given key, value and metadata.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public abstract class TextFormat {
* clear fields as they couldn't have been set before. If it is a mutable, retryable object,
* successive calls should clear these fields first.
*
* @return list of fields that will be used by this formatter.
* @since 0.1.0
*/
// The use cases of this are:
Expand All @@ -100,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.
* @param <C> carrier of propagation fields, such as an http request
* @since 0.1.0
*/
public abstract <C> void inject(SpanContext spanContext, C carrier, Setter<C> setter);
Expand Down Expand Up @@ -134,6 +136,8 @@ public abstract static class Setter<C> {
*
* @param carrier holds propagation fields. For example, an outgoing message or http request.
* @param getter invoked for each propagation key to get.
* @param <C> carrier of propagation fields, such as an http request.
* @return carrier of propagated fields.
* @throws SpanContextParseException if the input is invalid
* @since 0.1.0
*/
Expand All @@ -146,15 +150,15 @@ public abstract <C> SpanContext extract(C carrier, Getter<C> getter)
* <p>{@code Getter} is stateless and allows to be saved as a constant to avoid runtime
* allocations.
*
* @param <C> carrier of propagation fields, such as an http request
* @param <C> carrier of propagation fields, such as an http request.
* @since 0.1.0
*/
public abstract static class Getter<C> {

/**
* Returns the first value of the given propagation {@code key} or returns {@code null}.
*
* @param carrier carrier of propagation fields, such as an http request
* @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.1.0
Expand Down