Skip to content

Warn users to remember adding endpoint to Checkmate Infrastructure Dashboard #59

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

Merged
merged 1 commit into from
Apr 25, 2025

Conversation

mertssmnoglu
Copy link
Member

@mertssmnoglu mertssmnoglu commented Apr 20, 2025

Users may forgot to add http://ip-address:port/api/v1/metrics endpoint to their Checkmate Infrastructure Dashboard.

Created a function to retreive local ip address of the machine. Displaying a warning on startup.

Summary by CodeRabbit

  • New Features
    • Added a warning message displaying the local IP address and port, reminding users to add the URL to their Checkmate dashboard before starting the server.

@mertssmnoglu mertssmnoglu self-assigned this Apr 20, 2025
Copy link
Contributor

coderabbitai bot commented Apr 20, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

A new helper function, getLocalIP(), has been added to retrieve the first non-loopback IPv4 address of the local machine. This function is utilized in the main() function to log a warning message that instructs the user to add the constructed URL, containing the local IP and port, to their Checkmate dashboard. The log message is displayed after HTTP route setup and before the server starts. No other changes to logic or control flow are present.

Changes

File(s) Change Summary
cmd/capture/main.go Added getLocalIP() function to fetch local IPv4 address; used it in main() to enhance log message

Poem

In the warren of code, a new helper appears,
Sniffing out IPs, it hops without fears.
Now logs remind us, with a friendly cheer,
“Add this URL, let Checkmate draw near!”
With every new hop, the network grows bright,
A rabbit’s delight in each byte and byte!
🐇✨


📜 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 fb51757 and 1761440.

📒 Files selected for processing (1)
  • cmd/capture/main.go (3 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in 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
Contributor

@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: 0

🧹 Nitpick comments (2)
cmd/capture/main.go (2)

25-42: The getLocalIP() function works well but has some limitations.

The function correctly retrieves the first non-loopback IPv4 address. However, it has a couple of limitations:

  1. On machines with multiple network interfaces, it will always return the first non-loopback IPv4 address found, which might not be the desired one for connecting to the Checkmate dashboard.
  2. It doesn't support IPv6 addresses, which could be problematic in IPv6-only environments.

Consider enhancing the function to handle multiple network interfaces and IPv6 addresses:

func getLocalIP() string {
	addrs, err := net.InterfaceAddrs()
	if err != nil {
		return "<ip-address>"
	}
	
	// First try to find an IPv4 address
	for _, addr := range addrs {
		if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
			if ipnet.IP.To4() != nil {
				return ipnet.IP.String()
			}
		}
	}
	
+	// If no IPv4 address is found, try IPv6
+	for _, addr := range addrs {
+		if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
+			if ipnet.IP.To4() == nil {
+				return "[" + ipnet.IP.String() + "]" // IPv6 addresses should be enclosed in brackets
+			}
+		}
+	}
	
	return "<ip-address>"
}

75-75: The warning message is helpful but could be more informative.

The log statement correctly warns users to add the endpoint to their Checkmate dashboard. However, it doesn't provide context about why this is important or what will happen if they don't add it.

Consider enhancing the log message to be more informative:

-log.Println("warning: Remember to add http://" + getLocalIP() + ":" + appConfig.Port + "/api/v1/metrics to your Checkmate dashboard")
+log.Println("⚠️ WARNING: For proper monitoring, add http://" + getLocalIP() + ":" + appConfig.Port + "/api/v1/metrics to your Checkmate Infrastructure Dashboard. Without this endpoint, system metrics will not be displayed.")
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ef5b236 and fb51757.

📒 Files selected for processing (1)
  • cmd/capture/main.go (3 hunks)

…frastructure Dashboard

Signed-off-by: Mert Şişmanoğlu <[email protected]>
@mertssmnoglu mertssmnoglu force-pushed the feat/logging-warning branch from fb51757 to 1761440 Compare April 25, 2025 20:34
@mertssmnoglu mertssmnoglu merged commit 9429bdc into develop Apr 25, 2025
1 of 2 checks passed
@mertssmnoglu mertssmnoglu deleted the feat/logging-warning branch April 25, 2025 20:50
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