-
Notifications
You must be signed in to change notification settings - Fork 261
feature: add dynamic api error calculation #3154
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
base: feature/cyborg-release
Are you sure you want to change the base?
feature: add dynamic api error calculation #3154
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds dynamic API error calculation functionality to track specific error types (Cloudflare errors, 429 rate limits, and 5xx server errors) in testing results. The implementation adds error categorization and counting capabilities to the testing framework.
- Introduces a new
apiErrors
field to store error counts by type - Implements regex-based error detection for Cloudflare, 429, and 5xx errors
- Adds database indexing support for the new error tracking field
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
File | Description |
---|---|
TestingRunResult.java | Adds apiErrors field with getter/setter methods |
TestingRunResultDao.java | Creates database index for the new apiErrors field |
DbAction.java | Implements error detection logic using regex patterns and populates apiErrors map |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
apps/database-abstractor/src/main/java/com/akto/action/DbAction.java
Outdated
Show resolved
Hide resolved
apps/database-abstractor/src/main/java/com/akto/action/DbAction.java
Outdated
Show resolved
Hide resolved
apps/database-abstractor/src/main/java/com/akto/action/DbAction.java
Outdated
Show resolved
Hide resolved
apps/database-abstractor/src/main/java/com/akto/action/DbAction.java
Outdated
Show resolved
Hide resolved
apps/database-abstractor/src/main/java/com/akto/action/DbAction.java
Outdated
Show resolved
Hide resolved
apps/database-abstractor/src/main/java/com/akto/action/DbAction.java
Outdated
Show resolved
Hide resolved
apps/database-abstractor/src/main/java/com/akto/action/DbAction.java
Outdated
Show resolved
Hide resolved
apps/database-abstractor/src/main/java/com/akto/action/DbAction.java
Outdated
Show resolved
Hide resolved
testingRunResult.setTestRunResultSummaryId(id); | ||
} | ||
|
||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need the API to be fast.
make a scheduleExecutor with fixed threads [ say 10 ].
let the actual update happen [ without apiErrors ].
submit a job to executor which runs the regex.
if apiErrors are > 0 , issue an update, else skip updates altogether.
this will help in better find query performance, because we would be able to use the $exists paradigm.
final TestingRunResult trrForAsync = testingRunResult; | ||
final int capturedAccountId = (Context.accountId.get() != null) ? Context.accountId.get() : 0; | ||
apiErrorsService.submit(() -> { | ||
if (capturedAccountId != 0) { | ||
Context.accountId.set(capturedAccountId); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't run the thread altogether, if accountId is 0
if (cloudflareErrors + rateLimit429 + server5xx > 0) { | ||
try { | ||
// set apiErrors field on the existing document | ||
org.bson.conversions.Bson filter = Filters.eq("_id", trrForAsync.getId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
always use string literals, for all string fields.
i.e. instead of _id
, use Constants._ID
and define it somewhere [ I think it's already defined somewhere ].
…n logic