Skip to content

Commit

Permalink
contrib/99designs/gqlgen/tracer.go: only check response nil when fini…
Browse files Browse the repository at this point in the history
…shing span and update finishing order
  • Loading branch information
dienvoandpadcojp committed Aug 10, 2024
1 parent c150e09 commit a5403b4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions contrib/99designs/gqlgen/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,6 @@ func (t *gqlTracer) InterceptOperation(ctx context.Context, next graphql.Operati
responseHandler := next(ctx)
return func(ctx context.Context) (response *graphql.Response) {
defer func() {
if span != nil {
var err error
if response != nil && len(response.Errors) > 0 {
err = response.Errors
}
defer span.Finish(tracer.WithError(err))
}

var (
executionOperationRes types.ExecutionOperationRes
requestOperationRes types.RequestOperationRes
Expand All @@ -139,6 +131,14 @@ func (t *gqlTracer) InterceptOperation(ctx context.Context, next graphql.Operati

query.Finish(executionOperationRes)
req.Finish(requestOperationRes)

if span != nil {
var err error
if response != nil {
err = response.Errors
}
span.Finish(tracer.WithError(err))
}
}()

response = responseHandler(ctx)
Expand Down

0 comments on commit a5403b4

Please sign in to comment.