Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MentorRequest: export queued requests to Prometheus #76

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cogs/mentor_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
"add_thead": "INSERT INTO track_threads VALUES (:track_slug, :message_id)",
}
PROM_TRACK_COUNT = prometheus_client.Gauge("mentor_requests_tracks", "Number of tracks")
PROM_REQUEST_COUNT = prometheus_client.Gauge("mentor_requests", "Number of requests")
ACTIVE_REQUESTS = prometheus_client.Gauge("mentor_requests", "Number of requests")
REQUEST_QUEUED = prometheus_client.Counter(
"mentor_request_queued", "Number of requests queued", ["track"],
)
PROM_UPDATE_HIST = prometheus_client.Histogram("mentor_requests_update", "Update requests")
PROM_UPDATE_TRACK_HIST = prometheus_client.Histogram(
"mentor_requests_update_track", "Update one track", ["track"],
Expand Down Expand Up @@ -111,6 +114,7 @@ async def update_track_requests(self, track: str) -> dict[str, str]:
"message_id": message.id,
}
self.conn.execute(QUERY["add_request"], data)
REQUEST_QUEUED.labels(track).inc()
return requests

@PROM_UPDATE_HIST.time()
Expand Down Expand Up @@ -166,7 +170,7 @@ async def update_mentor_requests(self) -> None:
except discord.errors.NotFound:
logger.info("Message not found; dropping from DB. %s", message.jump_url)
await asyncio.sleep(0.1)
PROM_REQUEST_COUNT.set(len(self.requests))
ACTIVE_REQUESTS.set(len(self.requests))
logger.debug("End update_mentor_requests()")

@tasks.loop(minutes=10)
Expand Down