Private
Public Access
1
0

Add tracing

This commit is contained in:
2023-10-14 04:01:43 -07:00
parent 42dccd28a7
commit f9b521664d
13 changed files with 407 additions and 241 deletions

View File

@@ -16,6 +16,7 @@ import (
"go.ntppool.org/common/health"
"go.ntppool.org/common/logger"
"go.ntppool.org/common/metricsserver"
"go.ntppool.org/common/tracing"
chdb "go.ntppool.org/data-api/chdb"
"go.ntppool.org/data-api/ntpdb"
@@ -48,12 +49,15 @@ func NewServer(ctx context.Context, configFile string) (*Server, error) {
metrics: metricsserver.New(),
}
err = srv.initTracer()
err = tracing.InitTracer(ctx, &tracing.TracerConfig{
ServiceName: "data-api",
Environment: "",
})
if err != nil {
return nil, err
}
srv.tracer = srv.NewTracer()
srv.tracer = tracing.NewTracer("data-api-tracer")
return srv, nil
}
@@ -107,8 +111,8 @@ func (srv *Server) userCountryData(c echo.Context) error {
ctx := c.Request().Context()
q := ntpdb.New(srv.db)
zoneStats, err := q.GetZoneStats(ctx)
q := ntpdb.NewWrappedQuerier(ntpdb.New(srv.db))
zoneStats, err := ntpdb.GetZoneStats(ctx, q)
if err != nil {
slog.Error("GetZoneStats", "err", err)
return c.String(http.StatusInternalServerError, err.Error())