Skip to content

Commit

Permalink
fix: typo triggers panic in certain scenarios (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
reseul authored Dec 12, 2023
1 parent 9f7d0f0 commit dbe5649
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (t Tracer) InterceptResponse(ctx context.Context, next graphql.ResponseHand
semconv.GraphqlDocument(oc.RawQuery),
)
if operationName != "" {
span.SetAttributes(semconv.GraphqlOperationName(oc.Operation.Name))
span.SetAttributes(semconv.GraphqlOperationName(operationName))
}
if stats := extension.GetComplexityStats(ctx); stats != nil {
span.SetAttributes(graphqlComplexity.Int(stats.Complexity))
Expand Down
4 changes: 2 additions & 2 deletions tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ func (s *TracerSuite) TestQuery_ParsingError() {

query := "query GetGreeting { greeting"
var res struct{ Greeting string }
s.Require().Error(c.Post(query, &res))
s.Require().Error(c.Post(query, &res, func(req *client.Request) { req.OperationName = "GetGreeting" }))

spans := s.Exporter.GetSpans()
s.Require().Len(spans, 1)
s.Require().Equal("GraphQL Operation", spans[0].Name)
s.Require().Equal(codes.Error, spans[0].Status.Code)
s.Require().Len(spans[0].Attributes, 3)
s.Require().Len(spans[0].Attributes, 4)
}

func (s *TracerSuite) TestMutation_SpanCreated() {
Expand Down

0 comments on commit dbe5649

Please sign in to comment.