From 1c123b5d4f54b00506161b60d4d7c9f46114c976 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 16 Aug 2023 17:24:07 -0400 Subject: [PATCH] loottracker: add metrics --- .../loottracker/LootTrackerController.java | 23 +++++++++++++++++++ .../src/main/resources/application.yaml | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/http-service/src/main/java/net/runelite/http/service/loottracker/LootTrackerController.java b/http-service/src/main/java/net/runelite/http/service/loottracker/LootTrackerController.java index 9d01a04..5e24fdb 100644 --- a/http-service/src/main/java/net/runelite/http/service/loottracker/LootTrackerController.java +++ b/http-service/src/main/java/net/runelite/http/service/loottracker/LootTrackerController.java @@ -26,11 +26,14 @@ package net.runelite.http.service.loottracker; import com.google.gson.Gson; +import io.micrometer.core.instrument.MeterRegistry; import java.util.Collection; import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.loottracker.LootRecord; +import net.runelite.http.api.loottracker.LootRecordType; import net.runelite.http.service.util.redis.RedisPool; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -46,6 +49,12 @@ public class LootTrackerController @Autowired private RedisPool redisPool; + @Autowired + private MeterRegistry meterRegistry; + + @Value("${runelite.loottracker.metrics}") + private boolean enableMetrics; + @RequestMapping(method = RequestMethod.POST) public void storeLootRecord(@RequestBody Collection records) { @@ -53,5 +62,19 @@ public void storeLootRecord(@RequestBody Collection records) { jedis.publish("drops", GSON.toJson(records)); } + + if (enableMetrics) + { + for (LootRecord record : records) + { + if (record.getType() == LootRecordType.EVENT || record.getType() == LootRecordType.NPC) + { + meterRegistry.counter("runelite loottracker", + "type", record.getType().name(), + "name", record.getEventId()) + .increment(); + } + } + } } } \ No newline at end of file diff --git a/http-service/src/main/resources/application.yaml b/http-service/src/main/resources/application.yaml index 8f135ba..ffafb36 100644 --- a/http-service/src/main/resources/application.yaml +++ b/http-service/src/main/resources/application.yaml @@ -46,4 +46,6 @@ runelite: worlds: url: http://www.runescape.com/g=oldscape/slr.ws?order=LPWM item: - digestUrl: https://secure.runescape.com/m=itemdb_oldschool/digest.csv \ No newline at end of file + digestUrl: https://secure.runescape.com/m=itemdb_oldschool/digest.csv + loottracker: + metrics: false \ No newline at end of file