-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report Resource Usage Statistics When a dbt Command Finishes (#8671)
* Add performance metrics to the CommandCompleted event. * Add changelog entry. * Add flag for controling the log level of ResourceReport. * Update changelog entry to reflect changes * Remove outdated attributes * Work around missing resource module on windows * Fix corner case where flags are not set
- Loading branch information
1 parent
6d19ab5
commit 83e72c2
Showing
10 changed files
with
995 additions
and
883 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Features | ||
body: Add new ResourceReport event to record memory/cpu/io metrics | ||
time: 2023-09-19T10:21:48.772635-04:00 | ||
custom: | ||
Author: peterallenwebb | ||
Issue: "8342" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
|
||
from dbt.cli.main import dbtRunner | ||
from dbt.events.base_types import EventLevel | ||
|
||
|
||
def test_performance_report(project): | ||
|
||
resource_report_level = None | ||
|
||
def check_for_report(e): | ||
# If we see a ResourceReport event, record its level | ||
if e.info.name == "ResourceReport": | ||
nonlocal resource_report_level | ||
resource_report_level = e.info.level | ||
|
||
runner = dbtRunner(callbacks=[check_for_report]) | ||
|
||
runner.invoke(["run"]) | ||
|
||
# With not cli flag or env var set, ResourceReport should be debug level. | ||
assert resource_report_level == EventLevel.DEBUG | ||
|
||
try: | ||
os.environ["DBT_SHOW_RESOURCE_REPORT"] = "1" | ||
runner.invoke(["run"]) | ||
|
||
# With the appropriate env var set, ResourceReport should be info level. | ||
# This allows this fairly technical log line to be omitted by default | ||
# but still available in production scenarios. | ||
assert resource_report_level == EventLevel.INFO | ||
finally: | ||
del os.environ["DBT_SHOW_RESOURCE_REPORT"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters