Conversation
…hase 1) Phase 1 of the migration plan in ``notes/observability/REGISTER_OR_REUSE_HELPER_DESIGN_2026-05-05.md``: juniper-observability's own two inline guards (added in PR #211 for ``PrometheusMiddleware.__init__`` and PR #214 for ``set_build_info``) swap to the canonical helpers introduced in ``0.2.0`` (PR #216). ### What changes - ``juniper_observability/middleware/prometheus.py``: ``PrometheusMiddleware.__init__`` drops its inline ``_get_or_create`` closure (try/except + ``REGISTRY._names_to_collectors`` lookup) and calls ``register_or_reuse`` directly. Net -25 lines. - ``juniper_observability/prometheus.py``: ``set_build_info`` drops its inline try/except + lookup + ``info.info({...})`` sequence and calls ``register_info_or_update`` (which composes those three steps). Net -10 lines. Pure internal refactor — production behaviour and the collectors' wire format are unchanged. The helper has its own unit tests (``tests/test_prometheus_helpers.py``, 26 cases including the adopt-existing path); these two consumers' tests (``test_prometheus_middleware.py``, ``test_prometheus_utils.py``) exercise the integration end-to-end. ### Verification - juniper-observability own suite: **83 passed** (unchanged) - juniper-data full default suite under JuniperData env: **950 passed** (unchanged from yesterday's main run) ### Next Phase 2 — per-consumer migration in dependency order: juniper-data → juniper-canopy → juniper-cascor-client → juniper-cascor. Each consumer's PR will: 1. Bump the ``juniper-observability`` dep pin to ``>=0.2.0`` 2. Replace its inline ``_get_or_create`` / ``_register_or_reuse`` with an import from ``juniper_observability`` 3. Drop the duplicated implementation Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Phase 1 of the migration plan in
notes/observability/REGISTER_OR_REUSE_HELPER_DESIGN_2026-05-05.md.juniper-observability's own two inline guards (added in PR #211 for
PrometheusMiddleware.__init__and PR #214 forset_build_info) swap to the canonical helpers introduced in 0.2.0 (PR #216 / tagjuniper-observability-v0.2.0).What changes
juniper_observability/middleware/prometheus.pyregister_or_reuse(×3)REGISTRYimportjuniper_observability/prometheus.pyregister_info_or_updateREGISTRYimportPure internal refactor — production behaviour and the collectors' wire format are unchanged. The helper has its own unit tests (
tests/test_prometheus_helpers.py, 26 cases including the adopt-existing path); these two consumers' integration tests (test_prometheus_middleware.py,test_prometheus_utils.py) exercise the swap end-to-end.Verification
What's next
Phase 2 — per-consumer migration in dependency order: juniper-data → juniper-canopy → juniper-cascor-client → juniper-cascor. Each consumer's PR will:
juniper-observabilitydep pin to>=0.2.0_get_or_create/_register_or_reusewith an import fromjuniper_observabilityTest plan
Unreleasedentry underChangeddocuments the refactor🤖 Generated with Claude Code