Added Prometheus metrics support with opt-in CLI flag.
Audit / Dependencies (push) Successful in 7s
CI / Formatting (push) Successful in 5s
CI / Linting (push) Successful in 5s
CI / Tests (push) Successful in 16s
CI / Type Checking (push) Successful in 11s
CI / Spelling (push) Successful in 5s

This commit is contained in:
2026-03-18 19:43:30 -04:00
parent 6aa8527adc
commit a8d3a5c421
12 changed files with 452 additions and 46 deletions
+10 -4
View File
@@ -22,6 +22,7 @@ from typing import TYPE_CHECKING
import discord
from crabstero import metrics
from crabstero.messages import ingest_message
if TYPE_CHECKING:
@@ -74,18 +75,23 @@ async def ingest_channel(
logger.info("[%s] Starting ingestion of textable channel history.", channel.id)
count = 0
async for message in channel.history(limit=MAXIMUM_MESSAGES_PER_CHANNEL):
count += 1
await ingest_message(db, message)
with metrics.CHANNEL_INGESTION_DURATION.time():
count = 0
async for message in channel.history(limit=MAXIMUM_MESSAGES_PER_CHANNEL):
count += 1
await ingest_message(db, message)
metrics.CHANNEL_INGESTION_MESSAGES.observe(count)
logger.info(
"[%s] Ingestion of channel history complete. %d messages ingested.",
channel.id,
count,
)
metrics.CHANNELS_INGESTED.inc()
except Exception:
metrics.CHANNEL_INGESTION_ERRORS.inc()
logger.exception(
"[%s] An error occurred while ingesting textable channel history!",
channel.id,