Open
Conversation
Add comprehensive Google-style docstrings to all Python source files in the predbat codebase. Every source file now has a module-level docstring describing its purpose, and all major classes have class-level docstrings documenting their role, key attributes, and relationships. This enables pydoc/pdoc auto-documentation and improves IDE tooltip support for developers working with the codebase. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move metrics emission into the OSS codebase so each component emits its own data at the point of origin. prometheus_client is optional — when absent every operation silently no-ops. - Add predbat_metrics.py with conditional import, no-op stubs, singleton registry (31 metrics), record_api_call() helper, and /metrics HTTP handler - Instrument API clients (gecloud, octopus, solcast, fox, solis) with per-call success/failure tracking and reason labels - Fix solar calibration bug: store worst/best/total scaling on self (were local variables, never accessible outside pv_calibration()) - Add plan duration histogram + validity gauge - Add IOG latency histogram + register write counter - Add energy totals + data age gauge in fetch - Emit snapshot metrics (battery, cost, config) in update loop Co-Authored-By: Claude Opus 4.6 <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
predbat_metrics.py— a new OSS metrics module where each component emits its own Prometheus metrics at the point of originprometheus_clientis optional: when absent, all metric operations silently no-op via_NoOpMetricstubrecord_api_call()tracking success/failure with reason labelspv_calibration()computedworst_day_scaling,best_day_scaling,total_adjustmentas local variables that were never stored onself— now persisted and emitted as metrics/metricsHTTP endpoint on the existing web server (only when prometheus_client is installed)Test plan
python -c "import predbat_metrics"succeeds without prometheus_client installedmetrics().api_requests_total.labels(service='test').inc()silently does nothing without prometheus_clientcurl localhost:5052/metricsreturns valid Prometheus exposition formatpredbat_pv_scaling_worstnow appears in metrics (was always missing before due to the local variable bug)predbat_api_failures_total{service="givenergy",reason="auth_error"}shows correct classification🤖 Generated with Claude Code