Implement getValues() on HdrSnapshot.

Description

In spring actuator metrics when exposing Timer we need to expose TOTAL_TIME of timers, for example (cql-requests) metric:

1 2 3 4 5 6 7 8 9 10 "measurements": [ { "statistic": "COUNT", "value": 0 }, { "statistic": "TOTAL_TIME", "value": 0 } ],

We could gather all values and sum using this function:

1 2 3 4 long[] values = ((Timer) m.getSessionMetric(sessionMetric).get()) .getSnapshot() .getValues(); return LongStream.of(values).sum();

But the getSnapshot() method is not implemented on our HdrSnapshot:

1 2 3 4 5 6 7 8 @Override public long[] getValues() { // This can be implemented, but we ran into issues when accessed by concurrent reporters // because HdrHistogram uses an unsafe shared iterator. // So throwing instead since this method should be seldom used anyway. throw new UnsupportedOperationException( "HdrReservoir's snapshots do not implement getValues()"); }

The purpose of this ticket will be to implement getValues() method on HdrReservoir.

Environment

None

Pull Requests

None

Status

Assignee

Unassigned

Reporter

Tomasz Lelek

Labels

None

PM Priority

None

Reproduced in

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

External issue ID

None

Doc Impact

None

Reviewer

None

Size

None

Fix versions

Priority

Major