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

move event code up a level #4381

Merged
merged 3 commits into from
Dec 1, 2021
Merged
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
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