Skip to content

Conversation

@joshuali925
Copy link
Member

@joshuali925 joshuali925 commented Dec 4, 2025

Description

add signal type to dataset interface. For prometheus, there's no index-pattern or dataview, but we still need some place to store the signal type, so that prometheus only shows up in metrics

Issues Resolved

Screenshot

Testing the changes

Changelog

  • skip

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Summary by CodeRabbit

  • New Features

    • Datasets can now be classified by signal type (logs, metrics, traces) for improved organization and filtering.
    • Enhanced compatibility validation ensures datasets match the current app flavor.
  • Bug Fixes

    • Query is now properly cleared when switching to an incompatible dataset type.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

Walkthrough

This PR adds an optional signalType field to the Dataset interface and updates redux persistence logic to filter datasets based on signal type compatibility with the current flavor, enabling distinction between logs, metrics, and traces data sources.

Changes

Cohort / File(s) Summary
Dataset type definition
src/plugins/data/common/datasets/types.ts
Added optional signalType?: string property to the Dataset interface to classify dataset signals (e.g., 'logs', 'metrics', 'traces').
Redux persistence state management
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts
Updated loadReduxState, fetchFirstAvailableDataset, resolveDataset, and getPreloadedQueryState functions to propagate signalType through state and validate dataset compatibility against flavor-derived requiredSignalType. Datasets with incompatible signal types are filtered out; queries are reset when datasets change due to type mismatch.
Redux persistence tests
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.test.ts
Added test suite "Metrics flavor SignalType handling" with three tests validating acceptance and rejection of Metrics/Logs/Traces datasets based on flavor compatibility. Updated existing tests to reflect query clearing behavior when dataset type changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • redux_persistence.ts: Requires careful review of signal type validation logic, effectiveSignalType derivation, and state propagation paths across multiple conditional branches
  • Test coverage: Verify that new test scenarios properly validate Metrics/Logs/Traces interaction patterns and that mocking correctly simulates expected behavior
  • State mutations: Confirm query/language reset logic is correctly triggered only when dataset type changes due to signal type filtering

Poem

🐰 Hopping through datasets, what tales they hold—
Logs, metrics, traces, each type neatly storied!
Signal types sorted like carrots of gold,
The redux now knows which flavors are glorified! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main objective: adding a dataset signal type field to prevent Prometheus from appearing in logs.
Description check ✅ Passed The description covers the main purpose but lacks details on issues resolved, testing steps, and UI changes, though the changelog skip is included.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 65ea019 and 9d504cd.

📒 Files selected for processing (3)
  • src/plugins/data/common/datasets/types.ts (1 hunks)
  • src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.test.ts (2 hunks)
  • src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/plugins/data/common/datasets/types.ts
🧰 Additional context used
🧬 Code graph analysis (2)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.test.ts (2)
src/plugins/data/common/index_patterns/types.ts (1)
  • CORE_SIGNAL_TYPES (41-45)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (1)
  • getPreloadedState (134-152)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (2)
src/plugins/data/public/index.ts (1)
  • QueryState (539-539)
src/plugins/data/common/index_patterns/types.ts (1)
  • CORE_SIGNAL_TYPES (41-45)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (68)
  • GitHub Check: Run functional tests on Linux (ciGroup2)
  • GitHub Check: Run functional tests on Linux (ciGroup13)
  • GitHub Check: Run functional tests on Windows (ciGroup9)
  • GitHub Check: Run functional tests on Windows (ciGroup6)
  • GitHub Check: Run functional tests on Windows (ciGroup8)
  • GitHub Check: Run functional tests on Windows (ciGroup13)
  • GitHub Check: Run functional tests on Windows (ciGroup11)
  • GitHub Check: Run functional tests on Windows (ciGroup12)
  • GitHub Check: Run functional tests on Linux (ciGroup7)
  • GitHub Check: Run functional tests on Windows (ciGroup10)
  • GitHub Check: Run functional tests on Windows (ciGroup7)
  • GitHub Check: Run functional tests on Windows (ciGroup1)
  • GitHub Check: Run functional tests on Linux (ciGroup12)
  • GitHub Check: Run functional tests on Windows (ciGroup5)
  • GitHub Check: Run functional tests on Linux (ciGroup4)
  • GitHub Check: Run functional tests on Windows (ciGroup2)
  • GitHub Check: Run cypress tests (osd:ciGroup1)
  • GitHub Check: Run functional tests on Linux (ciGroup10)
  • GitHub Check: Run functional tests on Windows (ciGroup3)
  • GitHub Check: Run cypress tests (osd:ciGroup16Explore)
  • GitHub Check: Run functional tests on Linux (ciGroup8)
  • GitHub Check: Run functional tests on Windows (ciGroup4)
  • GitHub Check: Run functional tests on Linux (ciGroup11)
  • GitHub Check: Run cypress tests (osd:ciGroup17Explore)
  • GitHub Check: Run functional tests on Linux (ciGroup6)
  • GitHub Check: Run functional tests on Linux (ciGroup5)
  • GitHub Check: Run cypress tests (osd:ciGroup10Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup15Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup14)
  • GitHub Check: Run cypress tests (osd:ciGroup14Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup12Explore)
  • GitHub Check: Run functional tests on Linux (ciGroup3)
  • GitHub Check: Run cypress tests (osd:ciGroup12)
  • GitHub Check: Run functional tests on Linux (ciGroup1)
  • GitHub Check: Run cypress tests (osd:ciGroup13Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup15)
  • GitHub Check: Run functional tests on Linux (ciGroup9)
  • GitHub Check: Run cypress tests (osd:ciGroup2)
  • GitHub Check: Run cypress tests (osd:ciGroup11)
  • GitHub Check: Run cypress tests (osd:ciGroup9)
  • GitHub Check: Run cypress tests (osd:ciGroup3)
  • GitHub Check: Run cypress tests (osd:ciGroup8)
  • GitHub Check: Run cypress tests (osd:ciGroup10Slow)
  • GitHub Check: Run cypress tests (osd:ciGroup4)
  • GitHub Check: Run cypress tests (osd:ciGroup10Fast)
  • GitHub Check: Run cypress tests (osd:ciGroup13)
  • GitHub Check: Run cypress tests (osd:ciGroup6)
  • GitHub Check: Run cypress tests (osd:ciGroup7)
  • GitHub Check: Run cypress tests (osd:ciGroup5)
  • GitHub Check: Build and Verify on Linux (ciGroup4)
  • GitHub Check: Build and Verify on Windows (ciGroup3)
  • GitHub Check: Build and Verify on Linux (ciGroup3)
  • GitHub Check: Build and Verify on Windows (ciGroup4)
  • GitHub Check: Build and Verify on Linux (ciGroup1)
  • GitHub Check: Build min release artifacts on macOS ARM64
  • GitHub Check: Build and Verify on Linux (ciGroup2)
  • GitHub Check: Build and Verify on Windows (ciGroup1)
  • GitHub Check: Build and Verify on Windows (ciGroup2)
  • GitHub Check: Build min release artifacts on Linux ARM64
  • GitHub Check: Build min release artifacts on macOS x64
  • GitHub Check: bundle-analyzer
  • GitHub Check: linkchecker
  • GitHub Check: Build min release artifacts on Linux x64
  • GitHub Check: Build min release artifacts on Windows x64
  • GitHub Check: Run plugin functional tests on Linux
  • GitHub Check: Lint and validate
  • GitHub Check: Run plugin functional tests on Windows
  • GitHub Check: lighthouse
🔇 Additional comments (8)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.test.ts (2)

672-673: LGTM: Clear explanation of query clearing behavior.

The updated comment accurately reflects that the query is cleared when the dataset changes due to signal type incompatibility, which aligns with the implementation logic.


771-856: LGTM: Comprehensive test coverage for Metrics flavor signal type filtering.

The new test suite thoroughly validates that:

  • Metrics flavor accepts datasets with METRICS signal type (including Prometheus datasets)
  • Metrics flavor rejects datasets with other signal types
  • Other flavors (Logs) correctly reject Metrics datasets

The test mocks appropriately simulate both dataView-based and dataset-based signal type sources, which is essential for testing Prometheus datasets that set signalType directly on the dataset object.

src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (6)

82-82: LGTM: Correct signalType propagation from URL state.

The addition of signalType to the URL-derived dataset ensures signal type information is preserved when loading state from the URL.


90-100: LGTM: Appropriate handling of dataset changes.

The logic correctly detects when the dataset has changed due to signal type filtering and:

  • Updates the language to match the new dataset
  • Clears the query to avoid incompatibility issues

This prevents attempting to execute queries that may be invalid for the new dataset.


195-212: LGTM: Correct signal type filtering in dataset fetching.

The effective signal type resolution correctly handles both:

  • Index patterns where signal type comes from the dataView
  • Prometheus datasets where signal type is set directly on the dataset

The filtering logic appropriately:

  • Matches exact signal type for Traces/Metrics flavors
  • Excludes Traces/Metrics datasets for Logs flavor while accepting others

237-241: LGTM: Correct flavor to signal type mapping.

The mapping appropriately translates explore flavors to their required signal types, with Logs flavor having no specific requirement (undefined).


261-273: LGTM: Consistent signal type validation logic.

The validation logic correctly mirrors the filtering logic in fetchFirstAvailableDataset, ensuring consistent behavior across dataset resolution paths.


307-307: LGTM: Correct signalType preservation in minimal dataset.

Including signalType in the minimal dataset construction ensures the signal type information is preserved through the state management flow.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added distinguished-contributor Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry labels Dec 4, 2025
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.80%. Comparing base (4fe1241) to head (9d504cd).

Files with missing lines Patch % Lines
.../utils/state_management/utils/redux_persistence.ts 76.92% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11033   +/-   ##
=======================================
  Coverage   60.80%   60.80%           
=======================================
  Files        4538     4538           
  Lines      122703   122711    +8     
  Branches    20617    20625    +8     
=======================================
+ Hits        74605    74611    +6     
  Misses      42813    42813           
- Partials     5285     5287    +2     
Flag Coverage Δ
Linux_1 26.62% <ø> (ø)
Linux_2 38.97% <ø> (ø)
Linux_3 39.48% <ø> (ø)
Linux_4 33.77% <76.92%> (+<0.01%) ⬆️
Windows_1 26.63% <ø> (ø)
Windows_2 38.95% <ø> (ø)
Windows_3 39.49% <ø> (ø)
Windows_4 33.77% <76.92%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/plugins/data/common/datasets/types.ts (1)

277-278: Consider using a stricter type for signalType.

The signalType property uses a loose string type. Given that CORE_SIGNAL_TYPES is defined in src/plugins/data/common/index_patterns/types.ts with specific values ('logs', 'metrics', 'traces'), consider using a union type or the const type for better type safety:

-  /** Optional signal type for the dataset (e.g., 'logs', 'metrics', 'traces') */
-  signalType?: string;
+  /** Optional signal type for the dataset (e.g., 'logs', 'metrics', 'traces') */
+  signalType?: typeof CORE_SIGNAL_TYPES[keyof typeof CORE_SIGNAL_TYPES];

This would require importing CORE_SIGNAL_TYPES from ../index_patterns/types. If extensibility for future signal types is intended, keeping string is acceptable.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad3dcd8 and f7fd27b.

📒 Files selected for processing (3)
  • src/plugins/data/common/datasets/types.ts (1 hunks)
  • src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.test.ts (1 hunks)
  • src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.test.ts (3)
src/plugins/home/public/application/sample_data_client.test.js (1)
  • mockServices (38-44)
src/plugins/data/common/index_patterns/types.ts (1)
  • CORE_SIGNAL_TYPES (41-45)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (1)
  • getPreloadedState (134-152)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (2)
src/plugins/data/public/index.ts (1)
  • QueryState (539-539)
src/plugins/data/common/index_patterns/types.ts (1)
  • CORE_SIGNAL_TYPES (41-45)
🔇 Additional comments (6)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.test.ts (1)

771-856: Good test coverage for Metrics flavor handling.

The new test suite provides comprehensive coverage for Metrics flavor SignalType validation:

  • Verifies Metrics datasets are accepted for Metrics flavor
  • Verifies non-Metrics datasets are rejected for Metrics flavor
  • Verifies Metrics datasets are rejected for Logs flavor

This mirrors the existing Traces flavor tests and ensures symmetric behavior.

src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (5)

90-101: LGTM: Dataset change detection and language handling.

The logic correctly detects when the dataset changes (by id or type) due to SignalType filtering and appropriately updates the language to match the resolved dataset. This ensures query compatibility when a dataset is swapped for flavor compliance.


236-241: Correct flavor-to-signalType mapping.

The nested ternary correctly maps ExploreFlavor.Traces to CORE_SIGNAL_TYPES.TRACES and ExploreFlavor.Metrics to CORE_SIGNAL_TYPES.METRICS, with undefined for the Logs flavor (which uses exclusion logic instead).


204-211: Correct exclusion of TRACES and METRICS from Logs flavor.

The updated logic ensures both TRACES and METRICS signalType datasets are excluded when no requiredSignalType is specified (i.e., Logs flavor). This aligns with the PR objective to have Prometheus appear only under Metrics.


82-82: LGTM: signalType propagation in URL dataset.

Including signalType in the URL dataset construction ensures the signal type is preserved when loading state from URL parameters.


301-308: LGTM: signalType included in minimal dataset construction.

The signalType is correctly propagated to the minimal dataset, ensuring it's preserved through the dataset resolution and preloaded state pipeline.

Comment on lines +256 to +258
// Get effective signal type from dataView or preferredDataset (for Prometheus which sets signalType directly)
const effectiveSignalType = dataView?.signalType || preferredDataset?.signalType;

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Potential bug: effectiveSignalType may not consider existingDataset.signalType.

At line 257, effectiveSignalType falls back to preferredDataset?.signalType, but existingDataset (line 246) could come from queryStringQuery?.dataset or defaultQuery?.dataset, not just preferredDataset. If the existing dataset from those sources has a signalType but preferredDataset is undefined, the fallback won't capture it.

Consider using existingDataset.signalType as the fallback:

       // Get effective signal type from dataView or preferredDataset (for Prometheus which sets signalType directly)
-      const effectiveSignalType = dataView?.signalType || preferredDataset?.signalType;
+      const effectiveSignalType = dataView?.signalType || existingDataset.signalType;

This ensures signalType is considered regardless of how existingDataset was resolved.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Get effective signal type from dataView or preferredDataset (for Prometheus which sets signalType directly)
const effectiveSignalType = dataView?.signalType || preferredDataset?.signalType;
// Get effective signal type from dataView or preferredDataset (for Prometheus which sets signalType directly)
const effectiveSignalType = dataView?.signalType || existingDataset.signalType;
🤖 Prompt for AI Agents
In
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts
around lines 256 to 258 (existingDataset is resolved around line 246),
effectiveSignalType currently uses dataView?.signalType ||
preferredDataset?.signalType and misses existingDataset.signalType; update the
fallback chain to include existingDataset.signalType (e.g., dataView?.signalType
|| preferredDataset?.signalType || existingDataset?.signalType) so the resolved
signalType covers datasets from queryStringQuery/defaultQuery as well as
preferredDataset.

@joshuali925 joshuali925 force-pushed the dataset-signal-type branch 2 times, most recently from 7ed1b9b to ab2c71b Compare December 9, 2025 23:07
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (1)

256-258: The effectiveSignalType fallback may miss existingDataset.signalType.

As flagged in a previous review, when preferredDataset is undefined but existingDataset is resolved from queryStringQuery?.dataset or defaultQuery?.dataset (line 246), their signalType won't be considered in the fallback at line 257.

       // Get effective signal type from dataView or preferredDataset (for Prometheus which sets signalType directly)
-      const effectiveSignalType = dataView?.signalType || preferredDataset?.signalType;
+      const effectiveSignalType = dataView?.signalType || existingDataset?.signalType;
🧹 Nitpick comments (1)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.test.ts (1)

771-856: Good test coverage for Metrics flavor signalType handling.

The tests cover the essential scenarios for getPreloadedState. For completeness and consistency with the existing loadReduxState with SignalType validation for URL datasets test suite (lines 586-768), consider adding a parallel test for Metrics flavor URL dataset validation (e.g., rejecting a Logs dataset URL for Metrics flavor and fetching a compatible Metrics dataset).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ed1b9b and ab2c71b.

📒 Files selected for processing (3)
  • src/plugins/data/common/datasets/types.ts (1 hunks)
  • src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.test.ts (2 hunks)
  • src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/plugins/data/common/datasets/types.ts
🧰 Additional context used
🧬 Code graph analysis (1)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (2)
src/plugins/data/public/index.ts (1)
  • QueryState (539-539)
src/plugins/data/common/index_patterns/types.ts (1)
  • CORE_SIGNAL_TYPES (41-45)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (67)
  • GitHub Check: Run cypress tests (osd:ciGroup15Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup16Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup17Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup10Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup11)
  • GitHub Check: Run cypress tests (osd:ciGroup2)
  • GitHub Check: Run cypress tests (osd:ciGroup14)
  • GitHub Check: Run cypress tests (osd:ciGroup12Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup13Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup14Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup13)
  • GitHub Check: Run cypress tests (osd:ciGroup15)
  • GitHub Check: Run cypress tests (osd:ciGroup9)
  • GitHub Check: Run cypress tests (osd:ciGroup12)
  • GitHub Check: Run cypress tests (osd:ciGroup6)
  • GitHub Check: Run cypress tests (osd:ciGroup8)
  • GitHub Check: Run cypress tests (osd:ciGroup10Slow)
  • GitHub Check: Run cypress tests (osd:ciGroup7)
  • GitHub Check: Run cypress tests (osd:ciGroup10Fast)
  • GitHub Check: Run cypress tests (osd:ciGroup5)
  • GitHub Check: Run cypress tests (osd:ciGroup4)
  • GitHub Check: Run cypress tests (osd:ciGroup1)
  • GitHub Check: Run cypress tests (osd:ciGroup3)
  • GitHub Check: Run functional tests on Windows (ciGroup13)
  • GitHub Check: lighthouse
  • GitHub Check: Run functional tests on Linux (ciGroup7)
  • GitHub Check: Run functional tests on Windows (ciGroup11)
  • GitHub Check: Run functional tests on Windows (ciGroup6)
  • GitHub Check: Run functional tests on Windows (ciGroup7)
  • GitHub Check: Run functional tests on Windows (ciGroup5)
  • GitHub Check: Run functional tests on Linux (ciGroup11)
  • GitHub Check: Run functional tests on Linux (ciGroup12)
  • GitHub Check: Run functional tests on Windows (ciGroup1)
  • GitHub Check: Run functional tests on Windows (ciGroup2)
  • GitHub Check: Run functional tests on Linux (ciGroup8)
  • GitHub Check: Run functional tests on Windows (ciGroup9)
  • GitHub Check: Run functional tests on Windows (ciGroup12)
  • GitHub Check: Run functional tests on Linux (ciGroup4)
  • GitHub Check: Run functional tests on Linux (ciGroup5)
  • GitHub Check: Run functional tests on Windows (ciGroup8)
  • GitHub Check: Run functional tests on Linux (ciGroup2)
  • GitHub Check: Run functional tests on Windows (ciGroup10)
  • GitHub Check: Build min release artifacts on Linux ARM64
  • GitHub Check: Run functional tests on Windows (ciGroup3)
  • GitHub Check: Run functional tests on Windows (ciGroup4)
  • GitHub Check: Run functional tests on Linux (ciGroup9)
  • GitHub Check: Run functional tests on Linux (ciGroup6)
  • GitHub Check: Run functional tests on Linux (ciGroup10)
  • GitHub Check: Run functional tests on Linux (ciGroup13)
  • GitHub Check: Run functional tests on Linux (ciGroup3)
  • GitHub Check: Run functional tests on Linux (ciGroup1)
  • GitHub Check: bundle-analyzer
  • GitHub Check: Build min release artifacts on Windows x64
  • GitHub Check: Build and Verify on Windows (ciGroup3)
  • GitHub Check: Build min release artifacts on macOS x64
  • GitHub Check: Build min release artifacts on macOS ARM64
  • GitHub Check: Build and Verify on Linux (ciGroup4)
  • GitHub Check: Build and Verify on Windows (ciGroup1)
  • GitHub Check: Build and Verify on Linux (ciGroup2)
  • GitHub Check: Build and Verify on Windows (ciGroup2)
  • GitHub Check: Run plugin functional tests on Linux
  • GitHub Check: Build min release artifacts on Linux x64
  • GitHub Check: Build and Verify on Linux (ciGroup1)
  • GitHub Check: Build and Verify on Linux (ciGroup3)
  • GitHub Check: Run plugin functional tests on Windows
  • GitHub Check: Build and Verify on Windows (ciGroup4)
  • GitHub Check: Lint and validate
