Skip to content

feat: add Prometheus metrics to ws-server - #248

Merged
TheCodeHeist-Coder merged 2 commits into
TheCodeHeist-Coder:mainfrom
spikedeeev:feat/ws-server-prometheus-metrics
Nov 23, 2026
Merged

TheCodeHeist-Coder merged 2 commits into
TheCodeHeist-Coder:mainfrom
spikedeeev:feat/ws-server-prometheus-metrics

Conversation

@spikedeeev

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a private Prometheus /metrics endpoint to ws-server for live-quiz observability.

Exposes aggregate gauges and counters for:

  • Open WebSocket connections
  • Sessions with an active question timer
  • Submitted versus persisted answers
  • Answer queue flush failures
  • Answer score transaction errors
  • Question-close latency from timer deadline to results broadcast

The metrics listener runs on a separate port and is not published publicly in production. Metrics contain no session or participant labels.

Adds focused metrics tests and documents the endpoint in ARCHITECTURE.md.

Related issue

No issue: this addresses the missing operational visibility described by the live-quiz observability requirement.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactoring
  • Performance
  • Tests
  • Build / CI / deployment

Which services does this touch?

  • apps/frontend
  • apps/http-server
  • apps/ws-server
  • apps/genAI
  • packages/db (schema or Prisma changes)
  • Docker / CI

How did you test this?

  • Ran pnpm --filter ws-server test: 61 tests passed.
  • Ran pnpm --filter ws-server run check-types: passed.
  • Ran pnpm --filter ws-server run build: passed.
  • Started the Docker Compose services and confirmed ws-server listens on port 9090.
  • Confirmed GET http://127.0.0.1:9090/metrics returns HTTP 200 and Prometheus text format.
  • Opened a real WebSocket connection and confirmed rexial_ws_connections_open changed from 0 to 1, then returned to 0 after disconnect.
  • Confirmed port 9090 is published only on host loopback in development and not published in production Compose configuration.
  • Answer persistence and timer-latency counters should be verified during a live multi-participant quiz.

Checklist

  • I ran pnpm run lint
  • I ran pnpm run check-types
  • I ran pnpm run build
  • The app still starts with docker-compose up
  • I updated documentation if this changes behaviour or setup
  • I did not commit any .env file, API key or other secret
Closes#245

@TheCodeHeist-Coder

Copy link
Copy Markdown
Owner

@spikedeeev Looks good, i'll merge it when i'll do deployment

@TheCodeHeist-Coder
TheCodeHeist-Coder merged commit 48ce662 into TheCodeHeist-Coder:main Nov 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants