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

Polish gh-5836 #5915

Merged
merged 1 commit into from
Feb 12, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class StackdriverDistributionSummary extends StepDistributionSummary {

public StackdriverDistributionSummary(Id id, Clock clock, DistributionStatisticConfig distributionStatisticConfig,
StackdriverDistributionSummary(Id id, Clock clock, DistributionStatisticConfig distributionStatisticConfig,
double scale, long stepMillis) {
super(id, clock, distributionStatisticConfig, scale, stepMillis,
stackdriverHistogram(clock, distributionStatisticConfig));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,15 +505,17 @@ private TimeInterval interval(MetricDescriptor.MetricKind metricKind) {
Distribution distribution(HistogramSnapshot snapshot, boolean timeDomain) {
CountAtBucket[] histogram = snapshot.histogramCounts();

List<Long> bucketCounts = Arrays.stream(histogram)
.map(CountAtBucket::count)
.map(Double::longValue)
.collect(toCollection(ArrayList::new));
long cumulativeCount = Arrays.stream(histogram).mapToLong(c -> (long) c.count()).sum();
List<Long> bucketCounts = new ArrayList<>();
long cumulativeCount = 0L;
for (CountAtBucket countAtBucket : histogram) {
long count = (long) countAtBucket.count();
bucketCounts.add(count);
cumulativeCount += count;
}

// no-op histogram will have no buckets; other histograms should have at least
// the +Inf bucket
if (!bucketCounts.isEmpty() && bucketCounts.size() > 1) {
if (bucketCounts.size() > 1) {
// the rightmost bucket should be the infinity bucket; do not trim that
int endIndex = bucketCounts.size() - 2;
// trim zero-count buckets on the right side of the domain
Expand All @@ -525,7 +527,7 @@ Distribution distribution(HistogramSnapshot snapshot, boolean timeDomain) {
break;
}
}
long infCount = bucketCounts.get(bucketCounts.size() - 1);
Long infCount = bucketCounts.get(bucketCounts.size() - 1);
bucketCounts = bucketCounts.subList(0, lastNonZeroIndex + 1);
// infinite bucket count of 0 can be omitted
bucketCounts.add(infCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

class StackdriverTimer extends StepTimer {

public StackdriverTimer(Id id, Clock clock, DistributionStatisticConfig distributionStatisticConfig,
StackdriverTimer(Id id, Clock clock, DistributionStatisticConfig distributionStatisticConfig,
PauseDetector pauseDetector, TimeUnit baseTimeUnit, long stepDurationMillis) {
super(id, clock, distributionStatisticConfig, pauseDetector, baseTimeUnit, stepDurationMillis,
stackdriverHistogram(clock, distributionStatisticConfig));
Expand Down