Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ele 4028 format alerts messages #1796

Merged
merged 24 commits into from
Feb 6, 2025
Merged

Conversation

MikaKerman
Copy link
Contributor

@MikaKerman MikaKerman commented Feb 3, 2025

null

Copy link

linear bot commented Feb 3, 2025

Copy link
Contributor

github-actions bot commented Feb 3, 2025

👋 @MikaKerman
Thank you for raising your pull request.
Please make sure to add tests and document all user-facing changes.
You can do this by editing the docs files in this pull request.

@MikaKerman MikaKerman force-pushed the ele-4028-send-alerts-messages branch from e23e40d to 7baf655 Compare February 4, 2025 08:16
- Implemented `test_alert_message.py` with functions to generate structured alert messages for dbt tests
- Created utility functions to handle alert status, colors, and message block generation
- Added comprehensive test suite in `test_dbt_test_alert_message.py` to validate message body generation
- Updated `messages/utils.py` to improve JSON comparison in unit tests
- Implemented `get_elementary_test_alert_message_body()` in `test_alert_message.py` to generate structured alert messages for Elementary tests
- Added support for different test types like schema changes and anomaly detection
- Created comprehensive test suite in `test_elementary_test_alert_message.py` to validate message body generation
- Introduced utility functions to handle test alert titles and result blocks
- Updated test fixtures and utility functions to support new alert message generation
- Implemented `get_snapshot_alert_message_body()` in `test_alert_message.py` to generate structured alert messages for snapshot alerts
- Updated utility functions like `get_details_blocks()` and `get_result_blocks()` to support snapshot alert message generation
- Added comprehensive test suite in `test_snapshot_alert_message.py` to validate snapshot alert message body generation
- Introduced flexible message generation that handles various alert scenarios with optional fields
- Implemented `get_model_alert_message_body()` in `test_alert_message.py` to generate structured alert messages for model alerts
- Added `get_model_alert_config_blocks()` to support model-specific configuration details
- Created comprehensive test suite in `test_model_alert_message.py` to validate model alert message body generation
- Updated test utilities to support model alert message generation with various scenarios
- Implemented `get_source_freshness_alert_message_body()` in `test_alert_message.py` to generate structured alert messages for source freshness alerts
- Added `get_source_freshness_alert_config_blocks()` to support source freshness-specific configuration details
- Updated utility functions to include new status types and additional information blocks
- Created comprehensive test suite in `test_source_freshness_alert_message.py` to validate source freshness alert message body generation
- Implemented `get_alerts_group_message_body()` in `test_alert_message.py` to generate structured alert messages for groups of alerts
- Added new utility functions `get_alert_type_counters_subtitle_block()`, `get_alert_list_line()`, and `get_alert_list_blocks()` to support alerts group message generation
- Created comprehensive test suite in `test_alerts_group_message.py` to validate alerts group message body generation
- Supports multiple alert types including model errors, test failures, test warnings, and test errors
- Handles alerts with different ownership and optional report links
…arios

- Added support for handling alerts without a consistent model unique ID
- Implemented fallback summary generation when no model is available
- Added new properties to aggregate tags, owners, and subscribers across alerts
- Improved null-safety and type handling for model and summary properties
- Implemented `get_group_by_table_alert_message_body()` in `test_alert_message.py` to generate structured alert messages for alerts grouped by table
- Created comprehensive test suite in `test_group_by_table_alert_message.py` to validate group by table alert message body generation
- Updated utility functions to support sorting and displaying owners consistently
- Added support for generating messages with various alert types and configurations
…bscribers

