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

create and integrate the clientside resource client factory #9574

Merged

Conversation

d-buckner
Copy link
Member

Description

This is to create a clientside API to surface data connection resources. With this PR I've implemented the prometheus resource API which will be used for dynamic query suggestions.

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

Copy link

codecov bot commented Mar 19, 2025

Codecov Report

Attention: Patch coverage is 7.14286% with 39 lines in your changes missing coverage. Please review.

Please upload report for BASE (feature/prometheus@d47ea0a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...pplication/view_components/utils/use_prometheus.ts 0.00% 14 Missing ⚠️
...gins/data/public/resources/base_resource_client.ts 14.28% 6 Missing ⚠️
...ata/public/resources/prometheus_resource_client.ts 20.00% 4 Missing ⚠️
...s/data/public/resources/resource_client_factory.ts 0.00% 4 Missing ⚠️
.../server/connections/managers/prometheus_manager.ts 0.00% 4 Missing ⚠️
...ery_enhancements/server/routes/resources/routes.ts 0.00% 4 Missing ⚠️
...onents/visualizations/vislib/line/to_expression.ts 25.00% 3 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##             feature/prometheus    #9574   +/-   ##
=====================================================
  Coverage                      ?   61.68%           
=====================================================
  Files                         ?     3829           
  Lines                         ?    92052           
  Branches                      ?    14590           
=====================================================
  Hits                          ?    56778           
  Misses                        ?    31617           
  Partials                      ?     3657           
Flag Coverage Δ
Linux_1 28.94% <8.82%> (?)
Linux_2 56.39% <ø> (?)
Linux_3 39.24% <8.82%> (?)
Linux_4 28.81% <7.14%> (?)
Windows_1 28.96% <8.82%> (?)
Windows_2 56.34% <ø> (?)
Windows_3 39.24% <8.82%> (?)
Windows_4 28.81% <7.14%> (?)

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.

Signed-off-by: Daniel Rowe <[email protected]>
@@ -13,10 +13,13 @@ import { OpenSearchSearchHit } from '../../../../doc_views/doc_views_types';
import { IndexPattern } from '../../../../../../../data/public';
import { DiscoverViewServices } from '../../../../../build_services';

type Source = Record<string, number | string>;
Copy link
Member Author

Choose a reason for hiding this comment

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

Apologies for tossing some vega formatting/type improvements in this unrelated PR


type DataConnectionType = 'prometheus';

export class ResourceClientFactory {
Copy link
Member

Choose a reason for hiding this comment

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

ik just feature branch but would this be essentially be accomplished with a route on the server side

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, this hits the data_enhancements resource API route in OSD server which proxies the request to the sql plugin in OS.

const yAxisParam = {
field: columns[i].name,
type: 'quantitative',
scale: { zero: false },
axis: { titleColor: color, title: columns[i].name },
axis: { title: '' },
Copy link
Member

Choose a reason for hiding this comment

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

would this be breaking change? or just for demo purposes

Copy link
Member Author

Choose a reason for hiding this comment

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

This file is only used by the demo


import { HttpSetup } from 'opensearch-dashboards/public';

const BASE_API = 'api/enhancements';
Copy link
Member

Choose a reason for hiding this comment

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

prolly for feature branch purposes but data plugin doesn't depend on the enhancements plugin so might have to invert it

Copy link
Member Author

@d-buckner d-buckner Mar 21, 2025

Choose a reason for hiding this comment

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

Yeah, I felt bad about this tbh. I'd like to move the query enhancement languages (sql, ppl, promql) autocompletion definitions to the query enhancement to avoid having this coupling in the data plugin. Once those are moved over I can define this resource client in data enhancements. Thoughts?

@abbyhu2000 abbyhu2000 merged commit 80bf24e into opensearch-project:feature/prometheus Mar 24, 2025
55 of 72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
seasoned-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.

3 participants