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

[MDS] TSVB Support #6298

Merged
merged 28 commits into from
Apr 16, 2024
Merged

[MDS] TSVB Support #6298

merged 28 commits into from
Apr 16, 2024

Conversation

huyaboo
Copy link
Member

@huyaboo huyaboo commented Mar 29, 2024

Description

Currently, multiple data source (MDS) does not support TSVB visualizations. This PR adds a data source picker component to the TSVB Panel options page so users can specify which datasource to get index patterns from.

Issues Resolved

Partially addresses #6290 and closes #6005

Screenshot

Screen.Recording.2024-03-29.at.10.26.07.AM.mov

Testing the changes

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

Copy link

codecov bot commented Mar 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.40%. Comparing base (e785fd3) to head (710eaf7).
Report is 8 commits behind head on main.

❗ Current head 710eaf7 differs from pull request most recent head fe2b794. Consider uploading reports for the commit fe2b794 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #6298       +/-   ##
===========================================
+ Coverage   49.55%   67.40%   +17.84%     
===========================================
  Files        2670     2639       -31     
  Lines       54290    50276     -4014     
  Branches     8878     9086      +208     
===========================================
+ Hits        26906    33889     +6983     
+ Misses      25720    14236    -11484     
- Partials     1664     2151      +487     
Flag Coverage Δ
Linux_2 55.62% <100.00%> (?)
Linux_3 45.11% <100.00%> (?)
Linux_4 34.96% <100.00%> (?)
Windows_1 ?
Windows_3 ?

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.

Signed-off-by: Huy Nguyen <[email protected]>
@bandinib-amzn
Copy link
Member

Hi @huyaboo I re-run failed Build and test / Build and Verify on Linux (ciGroup1) check but it is still failing. Can you please take a look?

@bandinib-amzn
Copy link
Member

As we are adding a new file src/plugins/vis_type_timeseries/public/application/components/data_source_picker.tsx, let's refrain from using 'ts-expect-error'. Instead, I would encourage addressing type-level errors directly.

