-
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.
Allow custom metadata to be attached to every log (#5999)
* use extra dict * remove commented out code * fix duplicates * add test * consolidate * working, but needs some cleanup * convert back to globals * reset globals in tests * fix up some imports * fix text for windows * modify test for windows
- Loading branch information
Showing
11 changed files
with
105 additions
and
25 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
SECRET_ENV_PREFIX = "DBT_ENV_SECRET_" | ||
DEFAULT_ENV_PLACEHOLDER = "DBT_DEFAULT_PLACEHOLDER" | ||
METADATA_ENV_PREFIX = "DBT_ENV_CUSTOM_ENV_" |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pytest | ||
import json | ||
import os | ||
|
||
from dbt.tests.util import run_dbt_and_capture | ||
|
||
|
||
def parse_json_logs(json_log_output): | ||
parsed_logs = [] | ||
for line in json_log_output.split("\n"): | ||
try: | ||
log = json.loads(line) | ||
except ValueError: | ||
continue | ||
|
||
parsed_logs.append(log) | ||
|
||
return parsed_logs | ||
|
||
|
||
class TestCustomVarInLogs: | ||
@pytest.fixture(scope="class", autouse=True) | ||
def setup(self): | ||
# on windows, python uppercases env var names because windows is case insensitive | ||
os.environ["DBT_ENV_CUSTOM_ENV_SOME_VAR"] = "value" | ||
yield | ||
del os.environ["DBT_ENV_CUSTOM_ENV_SOME_VAR"] | ||
|
||
def test_extra_filled(self, project): | ||
_, log_output = run_dbt_and_capture(['--log-format=json', 'deps'],) | ||
logs = parse_json_logs(log_output) | ||
for log in logs: | ||
assert log['info'].get('extra') == {"SOME_VAR": "value"} |
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