Skip to content

Commit

Permalink
Store node_info in GenericExceptionOnRun logging event (#9559)
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank authored Feb 13, 2024
1 parent 5841d52 commit 2411f93
Show file tree
Hide file tree
Showing 6 changed files with 293 additions and 275 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240212-165619.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Store node_info in node associated logging events
time: 2024-02-12T16:56:19.954358-05:00
custom:
Author: gshank
Issue: "9557"
3 changes: 3 additions & 0 deletions core/dbt/events/core_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,7 @@ message SeedHeaderMsg {
message SQLRunnerException {
string exc = 1;
string exc_info = 2;
NodeInfo node_info = 3;
}

message SQLRunnerExceptionMsg {
Expand Down Expand Up @@ -1572,6 +1573,7 @@ message CatchableExceptionOnRunMsg {
message InternalErrorOnRun {
string build_path = 1;
string exc = 2;
NodeInfo node_info = 3;
}

message InternalErrorOnRunMsg {
Expand All @@ -1584,6 +1586,7 @@ message GenericExceptionOnRun {
string build_path = 1;
string unique_id = 2;
string exc = 3;
NodeInfo node_info = 4;
}

message GenericExceptionOnRunMsg {
Expand Down
544 changes: 272 additions & 272 deletions core/dbt/events/core_types_pb2.py

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion core/dbt/task/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,11 @@ def _handle_catchable_exception(self, e, ctx):
return str(e)

def _handle_internal_exception(self, e, ctx):
fire_event(InternalErrorOnRun(build_path=self.node.build_path, exc=str(e)))
fire_event(
InternalErrorOnRun(
build_path=self.node.build_path, exc=str(e), node_info=get_node_info()
)
)
return str(e)

def _handle_generic_exception(self, e, ctx):
Expand All @@ -345,6 +349,7 @@ def _handle_generic_exception(self, e, ctx):
build_path=self.node.build_path,
unique_id=self.node.unique_id,
exc=str(e),
node_info=get_node_info(),
)
)
fire_event(LogDebugStackTrace(exc_info=traceback.format_exc()))
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/task/freshness.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def execute(self, compiled_node, manifest):
def compile(self, manifest):
if self.node.resource_type != NodeType.Source:
# should be unreachable...
raise DbtRuntimeError("fresnhess runner: got a non-Source")
raise DbtRuntimeError("freshness runner: got a non-Source")
# we don't do anything interesting when we compile a source node
return self.node

Expand Down
6 changes: 5 additions & 1 deletion core/dbt/task/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def __init__(self, config, adapter, node, node_index, num_nodes) -> None:
CompileRunner.__init__(self, config, adapter, node, node_index, num_nodes)

def handle_exception(self, e, ctx):
fire_event(SQLRunnerException(exc=str(e), exc_info=traceback.format_exc()))
fire_event(
SQLRunnerException(
exc=str(e), exc_info=traceback.format_exc(), node_info=self.node.node_info
)
)
if isinstance(e, dbt.exceptions.Exception):
if isinstance(e, dbt_common.exceptions.DbtRuntimeError):
e.add_node(ctx.node)
Expand Down

0 comments on commit 2411f93

Please sign in to comment.