Skip to content

Commit

Permalink
Excavator: Upgrades Baseline to the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-excavator-bot committed Aug 20, 2021
1 parent 8890858 commit ed5e5a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,24 +33,24 @@ interface TimeBounds extends Comparable<TimeBounds> {
long endNanos();

default long startNanos() {
return TimeUnit.NANOSECONDS.convert(startMicros(), TimeUnit.MICROSECONDS);
return TimeUnit.NANOSECONDS.convert(Duration.of(startMicros(), ChronoUnit.MICROS));
}

default long durationNanos() {
return endNanos() - startNanos();
}

default long durationMicros() {
return TimeUnit.MICROSECONDS.convert(durationNanos(), TimeUnit.NANOSECONDS);
return TimeUnit.MICROSECONDS.convert(Duration.ofNanos(durationNanos()));
}

static TimeBounds fromSpans(Collection<Span> spans) {
long earliestStartMicros =
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()
Expand Down

0 comments on commit ed5e5a5

Please sign in to comment.