Skip to content

Commit

Permalink
add span event to errors
Browse files Browse the repository at this point in the history
  • Loading branch information
quinna-h committed Jan 24, 2025
1 parent 81208cd commit 74e6e11
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ddtrace/contrib/internal/graphql/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,23 @@ def _set_span_errors(errors: List[GraphQLError], span: Span) -> None:
if not errors:
# do nothing if the list of graphql errors is empty
return

breakpoint()
span.error = 1
exc_type_str = "%s.%s" % (GraphQLError.__module__, GraphQLError.__name__)
span.set_tag_str(ERROR_TYPE, exc_type_str)
error_msgs = "\n".join([str(error) for error in errors])
# Since we do not support adding and visualizing multiple tracebacks to one span
# we will not set the error.stack tag on graphql spans. Setting only one traceback
# could be misleading and might obfuscate errors.
locations = [
f"{err_location.formatted['line']}:{err_location.formatted['column']}" for err_location in errors[0].locations
]
locations = " ".join(locations)
span.set_tag_str(ERROR_MSG, error_msgs)
span._add_event(
name="dd.graphql.query.error",
attributes={"message": errors[0].message, "locations": locations, "path": errors[0].path},
)


def _set_span_operation_tags(span, document):
Expand Down

0 comments on commit 74e6e11

Please sign in to comment.