Skip to content

Commit a4a290d

Browse files
committed
Merge branch 'eperott-convert_nanos'
2 parents 9a97a9f + c0d4b88 commit a4a290d

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

common/src/main/java/com/zegelin/cassandra/exporter/CassandraMetricsUtilities.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ public long getCount() {
6767
@Override
6868
public Iterable<Interval> getIntervals() {
6969
/*
70-
Cassandra's JmxTimerMBean converts the percentile values to microseconds,
71-
which differs to the values returned by Sampling.getSnapshot() (which are in nanoseconds).
70+
Cassandra's JmxTimerMBean converts the percentile values to a parameterised duration unit,
71+
(currently the only usage is microseconds), which differs to the values returned by
72+
Sampling.getSnapshot() (which are always in nanoseconds).
7273
73-
We pay the penalty when running out-of-process to convert from nanoseconds->microseconds->nanoseconds
74-
(and eventually to seconds)!
74+
The conversion from nanoseconds -> seconds happens at a later stage. To keep things simple, we pay the
75+
penalty when running out-of-process to convert from nanoseconds-><duration-unit>->nanoseconds
76+
and then eventually to seconds!
7577
*/
7678
final TimeUnit durationUnit = TimeUnit.valueOf(timer.getDurationUnit().toUpperCase(Locale.US));
7779
final float durationFactor = durationUnit.toNanos(1L);

common/src/main/java/com/zegelin/cassandra/exporter/FactoriesSupplier.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ private static FactoryBuilder.CollectorConstructor timerAsSummaryCollectorConstr
407407
return (name, help, labels, mBean) -> {
408408
final NamedObject<SamplingCounting> samplingCountingNamedObject = CassandraMetricsUtilities.jmxTimerMBeanAsSamplingCounting(mBean);
409409

410-
return new FunctionalMetricFamilyCollector<>(name, help, ImmutableMap.of(labels, samplingCountingNamedObject), samplingAndCountingAsSummary(MetricValueConversionFunctions::microsecondsToSeconds));
410+
return new FunctionalMetricFamilyCollector<>(name, help, ImmutableMap.of(labels, samplingCountingNamedObject),
411+
samplingAndCountingAsSummary(MetricValueConversionFunctions::nanosecondsToSeconds));
412+
411413
};
412414
}
413415

0 commit comments

Comments
 (0)