Skip to content

Commit

Permalink
elementary-data#1496 - add project-name and env to slack notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojciech Kostka committed Apr 19, 2024
1 parent a52ba6b commit f70e9e6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions elementary/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ def __init__(
teams_webhook: Optional[str] = None,
env: str = "dev",
run_dbt_deps_if_needed: Optional[bool] = None,
project_name: Optional[str] = None,
):
self.config_dir = config_dir
self.profiles_dir = profiles_dir
self.project_dir = project_dir
self.profile_target = profile_target
self.project_profile_target = project_profile_target
self.env = env
self.project_name = project_name

# Additional env vars supplied to dbt invocations
self.env_vars = dict()
Expand Down
1 change: 1 addition & 0 deletions elementary/monitor/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ def send_report(
gcs_timeout_limit=gcs_timeout_limit,
report_url=report_url,
env=env,
project_name=project_name,
)
anonymous_tracking = AnonymousCommandLineTracking(config)
anonymous_tracking.set_env("use_select", bool(select))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ def send_test_results_summary(
include_description=include_description,
filter=self.selector_filter.to_selector_filter_schema(),
days_back=days_back,
env=self.config.env,
project_name=self.config.project_name,
),
)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ def get_slack_message(
self,
test_results: List[TestResultSummarySchema],
days_back: int,
env: str,
bucket_website_url: Optional[str] = None,
filter: SelectorFilterSchema = SelectorFilterSchema(),
include_description: bool = False,
project_name: Optional[str] = None,
) -> SlackMessageSchema:
self.add_title_to_slack_alert()
self.add_title_to_slack_alert(env, project_name)
self.add_preview_to_slack_alert(
test_results,
days_back=days_back,
Expand All @@ -34,9 +36,12 @@ def get_slack_message(
)
return super().get_slack_message()

def add_title_to_slack_alert(self):
def add_title_to_slack_alert(self, env: str, project_name: Optional[str] = None):
_project_name = f"for the {project_name} " if project_name else ""
title_blocks = [
self.create_header_block(":mag: Monitoring summary"),
self.create_header_block(
f":mag: Monitoring summary {_project_name}({env})"
),
self.create_divider_block(),
]
self._add_always_displayed_blocks(title_blocks)
Expand Down

0 comments on commit f70e9e6

Please sign in to comment.