@@ -44,21 +44,24 @@ export async function getFields(
requestContext: RequestHandlerContext,
request: OpenSearchDashboardsRequest,
framework: Framework,
indexPattern: string
indexPattern: string,
dataSourceId: string | null
Copy link
Member

Choose a reason for hiding this comment

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

+1 to @BionIT. Instead of null can we make optional parameter? If this is just because of router schema, then I would prefer fixing in router schema instead of workaround to support that. How much is the effort?


export const decideLegacyClient = (
requestContext: RequestHandlerContext,
dataSourceId: string | null
Copy link
Member

Choose a reason for hiding this comment

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

nit: let's use optional parameter instead of null.

Copy link
Member

Choose a reason for hiding this comment

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

We have decideClient in https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/data/server/search/opensearch_search/decide_client.ts.

  1. Can we use same file for decideLegacyClient ?

  2. Can we use request to get dataSourceId similar to decideClient?
    OR
    maybe refactor decideClient to return legacy client base on additional parameter?

  3. I can see in decideClient we are supporting LongNumerals. Is it something we need to take for legacy client? Can you double check?

Copy link
Member

@bandinib-amzn bandinib-amzn Apr 11, 2024

Choose a reason for hiding this comment

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

I found this function

for legacy client.

Looks like we have added this function while adding MDS feature. can we use same one?

Copy link
Member Author

Choose a reason for hiding this comment

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

Wrote a workaround to use decideClient() but this will need a refactor because other plugins may need this function as well. Raised a new issue to address this #6417

bandinib-amzn
bandinib-amzn previously approved these changes Apr 15, 2024
@bandinib-amzn
Copy link
Member

65 successful and 1 skipped checks before rebase.

@bandinib-amzn
Copy link
Member

@huyaboo Thank you for making this change and patiently hearing everyone's comments and feedback and addressing them. Greatly appreciate your contribution!

fullWidth={false}
removePrepend={true}
isClearable={false}
hideLocalCluster={!!getHideLocalCluster().hideLocalCluster}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need to set hideLocalCluster any more. As #6361 merged in, this prop will be decided by the data source management plugin. Whatever get passed in explicitly by the props, will be overwritten anyways.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed all instances of hideLocalCluster

dataSourceManagement: DataSourceManagementPluginSetup | undefined;
}>('DataSourceManagementSetup');

export const [getHideLocalCluster, setHideLocalCluster] = createGetterSetter<{
Copy link
Member

Choose a reason for hiding this comment

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

similar to my previous comment, this also can be removed

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed all instances of hideLocalCluster

savedObjectsClient={getSavedObjectsClient().client}
notifications={getNotifications().toasts}
onSelectedDataSource={handleDataSourceSelectChange}
defaultOption={model.data_source_id ? [{ id: model.data_source_id }] : [{ id: '' }]}
Copy link
Collaborator

Choose a reason for hiding this comment

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

shall we let the selector to decide the default data source if not provided?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah fixed it. I realized there could be a case where the data_source_id can be undefined and the local cluster is disabled.

import { PanelSchema } from 'src/plugins/vis_type_timeseries/common/types';
import { DATA_SOURCE_ID_KEY } from '../../../../common/constants';

export const createDataSourcePickerHandler = (handleChange: (e: PanelSchema) => void) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we have a test for this function?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added test cases.

BionIT
BionIT previously approved these changes Apr 16, 2024
@BionIT BionIT merged commit be0f9d5 into opensearch-project:main Apr 16, 2024
66 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 16, 2024
* Add MDS support to TSVB

Signed-off-by: Huy Nguyen <[email protected]>

* Refactor datasource picker component

Signed-off-by: Huy Nguyen <[email protected]>

* Allow picker to persist state

Signed-off-by: Huy Nguyen <[email protected]>

* Refactored picker component params

Signed-off-by: Huy Nguyen <[email protected]>

* Add unit tests

Signed-off-by: Huy Nguyen <[email protected]>

* Add to CHANGELOG

Signed-off-by: Huy Nguyen <[email protected]>

* Refactor components to use hideLocalCluster

Signed-off-by: Huy Nguyen <[email protected]>

* Remove Picker wrapper

Signed-off-by: Huy Nguyen <[email protected]>

* Update selector component and rename field to index name

Signed-off-by: Huy Nguyen <[email protected]>

* Address comments

Signed-off-by: Huy Nguyen <[email protected]>

* Refactor to use different decideClient

Signed-off-by: Huy Nguyen <[email protected]>

* Add optional arg

Signed-off-by: Huy Nguyen <[email protected]>

* Remove hidelocalcluster as a setting

Signed-off-by: Huy Nguyen <[email protected]>

* Fixed case where local cluster is disabled but the datasource id could be local cluster

Signed-off-by: Huy Nguyen <[email protected]>

* Add test for create data source picker handler

Signed-off-by: Huy Nguyen <[email protected]>

---------

Signed-off-by: Huy Nguyen <[email protected]>
(cherry picked from commit be0f9d5)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
@huyaboo huyaboo deleted the tsvb branch April 18, 2024 00:15
zhongnansu pushed a commit that referenced this pull request Apr 18, 2024
* Add MDS support to TSVB

Signed-off-by: Huy Nguyen <[email protected]>

* Refactor datasource picker component

Signed-off-by: Huy Nguyen <[email protected]>

* Allow picker to persist state

Signed-off-by: Huy Nguyen <[email protected]>

* Refactored picker component params

Signed-off-by: Huy Nguyen <[email protected]>

* Add unit tests

Signed-off-by: Huy Nguyen <[email protected]>

* Add to CHANGELOG

Signed-off-by: Huy Nguyen <[email protected]>

* Refactor components to use hideLocalCluster

Signed-off-by: Huy Nguyen <[email protected]>

* Remove Picker wrapper

Signed-off-by: Huy Nguyen <[email protected]>

* Update selector component and rename field to index name

Signed-off-by: Huy Nguyen <[email protected]>

* Address comments

Signed-off-by: Huy Nguyen <[email protected]>

* Refactor to use different decideClient

Signed-off-by: Huy Nguyen <[email protected]>

* Add optional arg

Signed-off-by: Huy Nguyen <[email protected]>

* Remove hidelocalcluster as a setting

Signed-off-by: Huy Nguyen <[email protected]>

* Fixed case where local cluster is disabled but the datasource id could be local cluster

Signed-off-by: Huy Nguyen <[email protected]>

* Add test for create data source picker handler

Signed-off-by: Huy Nguyen <[email protected]>

---------

Signed-off-by: Huy Nguyen <[email protected]>
(cherry picked from commit be0f9d5)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: ZilongX <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature][MDS] TSVB support with Multi data source
5 participants