Skip to content

Commit

Permalink
Ele 3008 project name (#1506)
Browse files Browse the repository at this point in the history
* #1496 - add project-name and env to slack notification

* Small changes to add_title_to_slack_alert (@ellakz's suggestion from the other PR)

---------

Co-authored-by: Wojciech Kostka <wojciech.kostka@contractors.roche.com>
Co-authored-by: Itamar Hartstein <haritamar@gmail.com>
  • Loading branch information
3 people committed May 27, 2024
1 parent fb37554 commit dddfe3c
Show file tree
Hide file tree
Showing 4 changed files with 11 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,10 @@ 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):
context = f"- {project_name} ({env})" if project_name else f"({env})"
title_blocks = [
self.create_header_block(":mag: Monitoring summary"),
self.create_header_block(f":mag: Monitoring summary {context}"),
self.create_divider_block(),
]
self._add_always_displayed_blocks(title_blocks)
Expand Down

0 comments on commit dddfe3c

Please sign in to comment.