Full rewrite of collective.prometheus - #12
Open
Sakoes wants to merge 2 commits into
Open
Conversation
refactor: per-request _ZopeCollector; lock module-level activity accumulator Removes request-scoped mutable state on the module-level collector singleton: the prior design stashed self._request / self._context on a process-wide _COLLECTOR via set_request(), which races under concurrent /@@metrics scrapes. - _ZopeCollector now requires (request, context) at construction; one instance is built per request inside Prometheus.__call__. - Per-request CollectorRegistry; PROCESS_COLLECTOR and PLATFORM_COLLECTOR are re-registered each scrape (cheap; keeps the registry self-contained). - Monotonic ZODB activity totals move to a module-level _ACTIVITY dict guarded by _ACTIVITY_LOCK so counters survive across scrapes but the read-modify-write is serialized per db. refactor: table-driven collect() and yield from in _safe style: split multi-statement yield lines and getattr chain; drop redundant or '' docs: note counter-reset semantics in HISTORY; add overrides.zcml example to README Also records (no code change) that setup.py classifier drop of 'Framework :: Zope2' is intentional: collective.prometheus targets Plone, not raw Zope2 (Zope is a transitive concern of Plone).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A full rewrite of the
@@metricsendpoint, modernizing it for current Prometheus practices.What changed:
prometheus_clientfor exposition — proper Content-Type, Cache-Control, and OpenMetrics negotiation. Also mounts the standardPROCESS_COLLECTOR/PLATFORM_COLLECTOR.zodb_object_loads_total,zodb_object_stores_total), backed by a monotonic accumulator instead of a 15-second sampling window. Resets only on Zope restart — userate()in dashboards.dblabel (not_<dbname>name suffixes); per-connection series use aconnectionlabel (fixes a bug where connection 0 collided with later samples under the oldthreadlabel).zope_cache_memory→zope_cache_objects(it always counted objects, not bytes).zope_busy_threads,zope_request_queue_length.threadframefallback; tightenssetup.pyclassifiers (Plone-only, not raw Zope2).Breaking for anyone with existing dashboards — metric names, labels, and types have changed. Tagged as
2.0.0 (UNRELEASED).Example output