Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
pkg/trace: include GraphQL ?Type parameter in route name
Browse files Browse the repository at this point in the history
Today our HTTP metrics are pretty nice, but when it comes to any GraphQL requests
they are all grouped under the `graphql` route which makes them mostly useless.

For example, you can see HTTP latency is quite bad or that there are lots of error
codes on GraphQL requests -- but it is impossible to know if those are search
requests or some super-slow request made on e.g. the admin-only repository list
page.

I chose to include this in the route name (`graphql: Search`) instead of adding a
different field because it is nice to not have to deal with the separate field in
dashboard queries and because the route field would be mostly useless on GraphQL
requests otherwise.

Fixes #4246
  • Loading branch information
slimsag committed Jun 6, 2019
1 parent 8304609 commit 665aea0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/trace/httptrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ func Middleware(next http.Handler) http.Handler {

m := httpsnoop.CaptureMetrics(next, rw, r.WithContext(ctx))

if routeName == "graphql" {
// We use the query to denote the type of a GraphQL request, e.g. /.api/graphql?Repositories
if r.URL.RawQuery != "" {
routeName = "graphql: " + r.URL.RawQuery
} else {
routeName = "graphql: unknown"
}
}

// route name is only known after the request has been handled
span.SetOperationName("Serve: " + routeName)
span.SetTag("Route", routeName)
Expand Down

0 comments on commit 665aea0

Please sign in to comment.