Skip to content

Commit

Permalink
move event code up a level (#4381)
Browse files Browse the repository at this point in the history
move event code up a level plus minor fixes
  • Loading branch information
Nathaniel May authored Dec 1, 2021
1 parent e93ad5f commit 41ed976
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions core/dbt/events/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,17 @@ def event_to_serializable_dict(
data = dict()
node_info = dict()
if hasattr(e, '__dataclass_fields__'):
for field, value in dataclasses.asdict(e).items(): # type: ignore[attr-defined]
_json_value = e.fields_to_json(value)
if isinstance(e, NodeInfo):
node_info = dataclasses.asdict(e.get_node_info())

if isinstance(e, NodeInfo):
node_info = dataclasses.asdict(e.get_node_info())
for field, value in dataclasses.asdict(e).items(): # type: ignore[attr-defined]
if field not in ["code", "report_node_data"]:
_json_value = e.fields_to_json(value)

if not isinstance(_json_value, Exception):
data[field] = _json_value
else:
data[field] = f"JSON_SERIALIZE_FAILED: {type(value).__name__, 'NA'}"
if not isinstance(_json_value, Exception):
data[field] = _json_value
else:
data[field] = f"JSON_SERIALIZE_FAILED: {type(value).__name__, 'NA'}"

event_dict = {
'type': 'log_line',
Expand All @@ -153,7 +154,8 @@ def event_to_serializable_dict(
'data': data,
'invocation_id': e.get_invocation_id(),
'thread_name': e.get_thread_name(),
'node_info': node_info
'node_info': node_info,
'code': e.code
}

return event_dict
Expand Down

0 comments on commit 41ed976

Please sign in to comment.