switch to mongo for metric storage
Some checks failed
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Failing after 1m1s

This commit is contained in:
Lee 2024-04-18 13:31:22 +01:00
parent c91a4afdf9
commit 1c685ca414
5 changed files with 15 additions and 5 deletions

@ -83,6 +83,12 @@
<artifactId>jedis</artifactId>
</dependency>
<!-- MongoDB for data storage -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<!-- Libraries -->
<dependency>
<groupId>org.projectlombok</groupId>

@ -1,6 +1,6 @@
package xyz.mcutils.backend.repository;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.mongodb.repository.MongoRepository;
import xyz.mcutils.backend.service.metric.Metric;
/**
@ -8,4 +8,4 @@ import xyz.mcutils.backend.service.metric.Metric;
*
* @author Braydon
*/
public interface MetricsRepository extends CrudRepository<Metric<?>, String> { }
public interface MetricsRepository extends MongoRepository<Metric<?>, String> { }

@ -101,7 +101,7 @@ public class MetricService {
for (Metric<?> metric : metrics.values()) {
saveMetric(metric);
}
log.info("Saved {} metrics to Redis", metrics.size());
log.info("Saved {} metrics to MongoDB", metrics.size());
}
/**

@ -7,12 +7,12 @@ import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.redis.core.RedisHash;
import org.springframework.data.mongodb.core.mapping.Document;
import xyz.mcutils.backend.service.MetricService;
@AllArgsConstructor
@Getter @Setter @ToString
@RedisHash(value = "metric")
@Document("metrics")
public abstract class Metric<T> {
/**
* The id of the metric.

@ -17,6 +17,10 @@ spring:
database: 1
auth: "" # Leave blank for no auth
mongodb:
uri: mongodb://localhost:27017
database: database
# Disable default metrics
management:
endpoints: