Skip to content

Commit

Permalink
customize the operation in http trace span (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktong authored May 1, 2024
1 parent f399418 commit 4059adb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion examples/http/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,18 @@ func main() {
}
})
server := &http.Server{
Handler: otelhttp.NewHandler(mux, "nilgo example"),
Handler: otelhttp.NewHandler(mux, "", otelhttp.WithSpanNameFormatter(func(operation string, r *http.Request) string {
if operation != "" {
return operation
}

method := r.Method
if method == "" {
method = "GET"
}

return method + " " + r.URL.Path
})),
ReadTimeout: time.Second,
}
args = append(args,
Expand Down

0 comments on commit 4059adb

Please sign in to comment.