Skip to content

Commit 0879a13

Browse files
committed
update span event attribute
1 parent cbe05b0 commit 0879a13

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

ddtrace/_trace/span.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ def __init__(self, name: str, attributes: Optional[Dict[str, Any]] = None, time_
6464
self.name: str = name
6565
if attributes is None:
6666
self.attributes = {}
67-
elif not isinstance(attributes, dict):
68-
raise TypeError("attributes must be a dictionary")
69-
elif not all(isinstance(k, str) for k in attributes.keys()):
70-
raise TypeError("All attributes keys must be strings")
7167
else:
7268
self.attributes = attributes
7369
if time_unix_nano is None:
@@ -81,6 +77,11 @@ def __dict__(self):
8177
return d
8278

8379
def __str__(self):
80+
"""
81+
Stringify and return value.
82+
Attribute value can be either str, bool, int/float, list.
83+
"""
84+
8485
def format_value(value: Any) -> str:
8586
if isinstance(value, list):
8687
return f"[{' '.join(map(str, value))}]"

ddtrace/contrib/internal/graphql/patch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ def _get_source_str(obj):
292292

293293

294294
def _set_span_errors(errors: List[GraphQLError], span: Span) -> None:
295+
"""
296+
Set tags on error span and set span events on each error.
297+
"""
295298
if not errors:
296299
# do nothing if the list of graphql errors is empty
297300
return
@@ -300,9 +303,6 @@ def _set_span_errors(errors: List[GraphQLError], span: Span) -> None:
300303
exc_type_str = "%s.%s" % (GraphQLError.__module__, GraphQLError.__name__)
301304
span.set_tag_str(ERROR_TYPE, exc_type_str)
302305
error_msgs = "\n".join([str(error) for error in errors])
303-
# Since we do not support adding and visualizing multiple tracebacks to one span
304-
# we will not set the error.stack tag on graphql spans. Setting only one traceback
305-
# could be misleading and might obfuscate errors.
306306
span.set_tag_str(ERROR_MSG, error_msgs)
307307
for error in errors:
308308
locations = [f"{loc.formatted['line']}:{loc.formatted['column']}" for loc in error.locations]

0 commit comments

Comments
 (0)