maybe fix metrics randomly not writing to influx
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m51s
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m51s
This commit is contained in:
parent
547fa075f3
commit
7a5b42e9d7
@ -125,13 +125,18 @@ public class MetricService {
|
||||
* @param metric the metric to save
|
||||
*/
|
||||
private void saveMetric(Metric<?> metric) {
|
||||
try {
|
||||
metricsRepository.save(metric); // Save the metric to the repository
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to save metric to MongoDB", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Push all metrics to InfluxDB.
|
||||
*/
|
||||
private void writeToInflux() {
|
||||
try {
|
||||
List<Point> points = new ArrayList<>();
|
||||
for (Metric<?> metric : metrics.values()) {
|
||||
if (metric.isCollector()) {
|
||||
@ -144,5 +149,8 @@ public class MetricService {
|
||||
}
|
||||
influxWriteApi.writePoints(points);
|
||||
log.info("Wrote {} metrics to Influx", metrics.size());
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to write metrics to Influx", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,10 @@ public class PlayerService {
|
||||
mojangProfile.getProperties() // Raw properties
|
||||
)
|
||||
);
|
||||
((UniquePlayerLookupsMetric) metricService.getMetric(UniquePlayerLookupsMetric.class)).addLookup(uuid); // Add the lookup to the unique player lookups
|
||||
|
||||
// Add the lookup to the unique player lookups metric
|
||||
((UniquePlayerLookupsMetric) metricService.getMetric(UniquePlayerLookupsMetric.class))
|
||||
.addLookup(uuid);
|
||||
|
||||
playerCacheRepository.save(player);
|
||||
player.getCache().setCached(false);
|
||||
|
@ -100,8 +100,9 @@ public class ServerService {
|
||||
((JavaMinecraftServer) server.getServer()).setMojangBlocked(mojangService.isServerBlocked(hostname));
|
||||
}
|
||||
|
||||
// Add the server lookup to the unique server lookups metric
|
||||
((UniqueServerLookupsMetric) metricService.getMetric(UniqueServerLookupsMetric.class))
|
||||
.addLookup("%s-%s:%s".formatted(platformName, hostname, port)); // Add the server lookup to the unique server lookups
|
||||
.addLookup("%s-%s:%s".formatted(platformName, hostname, port));
|
||||
|
||||
log.info("Found server: {}:{}", hostname, port);
|
||||
serverCacheRepository.save(server);
|
||||
|
Loading…
Reference in New Issue
Block a user