Skip to content

Conversation

kylelai1
Copy link
Collaborator

@kylelai1 kylelai1 commented Sep 23, 2025

Proposed changes

  • Adds integration tests for the performance advisor tool.
  • Gets process IDs from the standard connection string, which contains the hostnames.
  • Note: Mocks out the API responses for the performance advisor for 1 test because we can't guarantee that there will be performance advisor suggestions in our testing.
  • Also limits the max number of returned slow query logs from the tool, and changed wording to indicate that we are returning a sample of slow query logs. This is due to manually testing, and finding that the LLM can not interpret too large of a range of slow queries if the number increases towards 20,000 (which is the default).

Checklist

@kylelai1 kylelai1 changed the title feat: Atlas get performance advisor integration tests [WIP] feat: Atlas get performance advisor integration tests Sep 23, 2025
@kylelai1 kylelai1 marked this pull request as ready for review September 24, 2025 15:26
@kylelai1 kylelai1 requested a review from a team as a code owner September 24, 2025 15:26
@kylelai1 kylelai1 changed the title [WIP] feat: Atlas get performance advisor integration tests feat: Atlas get performance advisor integration tests Sep 24, 2025
@kylelai1 kylelai1 removed the request for review from kmruiz September 24, 2025 15:50
Copy link
Collaborator

@kmruiz kmruiz left a comment

Choose a reason for hiding this comment

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

Great job so far!

I know some suggestions apply to old code that you inherited, so sorry in advance this slipped over our other reviews. If you need help with any of these specific changes feel free to ping us, some of them might be a bit more advanced than usual.

@kylelai1 kylelai1 requested review from blva and kmruiz September 26, 2025 14:21
};
}

if (statusCode === 402) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we getting 402 when a customer tries to access PA on a free/shared tier cluster?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, we're getting a 402 for the integration tests when they're run with an org that has no payment set up, since an M10 is created for the new integration test. PA on a free/shared tier cluster will be a 200.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So are users likely to ever get the 402 response?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think one thing to add here is probably elicitation is needed for all these tools since they can add cost to the user, here's some context bcbf889

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

users are not likely to get the 402 response. This is purely for the integration tests.

: "No schema suggestions found.",
`## Suggested Indexes\n${
hasSuggestedIndexes
? `Note: The "Weight" field is measured in bytes, and represents the estimated number of bytes saved in disk reads per executed read query that would be saved by implementing an index suggestion. Please convert this to MB or GB for easier readability.\n${JSON.stringify(suggestedIndexesResult.suggestedIndexes)}`
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is included from product feedback to make it apparent to the LLM that the "weight" field is in bytes, and gives the definition to relay to the LLM

try {
const [suggestedIndexesResult, dropIndexSuggestionsResult, slowQueryLogsResult, schemaSuggestionsResult] =
await Promise.all([
await Promise.allSettled([
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed this to Promise.allSettled. Made sure it was type safe below as well when using the allSettled.

@kylelai1 kylelai1 requested review from nirinchev and kmruiz October 1, 2025 15:28
@kylelai1
Copy link
Collaborator Author

kylelai1 commented Oct 1, 2025

I've just added some changes after demo-ing and testing with the product team, so I've re-requested review for the additional changes/enhancements as well.

: "No schema suggestions found.",
`## Suggested Indexes\n${
hasSuggestedIndexes
? `Note: The "Weight" field is measured in bytes, and represents the estimated number of bytes saved in disk reads per executed read query that would be saved by implementing an index suggestion. Please convert this to MB or GB for easier readability.\n${JSON.stringify(suggestedIndexesResult.value?.suggestedIndexes)}`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably this calculation is something that we can do ourselves? It's trivial and we avoid the situation where different LLMs do the calculation differently or wrong.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can do the calculation ourselves, but that would mean we'd need to determine whether we want to convert to KB or GB, which I think would depend on the number itself. If the "weight" changes, and is sometimes KB and sometimes GB, then we need to add the units to the "weight" field, which is currently typed as a number. If we want, we can just leave it as bytes, and not have any conversion being done.

@kylelai1 kylelai1 requested a review from kmruiz October 2, 2025 15:05
@kylelai1 kylelai1 merged commit 352831e into atlas-list-performance-advisor-tool Oct 2, 2025
8 of 10 checks passed
@kylelai1 kylelai1 deleted the atlas-get-performance-advisor-integration-tests branch October 2, 2025 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants