Skip to content

Conversation

@kdelemme
Copy link
Contributor

@kdelemme kdelemme commented Dec 5, 2025

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.

@kdelemme kdelemme self-assigned this Dec 5, 2025
@kdelemme kdelemme added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. v9.3.0 labels Dec 5, 2025
@github-actions github-actions bot added the author:actionable-obs PRs authored by the actionable obs team label Dec 5, 2025
@kdelemme kdelemme added the ci:beta-faster-pr-build Uses an alternative PR build pipeline with speed optimizations label Dec 5, 2025
@elasticmachine
Copy link
Contributor

elasticmachine commented Dec 5, 2025

💔 Build Failed

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
observability 1.7MB 1.7MB +144.0B
slo 993.2KB 993.5KB +261.0B
synthetics 1.0MB 1.0MB +144.0B
total +549.0B

History

cc @kdelemme

@kdelemme kdelemme marked this pull request as ready for review December 9, 2025 18:12
@kdelemme kdelemme requested review from a team as code owners December 9, 2025 18:12
@elasticmachine
Copy link
Contributor

Pinging @elastic/actionable-obs-team (Team:actionable-obs)

Copy link
Contributor

Copilot AI left a 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 SLOSettingsRepository interface with DefaultSLOSettingsRepository implementation for better abstraction and testability
  • Separated StoredSLOSettings and SLOSettings types to properly handle optional fields in stored objects vs runtime requirements
  • Refactored excludeStaleSummaryFilter function 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

@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:actionable-obs PRs authored by the actionable obs team backport:skip This PR does not require backporting ci:beta-faster-pr-build Uses an alternative PR build pipeline with speed optimizations release_note:skip Skip the PR/issue when compiling release notes Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. Team:obs-ux-management v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants