mirror of
https://github.com/SigNoz/signoz.git
synced 2026-03-13 08:13:22 +08:00
chore(statsreporter): fix vultr platform detection in statsreporter (#9326)
* chore(statsreporter): fix vultr platform detection in statsreporter * chore(statsreporter): adds comment for Vultr Detection order
This commit is contained in:
@@ -119,6 +119,16 @@ func detectPlatform() string {
|
||||
// Try to detect cloud provider through metadata endpoints
|
||||
client := &http.Client{Timeout: 1 * gotime.Second}
|
||||
|
||||
// Vultr metadata, Must come before AWS Detection — Vultr exposes the AWS IMDS endpoint, causing false AWS detection.
|
||||
if req, err := http.NewRequest(http.MethodGet, "http://169.254.169.254/v1/hostname", nil); err == nil {
|
||||
if resp, err := client.Do(req); err == nil {
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode == 200 {
|
||||
return "vultr"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AWS metadata
|
||||
if req, err := http.NewRequest(http.MethodGet, "http://169.254.169.254/latest/meta-data/", nil); err == nil {
|
||||
if resp, err := client.Do(req); err == nil {
|
||||
@@ -161,16 +171,6 @@ func detectPlatform() string {
|
||||
}
|
||||
}
|
||||
|
||||
// Vultr metadata
|
||||
if req, err := http.NewRequest(http.MethodGet, "http://169.254.169.254/v1/hostname", nil); err == nil {
|
||||
if resp, err := client.Do(req); err == nil {
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode == 200 {
|
||||
return "vultr"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hetzner metadata
|
||||
if req, err := http.NewRequest(http.MethodGet, "http://169.254.169.254/hetzner/v1/metadata", nil); err == nil {
|
||||
if resp, err := client.Do(req); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user