diff options
author | Yang Song <songy23@users.noreply.github.com> | 2018-04-16 14:38:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-16 14:38:01 -0700 |
commit | 74d1f5dbaad7d24282edfaa95c6780bbe8191a98 (patch) | |
tree | ed5b33866cf4ad8ba05853d63dcb2bcf265907a6 /impl_core/src | |
parent | 3e4352b3684b4646a82eef4f2da66038531d821e (diff) | |
download | opencensus-java-74d1f5dbaad7d24282edfaa95c6780bbe8191a98.tar.gz |
Improve Duration.toMillis() (#1132)
* Improve java doc for toMillis().
* Make toMillis() non-static.
Diffstat (limited to 'impl_core/src')
3 files changed, 5 insertions, 5 deletions
diff --git a/impl_core/src/main/java/io/opencensus/implcore/stats/IntervalBucket.java b/impl_core/src/main/java/io/opencensus/implcore/stats/IntervalBucket.java index f114bea6..65b768da 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/stats/IntervalBucket.java +++ b/impl_core/src/main/java/io/opencensus/implcore/stats/IntervalBucket.java @@ -81,7 +81,7 @@ final class IntervalBucket { checkArgument( elapsedTime.compareTo(ZERO) >= 0 && elapsedTime.compareTo(duration) < 0, "This bucket must be current."); - return ((double) Duration.toMillis(elapsedTime)) / Duration.toMillis(duration); + return ((double) elapsedTime.toMillis()) / duration.toMillis(); } void clearStats() { diff --git a/impl_core/src/main/java/io/opencensus/implcore/stats/MutableViewData.java b/impl_core/src/main/java/io/opencensus/implcore/stats/MutableViewData.java index f0938c06..d60715b5 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/stats/MutableViewData.java +++ b/impl_core/src/main/java/io/opencensus/implcore/stats/MutableViewData.java @@ -287,7 +287,7 @@ abstract class MutableViewData { super(view); Duration totalDuration = ((View.AggregationWindow.Interval) view.getWindow()).getDuration(); this.totalDuration = totalDuration; - this.bucketDuration = Duration.fromMillis(Duration.toMillis(totalDuration) / N); + this.bucketDuration = Duration.fromMillis(totalDuration.toMillis() / N); // When initializing. add N empty buckets prior to the start timestamp of this // IntervalMutableViewData, so that the last bucket will be the current one in effect. @@ -346,8 +346,8 @@ abstract class MutableViewData { checkArgument( now.compareTo(startOfLastBucket) >= 0, "Current time must be within or after the last bucket."); - long elapsedTimeMillis = Duration.toMillis(now.subtractTimestamp(startOfLastBucket)); - long numOfPadBuckets = elapsedTimeMillis / Duration.toMillis(bucketDuration); + long elapsedTimeMillis = now.subtractTimestamp(startOfLastBucket).toMillis(); + long numOfPadBuckets = elapsedTimeMillis / bucketDuration.toMillis(); shiftBucketList(numOfPadBuckets, now); } diff --git a/impl_core/src/main/java/io/opencensus/implcore/trace/export/SpanExporterImpl.java b/impl_core/src/main/java/io/opencensus/implcore/trace/export/SpanExporterImpl.java index c8ed237d..e702d38c 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/trace/export/SpanExporterImpl.java +++ b/impl_core/src/main/java/io/opencensus/implcore/trace/export/SpanExporterImpl.java @@ -145,7 +145,7 @@ public final class SpanExporterImpl extends SpanExporter { private Worker(int bufferSize, Duration scheduleDelay) { spans = new ArrayList<SpanImpl>(bufferSize); this.bufferSize = bufferSize; - this.scheduleDelayMillis = Duration.toMillis(scheduleDelay); + this.scheduleDelayMillis = scheduleDelay.toMillis(); } // Returns an unmodifiable list of all buffered spans data to ensure that any registered |