tracing: better span names
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
2024-12-22 17:40:51 -08:00
parent d08c73a528
commit 0edce7bab9

View File

@@ -148,6 +148,8 @@ func getCity(req *http.Request) (*geoip2.City, error) {
}
func handleJSON(w http.ResponseWriter, req *http.Request) {
span := trace.SpanFromContext(req.Context())
span.SetName("/api/json")
city, err := getCity(req)
if err != nil {
log.Printf("getCity error: %s", err)
@@ -166,6 +168,9 @@ func handleJSON(w http.ResponseWriter, req *http.Request) {
}
func handleCountry(w http.ResponseWriter, req *http.Request) {
span := trace.SpanFromContext(req.Context())
span.SetName("/api/country")
city, err := getCity(req)
if err != nil {
log.Printf("getCity error: %s", err)
@@ -178,6 +183,10 @@ func handleCountry(w http.ResponseWriter, req *http.Request) {
}
func handleHealth(w http.ResponseWriter, req *http.Request) {
span := trace.SpanFromContext(req.Context())
span.SetAttributes(attribute.Bool("app.drop_sample", true))
span.SetName("/healthz")
ip := net.ParseIP("199.43.0.43")
city, err := getCityIP(ip)
if err != nil {