Skip to content

feat: log weather provider usage - #19

Merged
IceCodeNew merged 1 commit into
masterfrom
log/api-usage
Jul 14, 2026
Merged

feat: log weather provider usage#19
IceCodeNew merged 1 commit into
masterfrom
log/api-usage

Conversation

@IceCodeNew

Copy link
Copy Markdown
Owner

Summary

  • Log the effective weather provider order for each location.
  • Record each logical weather API attempt, result, duration, source, and observation time.
  • Preserve safe QWeather failure stages and HTTP or API status details so Open-Meteo fallback is visible.
  • Log optional air-quality failures without exposing coordinates, credentials, endpoints, URLs, or response bodies.

Root cause

QWeather failures were caught by the fallback provider without any diagnostic record. Hourly briefings could continue through Open-Meteo while operators saw no evidence that QWeather had failed or why fallback occurred.

Validation

  • Full pytest branch-coverage run: 331 passed; 99.59% line coverage and 97.85% branch coverage.
  • Ruff check passed.
  • ty check passed.
  • All prek hooks passed.
  • git diff check passed.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@IceCodeNew, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 24c32c8c-8fb3-4a5b-8e17-c4d4bb274a32

📥 Commits

Reviewing files that changed from the base of the PR and between 9d11558 and a9db860.

📒 Files selected for processing (7)
  • README.md
  • docs/design.md
  • docs/requirements.md
  • tests/test_cli.py
  • tests/test_weather_context.py
  • weather_briefing/cli.py
  • weather_briefing/weather_context.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch log/api-usage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@IceCodeNew
IceCodeNew requested a review from Copilot July 14, 2026 09:46
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.35%. Comparing base (c1ff66a) to head (a9db860).
⚠️ Report is 2 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #19      +/-   ##
==========================================
+ Coverage   99.33%   99.35%   +0.02%     
==========================================
  Files          34       34              
  Lines        4368     4525     +157     
  Branches      255      258       +3     
==========================================
+ Hits         4339     4496     +157     
  Misses         18       18              
  Partials       11       11              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves operational visibility into weather data sourcing by adding structured, non-sensitive logging around weather provider selection, per-provider attempts, failures, and fallbacks—so operators can diagnose why QWeather fell back to Open-Meteo without exposing coordinates, endpoints, or response bodies.

Changes:

  • Added a LoggedWeatherContextProvider decorator that logs each logical weather API attempt with duration and safe failure details.
  • Enriched provider failure errors (QWeather/Open-Meteo) with a safe “operation stage” plus HTTP status / exception type to make fallback causes visible.
  • Added/updated tests and documentation to validate and describe the new INFO/WARNING logging behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
weather_briefing/weather_context.py Adds provider-call logging wrapper, safe error summarization, and more informative (but non-sensitive) provider failure messages.
weather_briefing/cli.py Wraps configured providers with the logging decorator and logs the effective provider order per location.
tests/test_weather_context.py Adds coverage asserting fallback + per-provider logging and that optional air-quality failures are logged without failing the weather snapshot.
tests/test_cli.py Verifies the CLI logs the provider order for a configured location.
README.md Documents that INFO logs now include provider order and per-attempt weather API history for fallback diagnosis.
docs/requirements.md Updates requirements to mandate provider-order and per-attempt logging at INFO, including optional air-quality failures, without sensitive data.
docs/design.md Updates design notes to reflect provider logging being applied at the composition boundary and how fallback visibility is achieved.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@IceCodeNew
IceCodeNew marked this pull request as ready for review July 14, 2026 09:52
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
putComment timed out

@IceCodeNew

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread weather_briefing/weather_context.py

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

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.

2 participants