Skip to content

Conversation

@kaaaaaaang
Copy link
Collaborator

@kaaaaaaang kaaaaaaang commented Nov 25, 2025

Also fixs empty result when prometheus caontains /

Copy link

Copilot AI left a comment

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 adds HTTPS support for the metric dumper by refactoring URL handling throughout the codebase. The changes enable the system to work with both HTTP and HTTPS Prometheus endpoints.

Key changes:

  • Introduced a new URL2Name utility function to convert URLs to filesystem-safe names
  • Modified URL construction to include protocol prefixes (http:// or https://)
  • Updated the makeURL function to handle URLs that already contain protocol prefixes

Reviewed changes

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

File Description
pkg/utils/utils.go Added URL2Name utility function to sanitize URLs for filesystem usage by removing protocols and replacing special characters
collector/prometheus.go Updated URL construction across multiple functions to properly handle protocol prefixes, enabling HTTPS support for Prometheus endpoints

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

}
return false
}

Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

The function URL2Name is missing documentation. Since this is an exported function (starts with uppercase), it should have a doc comment explaining its purpose, parameters, and return value. For example:

// URL2Name converts a URL to a filesystem-safe name by removing the protocol
// prefix (http:// or https://) and replacing special characters (/ and :) with underscores.
func URL2Name(url string) string {
Suggested change
// URL2Name converts a URL to a filesystem-safe name by removing the protocol
// prefix (http:// or https://) and replacing special characters (/ and :) with underscores.

Copilot uses AI. Check for mistakes.
} else {
for _, prom := range topo.Monitors {
monitors = append(monitors, fmt.Sprintf("%s:%d", prom.Host(), prom.MainPort()))
// todo: check is TLS enabled in tiup deployed prometheus
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

[nitpick] The TODO comment mentions checking if TLS is enabled for tiup deployed prometheus, but there's no mechanism to actually detect or handle this. The code currently hardcodes http:// as the protocol. Consider implementing the TLS detection or document the expected behavior when TLS is enabled (e.g., users should manually configure endpoints with https:// via AttrKeyPromEndpoint).

Suggested change
// todo: check is TLS enabled in tiup deployed prometheus
// TODO: If Prometheus is deployed with TLS enabled, users must manually configure endpoints with `https://` via `AttrKeyPromEndpoint`.

Copilot uses AI. Check for mistakes.
@mornyx
Copy link
Collaborator

mornyx commented Nov 25, 2025

LGTM

@kaaaaaaang kaaaaaaang merged commit 8992bc3 into master Nov 26, 2025
3 checks passed
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.

3 participants