🔇 Additional comments (7)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.test.ts (1)

672-673: LGTM!

The updated expectation correctly reflects the implementation behavior: when the dataset changes due to signal type filtering, the query is cleared since the previous query may be incompatible with the new dataset.

src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (6)

82-82: LGTM!

Correctly propagates signalType from the URL state to maintain consistency when reconstructing the dataset.


90-101: LGTM!

The datasetChanged detection and query clearing logic ensures that incompatible queries aren't preserved when the dataset is swapped due to signal type filtering. This prevents runtime errors from executing queries against mismatched datasets.


195-211: LGTM!

The effectiveSignalType logic correctly handles both dataView-based signalType (for index patterns) and dataset-level signalType (for Prometheus which lacks a dataView). The filtering logic properly enforces signal type constraints for all flavors.


237-241: LGTM!

The ternary chain correctly maps each flavor to its required signal type.


264-272: LGTM!

The validation logic for Logs flavor correctly rejects both Traces and Metrics datasets, maintaining consistency with fetchFirstAvailableDataset.


301-308: LGTM!

Including signalType in the minimalDataset ensures that the signal type is preserved through the Redux state and URL persistence cycle.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (1)

248-272: effectiveSignalType should also consider existingDataset.signalType (reiterating earlier feedback)

Here effectiveSignalType is derived as:

const effectiveSignalType = dataView?.signalType || preferredDataset?.signalType;

But existingDataset may come from queryStringQuery?.dataset or defaultQuery?.dataset, and can already carry a signalType (especially for non‑index‑pattern datasets) even when preferredDataset is undefined. In that case, effectiveSignalType becomes undefined and the dataset is treated as “logs‑like”, potentially allowing a Metrics/Traces dataset to be used in the wrong flavor.

To cover all sources of the resolved dataset, consider including existingDataset.signalType in the fallback chain, e.g.:

-      const effectiveSignalType = dataView?.signalType || preferredDataset?.signalType;
+      const effectiveSignalType =
+        dataView?.signalType || existingDataset.signalType || preferredDataset?.signalType;

This way, datasets obtained from queryString/defaultQuery with a signalType are validated consistently with those coming in as preferredDataset.

🧹 Nitpick comments (3)
src/plugins/data/common/datasets/types.ts (1)

272-292: Dataset signalType is fine; consider tying the type to CORE_SIGNAL_TYPES for safety

Adding signalType?: string here is a good, minimally invasive way to plumb signal type into datasets. To prevent accidental typos and keep this aligned with CORE_SIGNAL_TYPES, you might later tighten the type (e.g., a SignalType union derived from CORE_SIGNAL_TYPES instead of bare string). Not urgent, just a future type-safety win.

src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.test.ts (1)

771-856: Metrics flavor tests look good; consider an additional case for dataset-only signalType

These three tests nicely cover the Metrics flavor matrix (accept Metrics, reject non‑Metrics, and reject Metrics when in Logs flavor) and line up with the signalType filtering logic in fetchFirstAvailableDataset/resolveDataset.

