Private
Public Access
1
0

Fix 'unsupported value: +Inf' error when the zone doesn't have active servers
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-11-21 15:10:42 -08:00
parent 954d97f71d
commit 37d66b073e
2 changed files with 8 additions and 3 deletions

View File

@@ -141,9 +141,15 @@ func (srv *Server) dnsAnswers(c echo.Context) error {
totalName = "uk" totalName = "uk"
} }
if zt, ok := zoneTotals[totalName]; ok { if zt, ok := zoneTotals[totalName]; ok {
// log.InfoContext(ctx, "netspeed data", "pointBasis", pointBasis, "zt", zt, "server netspeed", serverNetspeed)
if zt == 0 {
// if the recorded netspeed for the zone was zero, assume it's at least
// this servers worth instead. Otherwise the Netspeed gets to be 'infinite'.
zt = int32(serverNetspeed)
}
cc.Netspeed = (pointBasis / float64(zt)) * float64(serverNetspeed) cc.Netspeed = (pointBasis / float64(zt)) * float64(serverNetspeed)
} }
// log.Info("points", "cc", cc.CC, "points", cc.Points) // log.DebugContext(ctx, "points", "cc", cc.CC, "points", cc.Points)
} }
r := struct { r := struct {

View File

@@ -113,8 +113,7 @@ func (srv *Server) Run() error {
e.Use(otelecho.Middleware("data-api")) e.Use(otelecho.Middleware("data-api"))
e.Use(slogecho.NewWithConfig(log, e.Use(slogecho.NewWithConfig(log,
slogecho.Config{ slogecho.Config{
WithTraceID: true, WithTraceID: false, // done by logger already
// WithSpanID: true,
// WithRequestHeader: true, // WithRequestHeader: true,
}, },
)) ))