Skip to content

feat(integrations): Prometheus metrics base view (0.4.0) - #29

Merged
rrolf merged 2 commits into
mainfrom
feat/metrics
Nov 5, 2026
Merged

rrolf merged 2 commits into
mainfrom
feat/metrics

Conversation

@rrolf

@rrolf rrolf commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Neues Modul basicbar_integrations.metrics (→ integrations/v0.4.0): ein generischer, token-geschützter Prometheus-Exporter, den die -bar-Tools nur noch mit ihren Kennzahlen füllen (erster Nutzer: Ausleihbar; abstimmbar und ansehbar können nachziehen).

  • Gauges: sammelt Gauge-Familien (mit/ohne Labels) und rendert das Prometheus-Textformat 0.0.4 – Namensprüfung (fullmatch), Label-Escaping, int/float-Darstellung, Abweisung doppelter Label-Sets.
  • MetricsView(APIView): GET only, keine DRF-Auth/-Permissions/-Throttles, ignoriert Accept; Token aus METRICS_TOKEN (conf-Default ""): leer → 404, fehlend/falsch → 401 mit WWW-Authenticate: Bearer, Vergleich per hmac.compare_digest; Antwort text/plain; version=0.0.4, Cache-Control: no-store. Unterklassen implementieren collect(gauges).
  • Keine URL im Paket; das Tool hängt die View außerhalb von /api/ ein (README mit Beispiel inkl. Caddy-Block).
  • 26 neue Tests (runtests.py: 91 OK, auch unter Python 3.12); CHANGELOG mit Migrationshinweis; Version 0.4.0.

🤖 Generated with Claude Code

rrolf and others added 2 commits November 4, 2026 22:30
New module basicbar_integrations.metrics: Gauges renders gauge families
in the Prometheus text format 0.0.4 (dependency-free), MetricsView is a
GET/HEAD-only APIView that returns 404 while METRICS_TOKEN is empty and
401 (WWW-Authenticate: Bearer) unless the exact bearer token is sent.
Subclasses implement collect(); the package registers no URL. Bumps
basicbar-integrations to 0.4.0.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- Ignore Accept/?format= via a custom content negotiation, so scrapers'
  `Accept: text/plain;version=0.0.4` no longer gets 406 (also before the
  token check).
- Validate metric/label names with fullmatch (a trailing newline passed).
- Reject duplicate label sets within one family.
- throttle_classes = (): project default throttles never hit scrapes.
- Move the test subclass to tests/views.py; README: ASCII token, wording.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@rrolf
rrolf merged commit d5351f1 into main Nov 5, 2026
6 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.

1 participant