If you want to harden behavior around Prometheus‑style datasets that only set signalType on the dataset (and may not have a real data view), an extra test where dataViews.get returns an object without signalType (or is omitted), but toDataset() returns signalType: METRICS, would verify that path too.

src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (1)

186-219: Consider falling back to dataset signalType even when dataViews.get fails

The effectiveSignalType calculation here correctly prefers dataView?.signalType and falls back to dataset.signalType when dataViews.get succeeds:

const effectiveSignalType = dataView?.signalType || dataset.signalType;

However, if dataViews.get throws (e.g., Prometheus datasets that truly have no data view), the catch will continue and this dataset will never be considered, even if dataset.signalType is set. That slightly undermines the PR’s goal of supporting datasets “that lack an index-pattern or data view”.

You might want to treat dataset.signalType as the fallback even when dataViews.get fails, for example by computing effectiveSignalType outside the try and only overriding it when a data view is successfully loaded.

Would you confirm how dataViews.get behaves for Prometheus datasets in practice and whether it can throw for “no data view” cases?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab2c71b and 65ea019.

📒 Files selected for processing (4)
  • docs/_sidebar.md (1 hunks)
  • src/plugins/data/common/datasets/types.ts (1 hunks)
  • src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.test.ts (2 hunks)
  • src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (5 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/_sidebar.md
🧰 Additional context used
🧬 Code graph analysis (2)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.test.ts (2)
src/plugins/data/common/index_patterns/types.ts (1)
  • CORE_SIGNAL_TYPES (41-45)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (1)
  • getPreloadedState (134-152)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (2)
src/plugins/data/public/index.ts (1)
  • QueryState (539-539)
src/plugins/data/common/index_patterns/types.ts (1)
  • CORE_SIGNAL_TYPES (41-45)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (67)
  • GitHub Check: Run functional tests on Linux (ciGroup6)
  • GitHub Check: Run functional tests on Windows (ciGroup9)
  • GitHub Check: Run functional tests on Windows (ciGroup13)
  • GitHub Check: Run functional tests on Windows (ciGroup10)
  • GitHub Check: Run functional tests on Windows (ciGroup12)
  • GitHub Check: Run functional tests on Windows (ciGroup11)
  • GitHub Check: Run functional tests on Linux (ciGroup12)
  • GitHub Check: Run functional tests on Windows (ciGroup5)
  • GitHub Check: Run functional tests on Linux (ciGroup10)
  • GitHub Check: Run functional tests on Windows (ciGroup8)
  • GitHub Check: Run functional tests on Windows (ciGroup7)
  • GitHub Check: Run functional tests on Linux (ciGroup11)
  • GitHub Check: Run functional tests on Windows (ciGroup4)
  • GitHub Check: Run functional tests on Windows (ciGroup1)
  • GitHub Check: Run functional tests on Windows (ciGroup3)
  • GitHub Check: Run functional tests on Windows (ciGroup6)
  • GitHub Check: Run functional tests on Windows (ciGroup2)
  • GitHub Check: Run functional tests on Linux (ciGroup13)
  • GitHub Check: Run functional tests on Linux (ciGroup8)
  • GitHub Check: Run functional tests on Linux (ciGroup1)
  • GitHub Check: Run functional tests on Linux (ciGroup4)
  • GitHub Check: Run functional tests on Linux (ciGroup9)
  • GitHub Check: Run functional tests on Linux (ciGroup3)
  • GitHub Check: Run cypress tests (osd:ciGroup15Explore)
  • GitHub Check: Run functional tests on Linux (ciGroup7)
  • GitHub Check: Run functional tests on Linux (ciGroup5)
  • GitHub Check: Build min release artifacts on Linux ARM64
  • GitHub Check: Run cypress tests (osd:ciGroup12)
  • GitHub Check: Run functional tests on Linux (ciGroup2)
  • GitHub Check: Build min release artifacts on Windows x64
  • GitHub Check: Lint and validate
  • GitHub Check: Run cypress tests (osd:ciGroup13Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup14)
  • GitHub Check: Run cypress tests (osd:ciGroup14Explore)
  • GitHub Check: Build and Verify on Windows (ciGroup4)
  • GitHub Check: Run cypress tests (osd:ciGroup13)
  • GitHub Check: Run cypress tests (osd:ciGroup15)
  • GitHub Check: Build min release artifacts on Linux x64
  • GitHub Check: Build and Verify on Windows (ciGroup2)
  • GitHub Check: Build and Verify on Linux (ciGroup1)
  • GitHub Check: Run cypress tests (osd:ciGroup16Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup17Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup10Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup12Explore)
  • GitHub Check: Run cypress tests (osd:ciGroup5)
  • GitHub Check: lighthouse
  • GitHub Check: Build min release artifacts on macOS x64
  • GitHub Check: Build and Verify on Windows (ciGroup1)
  • GitHub Check: Build min release artifacts on macOS ARM64
  • GitHub Check: Run cypress tests (osd:ciGroup10Fast)
  • GitHub Check: Build and Verify on Windows (ciGroup3)
  • GitHub Check: Build and Verify on Linux (ciGroup3)
  • GitHub Check: Build and Verify on Linux (ciGroup4)
  • GitHub Check: Build and Verify on Linux (ciGroup2)
  • GitHub Check: Run cypress tests (osd:ciGroup10Slow)
  • GitHub Check: Run cypress tests (osd:ciGroup11)
  • GitHub Check: Run cypress tests (osd:ciGroup8)
  • GitHub Check: Run plugin functional tests on Linux
  • GitHub Check: Run cypress tests (osd:ciGroup1)
  • GitHub Check: Run cypress tests (osd:ciGroup7)
  • GitHub Check: Run cypress tests (osd:ciGroup9)
  • GitHub Check: Run cypress tests (osd:ciGroup6)
  • GitHub Check: Run cypress tests (osd:ciGroup3)
  • GitHub Check: Run cypress tests (osd:ciGroup2)
  • GitHub Check: Run cypress tests (osd:ciGroup4)
  • GitHub Check: Run plugin functional tests on Windows
  • GitHub Check: bundle-analyzer
🔇 Additional comments (5)
src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.test.ts (1)

662-674: Test expectation for clearing query on dataset change matches the new behavior

The assertion that result.query.query becomes '' when an incompatible URL dataset is replaced is consistent with loadReduxState now resetting query when datasetChanged is true. This looks correct and avoids replaying potentially incompatible queries across signal types.

src/plugins/explore/public/application/utils/state_management/utils/redux_persistence.ts (4)

72-84: Including signalType in urlDataset keeps URL and resolution paths consistent

Copying signalType from queryState.dataset into urlDataset ensures that datasets which only encode their signal type on the Dataset (e.g., Prometheus) participate correctly in subsequent validation. This is consistent with how minimalDataset is built in getPreloadedQueryState.


89-101: datasetChanged + query/language reset behavior is coherent with signalType filtering

The datasetChanged check on {id, type} and the follow‑up logic:

  • updating language from resolvedQueryState.language when the dataset changes, and
  • clearing query to '' in that case

are aligned with the intent to treat a signalType‑driven dataset swap as a fresh context. This avoids running an old query against a semantically different dataset while still preserving URL‑supplied query/language when the dataset is unchanged.


236-241: Flavor → requiredSignalType mapping is straightforward and matches ExploreFlavor

The mapping from ExploreFlavor.TracesCORE_SIGNAL_TYPES.TRACES, ExploreFlavor.MetricsCORE_SIGNAL_TYPES.METRICS, and undefined otherwise is clear and keeps Logs (and any other non‑Traces/Metrics flavors) in the “no required signal type” bucket. Looks good.


301-308: Propagating signalType into minimalDataset keeps downstream consumers consistent

Adding signalType: selectedDataset.signalType to the minimalDataset ensures that anything consuming the preloaded query state (including getInitialQueryByDataset and URL serialization) has access to the dataset’s signal type, which matches the new URL handling and filtering logic. This keeps the different initialization paths aligned.

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

Labels

distinguished-contributor Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant