-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix(GraphQL): Log query along with the panic #7638
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 3 files reviewed, 4 unresolved discussions (waiting on @pawanrawal and @vmrajas)
graphql/resolve/resolver.go, line 476 at r1 (raw file):
Quoted 13 lines of code…
resp := &schema.Response{ Extensions: &schema.Extensions{ Tracing: &schema.Trace{ Version: 1, StartTime: startTime.Format(time.RFC3339Nano), }, }, } defer func() { endTime := time.Now() resp.Extensions.Tracing.EndTime = endTime.Format(time.RFC3339Nano) resp.Extensions.Tracing.Duration = endTime.Sub(startTime).Nanoseconds() }()
let's bring this back here
graphql/resolve/resolver.go, line 480 at r1 (raw file):
return schema.ErrorResponse(err)
I am realizing that this won't return tracing information in the response.
So, we should do this here:
resp.Errors = schema.AsGQLErrors(err)
return
graphql/resolve/resolver.go, line 486 at r1 (raw file):
return schema.ErrorResponse(err)
resp.Errors = schema.AsGQLErrors(err)
return
graphql/resolve/resolver.go, line 570 at r1 (raw file):
Quoted 4 lines of code…
api.PanicHandler( func(err error) { resp.Errors = schema.AsGQLErrors(schema.AppendGQLErrs(resp.Errors, err)) }, gqlReq.Query)
we can put this as the first line in the already existing defer func()
above. That way any bad thing inside Resolve()
would be caught here itself, and the panic handler in recoveryHandler
would be responsible for a very limited set of things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 3 files reviewed, 4 unresolved discussions (waiting on @abhimanyusinghgaur and @pawanrawal)
graphql/resolve/resolver.go, line 476 at r1 (raw file):
Previously, abhimanyusinghgaur (Abhimanyu Singh Gaur) wrote…
resp := &schema.Response{ Extensions: &schema.Extensions{ Tracing: &schema.Trace{ Version: 1, StartTime: startTime.Format(time.RFC3339Nano), }, }, } defer func() { endTime := time.Now() resp.Extensions.Tracing.EndTime = endTime.Format(time.RFC3339Nano) resp.Extensions.Tracing.Duration = endTime.Sub(startTime).Nanoseconds() }()
let's bring this back here
Done.
graphql/resolve/resolver.go, line 480 at r1 (raw file):
Previously, abhimanyusinghgaur (Abhimanyu Singh Gaur) wrote…
return schema.ErrorResponse(err)
I am realizing that this won't return tracing information in the response.
So, we should do this here:resp.Errors = schema.AsGQLErrors(err) return
Yes, it was also the case before this PR. I will fix this with this PR itself.
graphql/resolve/resolver.go, line 486 at r1 (raw file):
Previously, abhimanyusinghgaur (Abhimanyu Singh Gaur) wrote…
return schema.ErrorResponse(err)
resp.Errors = schema.AsGQLErrors(err) return
Done.
graphql/resolve/resolver.go, line 570 at r1 (raw file):
Previously, abhimanyusinghgaur (Abhimanyu Singh Gaur) wrote…
api.PanicHandler( func(err error) { resp.Errors = schema.AsGQLErrors(schema.AppendGQLErrs(resp.Errors, err)) }, gqlReq.Query)
we can put this as the first line in the already existing
defer func()
above. That way any bad thing insideResolve()
would be caught here itself, and the panic handler inrecoveryHandler
would be responsible for a very limited set of things.
Done.
ee6dd6c
to
31d786f
Compare
* Log query along with panic * Log mutations using panic handler * Address Abhimanyu's comments (cherry picked from commit 071d5de)
* Log query along with panic * Log mutations using panic handler * Address Abhimanyu's comments
This PR adds functionality to log the query and mutations which cause panic in PanicHandler.
Testing:
Tested locally.
This change is