Skip to content

Conversation

amotl
Copy link
Contributor

@amotl amotl commented Jul 26, 2025

Problem

Using the /api/health endpoint is problematic, because Amazon Managed Grafana (AMG) doesn't support it.

Solution

Apply the solution as suggested by @squadgazzz to use the /api/frontend/settings endpoint instead -- thanks again!

References

/cc @bhks, @philipnrmn, @ImerysOTDataAndArchitecture, @interfan7

Copy link

coderabbitai bot commented Jul 26, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Updated Grafana version retrieval to use a new endpoint, which now requires authentication and no longer returns database status.
  • Tests

    • Updated all related tests to mock the new endpoint and response structure for version checks.
    • Adjusted test assertions and mock data to align with the revised API response format.
  • Documentation

    • Revised changelog to reflect the updated method for fetching Grafana version information.

Walkthrough

The codebase updates the Health.check method to fetch Grafana build information from the /api/frontend/settings endpoint instead of /api/health, enhancing compatibility with Amazon Managed Grafana (AMG). The changelog is updated accordingly, and the method now returns only the buildInfo field from the response.

Changes

File(s) Change Summary
grafana_client/elements/_async/health.py, grafana_client/elements/health.py Modified Health.check to query /frontend/settings and return only the buildInfo field; updated docstrings.
test/test_grafana_client.py Added detailed frontend_settings_buildinfo_payload mock; updated tests to use nested buildInfo structure and assert version accordingly.
test/elements/test_dashboard.py, test/elements/test_datasource_base.py, test/elements/test_datasource_health.py, test/elements/test_libraryelement.py, test/elements/test_team.py Updated tests to mock /api/frontend/settings instead of /api/health with adjusted JSON responses reflecting the new nested buildInfo structure and removal of database field.
test/elements/test_health.py Changed mocked endpoint and response JSON structure; updated assertions to match nested buildInfo format without database key.
CHANGELOG.md Added entry describing the endpoint change for Grafana version fetching and credited contributor.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Health
    participant GrafanaAPI

    Caller->>Health: check()
    Health->>GrafanaAPI: GET /api/frontend/settings
    GrafanaAPI-->>Health: { buildInfo: {...}, ... }
    Health-->>Caller: buildInfo
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

Poem

A hop to the settings, away from old health,
Now buildInfo returns, a snippet of wealth.
For Grafana and AMG, the code is aligned,
With endpoints updated, precision refined.
🐇✨
Changelog refreshed, the journey is clear—
This rabbit approves, and gives a big cheer!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 881a820 and 1585f63.

📒 Files selected for processing (10)
  • CHANGELOG.md (1 hunks)
  • grafana_client/elements/_async/health.py (1 hunks)
  • grafana_client/elements/health.py (1 hunks)
  • test/elements/test_dashboard.py (2 hunks)
  • test/elements/test_datasource_base.py (14 hunks)
  • test/elements/test_datasource_health.py (13 hunks)
  • test/elements/test_health.py (1 hunks)
  • test/elements/test_libraryelement.py (30 hunks)
  • test/elements/test_team.py (2 hunks)
  • test/test_grafana_client.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
  • grafana_client/elements/_async/health.py
  • test/elements/test_team.py
  • test/elements/test_dashboard.py
  • test/elements/test_health.py
  • grafana_client/elements/health.py
  • test/elements/test_datasource_health.py
  • CHANGELOG.md
  • test/elements/test_datasource_base.py
  • test/test_grafana_client.py
  • test/elements/test_libraryelement.py
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch health-check-to-frontend-settings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
grafana_client/elements/health.py (1)

15-17: Good consistency with async implementation.

The synchronous implementation correctly mirrors the async version changes:

  • Same endpoint (/frontend/settings)
  • Same return value extraction (buildInfo only)
  • Same breaking change implications as noted in the async version review
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3fc0400 and 50b6e5b.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • grafana_client/elements/_async/health.py (1 hunks)
  • grafana_client/elements/health.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
grafana_client/elements/_async/health.py (2)
test/elements/test_health.py (2)
  • test_healthcheck (13-21)
  • HealthTestCase (8-21)
test/elements/test_plugin.py (1)
  • test_health (211-217)
🔇 Additional comments (3)
CHANGELOG.md (1)

5-6: LGTM! Clear and accurate changelog entry.

The changelog entry properly documents the endpoint change for AMG compatibility and includes appropriate attribution.

grafana_client/elements/_async/health.py (1)

11-11: LGTM! Updated docstring accurately reflects AMG compatibility.

The docstring correctly documents that the method now works with both Grafana and Amazon Managed Grafana.

grafana_client/elements/health.py (1)

11-11: LGTM! Consistent docstring with async version.

The docstring update matches the async implementation and accurately describes AMG compatibility.

@amotl amotl force-pushed the health-check-to-frontend-settings branch from 50b6e5b to c1b887f Compare July 26, 2025 22:15
@amotl amotl force-pushed the health-check-to-frontend-settings branch from c1b887f to 0aea049 Compare July 26, 2025 22:47
@amotl amotl force-pushed the health-check-to-frontend-settings branch from 0aea049 to 21130a4 Compare July 26, 2025 22:50
@amotl amotl force-pushed the health-check-to-frontend-settings branch from 21130a4 to 73847eb Compare July 26, 2025 22:52
@amotl amotl force-pushed the health-check-to-frontend-settings branch from 73847eb to 1c330d5 Compare July 26, 2025 23:01
@amotl amotl marked this pull request as ready for review July 26, 2025 23:07
@amotl amotl force-pushed the health-check-to-frontend-settings branch from 1c330d5 to 881a820 Compare July 27, 2025 10:24
Copy link

codecov bot commented Jul 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.26%. Comparing base (7acc4d8) to head (1585f63).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #229      +/-   ##
==========================================
- Coverage   92.40%   92.26%   -0.15%     
==========================================
  Files          27       27              
  Lines        1818     1822       +4     
==========================================
+ Hits         1680     1681       +1     
- Misses        138      141       +3     
Flag Coverage Δ
unittests 92.26% <100.00%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@amotl amotl force-pushed the health-check-to-frontend-settings branch from 881a820 to 7811c51 Compare July 27, 2025 10:36
@amotl amotl force-pushed the health-check-to-frontend-settings branch from 7811c51 to 1585f63 Compare July 27, 2025 10:37
@amotl amotl merged commit b346242 into main Jul 27, 2025
8 checks passed
@amotl amotl deleted the health-check-to-frontend-settings branch July 27, 2025 10:46
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