- Added fallback text for empty lists to ensure consistent message formatting
@MikaKerman MikaKerman force-pushed the ele-4028-send-alerts-messages branch from c14fda0 to a37d0a2 Compare February 4, 2025 09:31
…nction to return `None` when input status is `None`
- Modify function to remove duplicate entries for tags, owners, and subscribers
@MikaKerman MikaKerman force-pushed the ele-4028-send-alerts-messages branch 2 times, most recently from 05d0a36 to 86f5b24 Compare February 4, 2025 13:31
elementary/monitor/alerts/alert_messages/builder.py Outdated Show resolved Hide resolved
elementary/monitor/alerts/alert_messages/builder.py Outdated Show resolved Hide resolved
elementary/monitor/alerts/alert_messages/builder.py Outdated Show resolved Hide resolved
elementary/monitor/alerts/alert_messages/builder.py Outdated Show resolved Hide resolved
facts = []
if materialization:
facts.append(("Materialization", materialization))
if full_refresh:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if full_refresh is not None

if len(owners) == 1:
inlines.append(TextBlock(text=f"Owner: {owners.pop()}"))
else:
# order owners by alphabetical order
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant comment is redundant

- Introduced `AlertMessageBuilder` class in `builder.py` to consolidate alert message generation logic
- Replaced multiple individual message generation functions with a single, flexible `build()` method
- Updated test utilities to use the new `get_alert_message_body()` function with the `AlertMessageBuilder`
- Removed the deprecated `test_alert_message.py` file
- Maintained existing functionality while improving code organization and reusability
- Introduced `PrimaryFactBlock()` and `NonPrimaryFactBlock()` functions to create fact blocks with configurable primary status
- Simplified fact block creation by extracting common logic into a shared implementation
- Supports creating fact blocks with flexible title and value configurations
@MikaKerman MikaKerman force-pushed the ele-4028-send-alerts-messages branch from 3bbd7d8 to ba19e7c Compare February 5, 2025 09:15
… placement

- Add divider blocks between different alert type sections
- Ensure clean separation of model errors, test failures, test warnings, and test errors
- Modify block extension logic to maintain a clear and organized alert message structure
…de test combinations

- Removed `itertools.product()` and global test parameter lists from multiple test files
- Replaced dynamic parameter generation with explicit, predefined test combinations
- Simplified test parameter generation while maintaining comprehensive test coverage
- Improved readability by removing unnecessary imports and global variables
- Formatted adaptive card filename generation for better consistency across test files
@MikaKerman
Copy link
Contributor Author

MikaKerman commented Feb 5, 2025

@ofek1weiss I have reduced the number of test cases.

- Introduced `DEFAULT_ENV` constant with value "dev"
- Updated `Config` class constructor to use `DEFAULT_ENV` as default environment
- Added `specified_env` property to return environment only if it differs from default
- Updated alert model classes to include an optional `env` parameter
- Modified alert data schemas to pass the `env` parameter during alert model creation
- Integrated environment specification in data monitoring alerts generation
- Updated `BaseAlertsGroup` and `AlertsGroup` to include an optional `env` parameter
- Modified `DataMonitoringAlerts` to pass environment when creating grouped alerts
- Updated base integration to propagate environment when grouping alerts
- Ensures environment context is preserved across alert processing and grouping
- Added environment parameter to test cases for various alert message types
- Modified test file names to include environment flag
- Updated test utilities to conditionally set environment in test alerts
- Ensured comprehensive test coverage for alerts with and without environment context
@MikaKerman
Copy link
Contributor Author

@ofek1weiss
Also added an env to the alert, in case it was specified with "--env X" in the cli

@MikaKerman MikaKerman changed the title Ele 4028 send alerts messages Ele 4028 format alerts messages Feb 5, 2025
- Refactored subtitle block generation for different alert types into a single method
- Simplified type checking and block creation for test, model, snapshot, and source alerts
- Reduced code duplication by using a unified approach to generate subtitle blocks
- Updated test files to use UTC timezone for datetime objects
- Imported `timezone` from `datetime` in alert message test files
- Ensured consistent timezone handling across different alert message test scenarios
@MikaKerman MikaKerman merged commit a7682e1 into master Feb 6, 2025
4 checks passed
@MikaKerman MikaKerman deleted the ele-4028-send-alerts-messages branch February 6, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants