mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-13 22:15:26 +00:00
exposed leaderboard timing metrics data as a structured type, not TabularData;
this way the data shows cleanly in JConsole, but the Prometheus JMX adapter doesn't find it. I need to find out how to convice Prometheus to pick up this data from the right place Change-Id: Ic2a56644deb1e1c4148eebc63895f1d06c608e61
This commit is contained in:
1 parent
b7f04f98c3
commit
8789e2f05d
2 files changed
+41
-56
No files matched your search
@@ -2,11 +2,16 @@ package com.sap.sailing.server;
|
||||
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.openmbean.TabularData;
|
||||
|
||||
import com.sap.sse.common.Named;
|
||||
|
||||
public interface LeaderboardMXBean extends Named {
|
||||
public static interface ComputationTimeAverage {
|
||||
int getNumberOfComputations();
|
||||
long getAverageComputeDurationInMillis();
|
||||
long getAverageRangeInMillis();
|
||||
}
|
||||
|
||||
ObjectName getObjectName() throws MalformedObjectNameException;
|
||||
int getNumberOfCompetitors();
|
||||
int getNumberOfAllCompetitors();
|
||||
@@ -14,5 +19,5 @@ public interface LeaderboardMXBean extends Named {
|
||||
String getType();
|
||||
long getDelayToLiveInMillis();
|
||||
String getBoatClass();
|
||||
TabularData getComputationTimeAverages();
|
||||
ComputationTimeAverage[] getComputationTimeAverages();
|
||||
}
|
||||
+34
-54
@@ -1,21 +1,10 @@
|
||||
package com.sap.sailing.server.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import javax.management.openmbean.OpenType;
|
||||
import javax.management.openmbean.SimpleType;
|
||||
import javax.management.openmbean.TabularData;
|
||||
import javax.management.openmbean.TabularDataSupport;
|
||||
import javax.management.openmbean.TabularType;
|
||||
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.server.LeaderboardMXBean;
|
||||
@@ -24,33 +13,10 @@ import com.sap.sse.common.Util;
|
||||
import com.sap.sse.common.Util.Pair;
|
||||
|
||||
public class LeaderboardMXBeanImpl implements LeaderboardMXBean {
|
||||
private static final Logger logger = Logger.getLogger(LeaderboardMXBeanImpl.class.getName());
|
||||
private static final long serialVersionUID = -8420830339429971378L;
|
||||
|
||||
private final static String AVERAGE_RANGE_IN_MILLIS = "averageRangeInMillis";
|
||||
private final static String AVERAGE_COMPUTE_DURATION_IN_MILLIS = "averageComputeDurationInMillis";
|
||||
private final static String NUMBER_OF_COMPUTATIONS = "numberOfComputations";
|
||||
private final static CompositeType rowType;
|
||||
|
||||
private final Leaderboard leaderboard;
|
||||
|
||||
static {
|
||||
CompositeType myRowType;
|
||||
try {
|
||||
myRowType = new CompositeType("LeaderboardComputeTimeStat",
|
||||
"Computation times and numbers for different averaging intervals",
|
||||
new String[] { AVERAGE_RANGE_IN_MILLIS, AVERAGE_COMPUTE_DURATION_IN_MILLIS, NUMBER_OF_COMPUTATIONS },
|
||||
new String[] { "Tells the age of the oldest leaderboard computation request, in milliseconds, still considered in this row",
|
||||
"The average computation duration in milliseconds",
|
||||
"The number of computations performed in this time range" },
|
||||
new OpenType<?>[] { SimpleType.LONG, SimpleType.LONG, SimpleType.INTEGER });
|
||||
} catch (OpenDataException e) {
|
||||
logger.log(Level.SEVERE, "Problem trying to expose leaderboard computation times as MBean", e);
|
||||
myRowType = null;
|
||||
}
|
||||
rowType = myRowType;
|
||||
}
|
||||
|
||||
public LeaderboardMXBeanImpl(Leaderboard leaderboard) {
|
||||
super();
|
||||
this.leaderboard = leaderboard;
|
||||
@@ -96,7 +62,7 @@ public class LeaderboardMXBeanImpl implements LeaderboardMXBean {
|
||||
|
||||
@Override
|
||||
public long getDelayToLiveInMillis() {
|
||||
return leaderboard.getDelayToLiveInMillis();
|
||||
return leaderboard.getDelayToLiveInMillis() == null ? -1 : leaderboard.getDelayToLiveInMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,26 +70,40 @@ public class LeaderboardMXBeanImpl implements LeaderboardMXBean {
|
||||
return leaderboard.getBoatClass().getName();
|
||||
}
|
||||
|
||||
public static class ComputationTimeAverageImpl implements ComputationTimeAverage {
|
||||
private final long averageRangeInMillis;
|
||||
private final long averageComputeDurationInMillis;
|
||||
private final int numberOfComputations;
|
||||
public ComputationTimeAverageImpl(long averageRangeInMillis, long averageComputeDurationInMillis,
|
||||
int numberOfComputations) {
|
||||
super();
|
||||
this.averageRangeInMillis = averageRangeInMillis;
|
||||
this.averageComputeDurationInMillis = averageComputeDurationInMillis;
|
||||
this.numberOfComputations = numberOfComputations;
|
||||
}
|
||||
@Override
|
||||
public long getAverageRangeInMillis() {
|
||||
return averageRangeInMillis;
|
||||
}
|
||||
@Override
|
||||
public long getAverageComputeDurationInMillis() {
|
||||
return averageComputeDurationInMillis;
|
||||
}
|
||||
@Override
|
||||
public int getNumberOfComputations() {
|
||||
return numberOfComputations;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabularData getComputationTimeAverages() {
|
||||
TabularData result;
|
||||
try {
|
||||
result = new TabularDataSupport(
|
||||
new TabularType(
|
||||
"LeaderboardComputeTimeStats",
|
||||
"Describes average leaderboard calculation times and the number of computations",
|
||||
rowType,
|
||||
/* index */ new String[] { AVERAGE_RANGE_IN_MILLIS }));
|
||||
for (final Entry<Duration, Pair<Duration, Integer>> e : getLeaderboard().getComputationTimeStatistics().entrySet()) {
|
||||
final Map<String, Object> rowValues = new HashMap<>();
|
||||
rowValues.put(AVERAGE_RANGE_IN_MILLIS, e.getKey().asMillis());
|
||||
rowValues.put(AVERAGE_COMPUTE_DURATION_IN_MILLIS, e.getValue().getA()==null?-1:e.getValue().getA().asMillis());
|
||||
rowValues.put(NUMBER_OF_COMPUTATIONS, e.getValue().getB());
|
||||
result.put(new CompositeDataSupport(rowType, rowValues));
|
||||
}
|
||||
} catch (OpenDataException e) {
|
||||
logger.log(Level.SEVERE, "Problem trying to expose leaderboard computation times as MBean", e);
|
||||
result = null;
|
||||
public ComputationTimeAverage[] getComputationTimeAverages() {
|
||||
final Map<Duration, Pair<Duration, Integer>> computationTimeStatistics = getLeaderboard().getComputationTimeStatistics();
|
||||
final ComputationTimeAverage[] result = new ComputationTimeAverage[computationTimeStatistics.size()];
|
||||
int i=0;
|
||||
for (final Entry<Duration, Pair<Duration, Integer>> e : computationTimeStatistics.entrySet()) {
|
||||
result[i++] = new ComputationTimeAverageImpl(e.getKey().asMillis(),
|
||||
e.getValue().getA()==null?-1:e.getValue().getA().asMillis(),
|
||||
e.getValue().getB());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user