Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Display more in-depth health information about the hermes service #10068

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

PaRangger
Copy link
Contributor

@PaRangger PaRangger commented Dec 23, 2024

Checklist

General

Server

Motivation and Context

Currently, Artemis checks if Hermes is running by calling the base url and looking if it returns a 200 response code. While working, this does not provide a lot of information to the admins.

Description

I implemented a new /api/health api in the Hermes Repository that provides the information whether or not Hermes was able to connect to the APNS or to Firebase. Additionally, it returns the version number of Hermes. This information is displayed in the "details" section when viewing the service health in the admin panel.

Steps for Testing

Prerequisites:

  • 1 Artemis Admin (On TS3 your TUM Online Account should be admin)
  1. Log in to Artemis
  2. Navigate to Server Administration > Health in the navbar
  3. Check if the Hermes service is displayed as online
  4. Click the "Eye" icon to view the details
  5. Check if the additional info (firebase_up, apns_up and version) are displayed. (It should say "up" in 99% of cases.)

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Screenshots

Bildschirmfoto 2024-12-23 um 14 05 30

Summary by CodeRabbit

  • New Features

    • Enhanced health checking mechanism for Hermes push notification service
    • Added support for retrieving detailed health status from a new endpoint
  • Bug Fixes

    • Improved service availability detection with fallback mechanism

@PaRangger PaRangger added feature server Pull requests that update Java code. (Added Automatically!) component:Notification small labels Dec 23, 2024
@PaRangger PaRangger self-assigned this Dec 23, 2024
@github-actions github-actions bot added the communication Pull requests that affect the corresponding module label Dec 23, 2024
Copy link

There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions.

@github-actions github-actions bot added the stale label Dec 31, 2024
@PaRangger PaRangger removed the stale label Jan 2, 2025
Copy link

github-actions bot commented Jan 9, 2025

There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jan 9, 2025
@PaRangger PaRangger removed the stale label Jan 10, 2025
@PaRangger PaRangger marked this pull request as ready for review January 15, 2025 14:15
@PaRangger PaRangger requested a review from a team as a code owner January 15, 2025 14:15
Copy link

coderabbitai bot commented Jan 15, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 pmd (7.8.0)
src/main/java/de/tum/cit/aet/artemis/communication/config/HermesHealthIndicator.java

The following rules are missing or misspelled in your ruleset file category/vm/bestpractices.xml: BooleanInstantiation, DontImportJavaLang, DuplicateImports, EmptyFinallyBlock, EmptyIfStmt, EmptyInitializer, EmptyStatementBlock, EmptyStatementNotInLoop, EmptySwitchStatements, EmptySynchronizedBlock, EmptyTryBlock, EmptyWhileStmt, ExcessiveClassLength, ExcessiveMethodLength, ImportFromSamePackage, MissingBreakInSwitch, SimplifyBooleanAssertion. Please check your ruleset configuration.

Walkthrough

The changes modify the HermesHealthIndicator class to introduce a more robust health checking mechanism for the Hermes push notification service. A new method is implemented to retrieve health information from a dedicated /api/health endpoint, with a fallback mechanism for older service versions. The changes include adding a private record to encapsulate health report data and implementing a more comprehensive health status check that captures connection statuses for Firebase and APNs, along with the service version number.

Changes

File Change Summary
src/main/java/de/tum/cit/aet/artemis/communication/config/HermesHealthIndicator.java - Added private record HermesHealthReport
- Implemented new health check method with endpoint /api/health
- Added fallback mechanism for health checking
- Enhanced health status determination logic

Sequence Diagram

sequenceDiagram
    participant Client as HermesHealthIndicator
    participant Endpoint as Hermes Service
    
    Client->>Endpoint: GET /api/health
    alt Health Endpoint Available
        Endpoint-->>Client: Return Health Report
        Client->Client: Parse Health Report
        Client->Client: Update Health Status
    else Health Endpoint Unavailable
        Client->>Endpoint: Fallback: GET Base URL
        Endpoint-->>Client: Verify Connection
        Client->Client: Determine Fallback Status
    end
Loading

The sequence diagram illustrates the new health checking process, showing the primary flow of attempting to retrieve health information from the /api/health endpoint, with a fallback mechanism if the endpoint is not available.

Finishing Touches

  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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 or @coderabbitai title anywhere in the PR title to generate the title automatically.

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0cda16 and 8736c32.

📒 Files selected for processing (1)
  • src/main/java/de/tum/cit/aet/artemis/communication/config/HermesHealthIndicator.java (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/java/de/tum/cit/aet/artemis/communication/config/HermesHealthIndicator.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (2)
src/main/java/de/tum/cit/aet/artemis/communication/config/HermesHealthIndicator.java (2)

76-77: Verify field names in HermesHealthReport match JSON properties

Ensure that the field names in HermesHealthReportisApnsConnected, isFirebaseConnected, versionNumber—correctly map to the JSON properties returned by the /api/health endpoint. If the JSON properties differ (e.g., apnsConnected instead of isApnsConnected), use @JsonProperty annotations to map them appropriately.


44-58: New health check implementation enhances service monitoring

The addition of the /api/health endpoint check provides more detailed health information about the Hermes service, improving administrators' ability to monitor connectivity with APNs and Firebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
communication Pull requests that affect the corresponding module component:Notification feature ready for review server Pull requests that update Java code. (Added Automatically!) small
Projects
Status: Ready For Review
Status: Todo
Development

Successfully merging this pull request may close these issues.

1 participant