-
Notifications
You must be signed in to change notification settings - Fork 8.5k
chore(slo): code cleanup and settings refactoring #245444
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
base: main
Are you sure you want to change the base?
Conversation
💔 Build Failed
Failed CI StepsMetrics [docs]Async chunks
Historycc @kdelemme |
|
Pinging @elastic/actionable-obs-team (Team:actionable-obs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the SLO settings management by introducing a proper repository pattern and improving type handling across the application. The changes include extracting utility functions, adding comprehensive test coverage, and implementing error handling for health data computation.
Key Changes:
- Introduced
SLOSettingsRepositoryinterface withDefaultSLOSettingsRepositoryimplementation for better abstraction and testability - Separated
StoredSLOSettingsandSLOSettingstypes to properly handle optional fields in stored objects vs runtime requirements - Refactored
excludeStaleSummaryFilterfunction into a dedicated utility with improved parameter handling and test coverage
Reviewed changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
x-pack/solutions/observability/test/api_integration_deployment_agnostic/services/slo_api.ts |
Added getSettings and updateSettings test helper methods |
x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/slo/slo_settings.ts |
New comprehensive API integration tests for SLO settings with serverless/non-serverless variants |
x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/slo/index.ts |
Added new test file to test suite |
x-pack/solutions/observability/test/api_integration_deployment_agnostic/apis/slo/find_slo_definition.ts |
Added test for finding SLOs with health data |
x-pack/solutions/observability/plugins/slo/server/services/utils/summary_stale_filter.ts |
Refactored filter function with improved API using named parameters object |
x-pack/solutions/observability/plugins/slo/server/services/utils/summary_stale_filter.test.ts |
New unit tests covering all filter logic branches |
x-pack/solutions/observability/plugins/slo/server/services/utils/get_summary_indices.ts |
Extracted utility function for getting summary indices |
x-pack/solutions/observability/plugins/slo/server/services/summary_utils.test.ts |
Deleted - tests moved to dedicated utility test file |
x-pack/solutions/observability/plugins/slo/server/services/summary_search_client/summary_search_client.ts |
Updated to use settings repository via dependency injection instead of direct SO client access |
x-pack/solutions/observability/plugins/slo/server/services/summary_search_client/summary_search_client.test.ts |
Updated test setup to inject settings directly |
x-pack/solutions/observability/plugins/slo/server/services/slo_settings_repository.ts |
New repository implementation with proper type conversion between stored and runtime settings |
x-pack/solutions/observability/plugins/slo/server/services/slo_settings.ts |
Deleted - functionality replaced by repository pattern |
x-pack/solutions/observability/plugins/slo/server/services/purge_instances.ts |
Refactored to receive settings via dependency injection |
x-pack/solutions/observability/plugins/slo/server/services/get_slo_stats_overview.ts |
Updated to use settings repository instead of direct SO client |
x-pack/solutions/observability/plugins/slo/server/services/get_slo_groupings.ts |
Fixed constant usage from INDEX_NAME to INDEX_PATTERN |
x-pack/solutions/observability/plugins/slo/server/services/find_slo_groups.ts |
Updated to use settings repository via dependency injection |
x-pack/solutions/observability/plugins/slo/server/services/find_slo_definitions.ts |
Added error handling with fallback when health computation fails |
x-pack/solutions/observability/plugins/slo/server/services/find_slo_definitions.test.ts |
Added test for error handling when health computation fails |
x-pack/solutions/observability/plugins/slo/server/routes/types.ts |
Added settingsRepository to route handler scoped clients |
x-pack/solutions/observability/plugins/slo/server/routes/slo/update_slo_settings.ts |
Renamed from put_slo_settings.ts, uses repository pattern with proper defaults merging |
x-pack/solutions/observability/plugins/slo/server/routes/slo/route.ts |
Updated import and usage to renamed updateSloSettings |
x-pack/solutions/observability/plugins/slo/server/routes/slo/purge_instances.ts |
Updated to fetch settings via repository |
x-pack/solutions/observability/plugins/slo/server/routes/slo/get_slo_stats_overview.ts |
Updated to use settings repository |
x-pack/solutions/observability/plugins/slo/server/routes/slo/get_slo_settings.ts |
Refactored to use settings repository instead of direct helper function |
x-pack/solutions/observability/plugins/slo/server/routes/slo/get_groupings.ts |
Updated to use settings repository |
x-pack/solutions/observability/plugins/slo/server/routes/slo/find_slo.ts |
Updated to inject settings into summary search client |
x-pack/solutions/observability/plugins/slo/server/routes/slo/find_groups.ts |
Updated to use settings repository |
x-pack/solutions/observability/plugins/slo/server/routes/slo/find_definitions.ts |
Added logger dependency to FindSLODefinitions constructor |
x-pack/solutions/observability/plugins/slo/server/plugin.ts |
Instantiated settings repository in scoped clients factory |
x-pack/solutions/observability/plugins/slo/server/domain/models/common.ts |
Updated StoredSLOSettings type to use storedSloSettingsSchema |
x-pack/solutions/observability/plugins/slo/server/client/index.ts |
Updated to use settings repository pattern |
x-pack/solutions/observability/plugins/slo/public/pages/slos/hooks/use_summary_dataview.ts |
Updated to use new getSLOSummaryIndices function signature with named parameters |
x-pack/solutions/observability/plugins/slo/common/get_slo_summary_indices.ts |
Refactored to use named parameters object instead of positional parameters |
x-pack/solutions/observability/plugins/slo/common/get_slo_summary_indices.test.ts |
Updated tests for new function signature |
x-pack/platform/packages/shared/kbn-slo-schema/src/schema/settings.ts |
Separated storedSloSettingsSchema (with optional fields) from runtime sloSettingsSchema |
x-pack/platform/packages/shared/kbn-slo-schema/src/rest_specs/routes/put_settings.ts |
Renamed sloServerlessSettingsSchema to serverlessSloSettingsSchema for consistency |
x-pack/solutions/observability/plugins/slo/server/services/find_slo_groups.ts
Outdated
Show resolved
Hide resolved
|
Pinging @elastic/obs-ux-management-team (Team:obs-ux-management) |
Summary
This PR started as a quick cleanup of some small 💩 left by Cursor here and there.
But then it become a bigger side quest including a full refactoring of the SLO settings repository to properly handle some types across the app, and harnessing the SLO Definition service when requiring the health data in case of runtime errors.
Added some tests for the SLO settings as well.