New feature: prometheus metrics endpoint (#46)

This commit is contained in:
2025-11-03 18:36:13 +01:00
committed by GitHub
parent ec1de1fa81
commit e8d3a20781
13 changed files with 564 additions and 82 deletions

View File

@@ -6,6 +6,7 @@ import (
"net"
"sync"
"github.com/dcarrillo/whatismyip/internal/metrics"
"github.com/dcarrillo/whatismyip/models"
)
@@ -41,6 +42,7 @@ func (g *Geo) LookUpCity(ip net.IP) *models.GeoRecord {
return nil
}
metrics.RecordGeoLookup("city")
return record
}
@@ -51,6 +53,7 @@ func (g *Geo) LookUpASN(ip net.IP) *models.ASNRecord {
return nil
}
metrics.RecordGeoLookup("asn")
return record
}

View File

@@ -3,6 +3,8 @@ package service
import (
"net"
"time"
"github.com/dcarrillo/whatismyip/internal/metrics"
)
const scannerTimeOut = 3 * time.Second
@@ -20,5 +22,6 @@ func (p *PortScanner) IsPortOpen() (bool, error) {
defer conn.Close()
}
metrics.RecordPortScan()
return true, nil
}