Skip to content
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

feat: add graphql span event on errors #12087

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ddtrace/contrib/internal/graphql/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,22 @@ def _set_span_errors(errors: List[GraphQLError], span: Span) -> None:
if not errors:
# do nothing if the list of graphql errors is empty
return

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
Loading