Skip to content

Commit

Permalink
Merge branch '1.13.x' into 1.14.x
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen committed Feb 12, 2025
2 parents 6e1478f + 717390d commit 30eb827
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
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

0 comments on commit 30eb827

Please sign in to comment.