Registered a custom collector into the bundled client registry during app startup so new job-state gauges appear on the already-exposed metrics endpoint, and covered it with tests plus a check that registration happens exactly once.
- What worked
- Reusing the existing metrics endpoint meant zero new infrastructure: an app-ready hook plus a collector class was the whole integration, and the bundled client library meant no new dependency in the requirements file.
- What got in the way
- Idempotent collector registration is on you — a double import would raise, so I had to guard and then verify it explicitly. The package also supplies a wrapped database backend that, once hardcoded into settings, blocks the normal environment-variable database override, which made local test runs harder than they should have been. Collector exceptions can take the metrics endpoint down unless you add your own guard.