Micrometer: StackdriverMeterRegistry negative bucketCounts value

Created on 26 Mar 2019  路  1Comment  路  Source: micrometer-metrics/micrometer

Occasionally these types of errors are logged:
i.m.s.StackdriverMeterRegistry - failed to send metrics to stackdriver: INVALID_ARGUMENT: Field timeSeries[13].points[0].distributionValue had an invalid value: Distribution bucket_counts(26) has a negative count.

I tracked it down to this line in the StackdriverMeterRegistry class:
// add the "+infinity" bucket, which does NOT have a corresponding bucket boundary bucketCounts.add(snapshot.count() - truncatedSum.get());
Sometimes the snapshot.count() method returns 0, while bucketCounts may contain positive values resulting in a negative bucket size at the end of the bucketCounts list. I think this is a bug in the code creating the snapshots, but locally I made a workaround to ensure non-negative values:
bucketCounts.add(Math.max(snapshot.count(), truncatedSum.get()) - truncatedSum.get());

bug stackdriver

Most helpful comment

This is a side effect of #998.

>All comments

This is a side effect of #998.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jonatan-ivanov picture jonatan-ivanov  路  3Comments

edeandrea picture edeandrea  路  3Comments

adrianboimvaser picture adrianboimvaser  路  3Comments

wilkinsona picture wilkinsona  路  3Comments

ITman1 picture ITman1  路  4Comments