diff --git a/build.gradle b/build.gradle index 7f06480b0..d76649fa4 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ buildscript { classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.2.0' classpath 'com.palantir.gradle.revapi:gradle-revapi:1.5.0' classpath 'gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0' - classpath 'com.palantir.baseline:gradle-baseline-java:4.9.0' + classpath 'com.palantir.baseline:gradle-baseline-java:4.22.0' classpath 'com.palantir.gradle.gitversion:gradle-git-version:0.12.3' classpath 'gradle.plugin.org.inferred:gradle-processors:3.3.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.0.0' diff --git a/tracing-test-utils/src/main/java/com/palantir/tracing/HtmlFormatter.java b/tracing-test-utils/src/main/java/com/palantir/tracing/HtmlFormatter.java index 586121649..05773b24c 100644 --- a/tracing-test-utils/src/main/java/com/palantir/tracing/HtmlFormatter.java +++ b/tracing-test-utils/src/main/java/com/palantir/tracing/HtmlFormatter.java @@ -26,10 +26,12 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; +import java.time.Duration; import java.time.Instant; import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.Collection; import java.util.Comparator; import java.util.Map; @@ -116,11 +118,11 @@ private void renderAllSpansForOneTraceId(String traceId, SpanAnalyzer.Result ana } private void header(StringBuilder sb) throws IOException { - OffsetDateTime startTime = Instant.ofEpochMilli( - TimeUnit.MILLISECONDS.convert(config.bounds().startMicros(), TimeUnit.MICROSECONDS)) + OffsetDateTime startTime = Instant.ofEpochMilli(TimeUnit.MILLISECONDS.convert( + Duration.of(config.bounds().startMicros(), ChronoUnit.MICROS))) .atOffset(ZoneOffset.UTC); - OffsetDateTime endTime = Instant.ofEpochMilli( - TimeUnit.MILLISECONDS.convert(config.bounds().endNanos(), TimeUnit.NANOSECONDS)) + OffsetDateTime endTime = Instant.ofEpochMilli(TimeUnit.MILLISECONDS.convert( + Duration.ofNanos(config.bounds().endNanos()))) .atOffset(ZoneOffset.UTC); sb.append(template( "header.html", @@ -167,7 +169,7 @@ private void formatSpan(Span span, boolean suspectedCollision, StringBuilder sb) Utils.renderDuration( transposedStartMicros + TimeUnit.MICROSECONDS.convert( - span.getDurationNanoSeconds(), TimeUnit.NANOSECONDS), + Duration.ofNanos(span.getDurationNanoSeconds())), TimeUnit.MICROSECONDS)) .put("{{OPERATION}}", span.getOperation()) .put("{{DURATION}}", Utils.renderDuration(span.getDurationNanoSeconds(), TimeUnit.NANOSECONDS)) diff --git a/tracing-test-utils/src/main/java/com/palantir/tracing/TimeBounds.java b/tracing-test-utils/src/main/java/com/palantir/tracing/TimeBounds.java index 23f49600c..13656b26c 100644 --- a/tracing-test-utils/src/main/java/com/palantir/tracing/TimeBounds.java +++ b/tracing-test-utils/src/main/java/com/palantir/tracing/TimeBounds.java @@ -17,6 +17,8 @@ package com.palantir.tracing; import com.palantir.tracing.api.Span; +import java.time.Duration; +import java.time.temporal.ChronoUnit; import java.util.Collection; import java.util.Comparator; import java.util.concurrent.TimeUnit; @@ -31,7 +33,7 @@ interface TimeBounds extends Comparable { long endNanos(); default long startNanos() { - return TimeUnit.NANOSECONDS.convert(startMicros(), TimeUnit.MICROSECONDS); + return TimeUnit.NANOSECONDS.convert(Duration.of(startMicros(), ChronoUnit.MICROS)); } default long durationNanos() { @@ -39,7 +41,7 @@ default long durationNanos() { } default long durationMicros() { - return TimeUnit.MICROSECONDS.convert(durationNanos(), TimeUnit.NANOSECONDS); + return TimeUnit.MICROSECONDS.convert(Duration.ofNanos(durationNanos())); } static TimeBounds fromSpans(Collection spans) { @@ -47,8 +49,8 @@ static TimeBounds fromSpans(Collection spans) { spans.stream().mapToLong(Span::getStartTimeMicroSeconds).min().getAsLong(); long latestEndNanos = spans.stream() .mapToLong(span -> { - long startTimeNanos = - TimeUnit.NANOSECONDS.convert(span.getStartTimeMicroSeconds(), TimeUnit.MICROSECONDS); + long startTimeNanos = TimeUnit.NANOSECONDS.convert( + Duration.of(span.getStartTimeMicroSeconds(), ChronoUnit.MICROS)); return startTimeNanos + span.getDurationNanoSeconds(); }) .max()