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

Complete prometheus manager wiring/modeling #9550

Merged

Conversation

d-buckner
Copy link
Member

Description

This is to update the prometheus manager to use the new resource API routes and better model the query and response types

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

d-buckner and others added 9 commits March 4, 2025 18:16
Signed-off-by: Daniel Rowe <rowdane@amazon.com>
Signed-off-by: Daniel Rowe <rowdane@amazon.com>
Signed-off-by: Daniel Rowe <rowdane@amazon.com>
Signed-off-by: daniel <51932404+d-buckner@users.noreply.github.com>
Signed-off-by: Daniel Rowe <rowdane@amazon.com>
Co-authored-by: Joshua Li <joshuali925@gmail.com>
Signed-off-by: daniel <51932404+d-buckner@users.noreply.github.com>
Signed-off-by: Daniel Rowe <rowdane@amazon.com>
Signed-off-by: Daniel Rowe <rowdane@amazon.com>
Signed-off-by: Daniel Rowe <rowdane@amazon.com>
@github-actions github-actions bot added valued-contributor Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry labels Mar 14, 2025
d-buckner and others added 2 commits March 14, 2025 14:23
Signed-off-by: daniel <51932404+d-buckner@users.noreply.github.com>
Signed-off-by: Daniel Rowe <rowdane@amazon.com>
async (context, request, response) => {
const { dataConnectionId, dataConnectionType, resourceType, resourceName } = request.params;
if (dataConnectionType === 'prometheus') {
const resources = await new PrometheusManager().getResources(context, request, {
Copy link
Member Author

Choose a reason for hiding this comment

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

@joshuali925 I know you mentioned this could be added to the route handler context. Can you share where that's defined? Happy to use a shared instance in context in follow up.

Copy link
Member

Choose a reason for hiding this comment

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

you can define route context like this

core.http.registerRouteHandlerContext('query_assist', () => ({
logger: this.logger,
configPromise: this.initializerContext.config
.create<ConfigSchema>()
.pipe(first())
.toPromise(),
dataSourceEnabled: !!dataSource,
}));

then it's accessible in the route handler's context.<context-name> variable

It actually must be a shared instance, because the overridden client from other plugins won't work if every time the manager is newly created. might be better if you can make it a singleton

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, that's what I was worried about as well. Will export a singleton, register in this context, and then consume from handler context. I'll send out a commit shortly to address.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated the prometheus manager so it's only vended as a singleton. I didn't get a chance to update the router context, but will include in next change.

Signed-off-by: Daniel Rowe <rowdane@amazon.com>
Copy link

codecov bot commented Mar 14, 2025

Codecov Report

Attention: Patch coverage is 18.75000% with 26 lines in your changes missing coverage. Please review.

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

Files with missing lines Patch % Lines
.../server/connections/managers/prometheus_manager.ts 40.00% 9 Missing ⚠️
...er/connections/clients/promql_connection_client.ts 0.00% 6 Missing ⚠️
...ery_enhancements/server/routes/resources/routes.ts 0.00% 5 Missing ⚠️
...erver/connections/clients/sql_connection_client.ts 0.00% 4 Missing ⚠️
...public/application/view_components/panel/index.tsx 0.00% 1 Missing ⚠️
.../plugins/query_enhancements/server/routes/index.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##             feature/prometheus    #9550   +/-   ##
=====================================================
  Coverage                      ?   61.72%           
=====================================================
  Files                         ?     3822           
  Lines                         ?    91971           
  Branches                      ?    14578           
=====================================================
  Hits                          ?    56771           
  Misses                        ?    31542           
  Partials                      ?     3658           
Flag Coverage Δ
Linux_1 28.97% <0.00%> (?)
Linux_2 56.39% <ø> (?)
Linux_3 39.28% <0.00%> (?)
Linux_4 28.84% <18.75%> (?)
Windows_1 28.98% <0.00%> (?)
Windows_2 56.34% <ø> (?)
Windows_3 39.28% <0.00%> (?)
Windows_4 28.84% <18.75%> (?)

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 <rowdane@amazon.com>
@d-buckner d-buckner force-pushed the prometheus-demo branch 3 times, most recently from 828a4f7 to a2d9aa2 Compare March 14, 2025 22:35
Signed-off-by: Daniel Rowe <rowdane@amazon.com>
@abbyhu2000 abbyhu2000 merged commit 33115c9 into opensearch-project:feature/prometheus Mar 17, 2025
57 of 72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry valued-contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants