Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds timing metrics to the
scan_asyncreturn value to enable better observability of scanning performance, particularly for tracking CPU time vs I/O time in async scans.Related JIRA: SDS-1904
Changes
Core Changes in dd-sds
New
ScanMetricsstruct - Captures timing information:total_duration: Total time from scan start to completionio_duration: Time spent in I/O operations (async rules making network requests)num_async_rules: Count of async rules executedNew
ScanResultstruct - Wraps scan results with metrics:matches: Vector ofRuleMatchobjects (existing functionality)metrics:ScanMetricswith timing informationUpdated
scan_asyncreturn type:Result<Vec<RuleMatch>, ScannerError>Result<ScanResult, ScannerError>I/O Duration Tracking:
total_duration - io_durationBreaking Changes
scan_async()andscan_async_with_options()now returnScanResultinstead ofVec<RuleMatch>result.matchesinstead of using the result directlyUsage in sds-shared-library
This change enables the sds-shared-library JNI bindings to report a new metric:
scan_cpu_duration_nsFor Synchronous Scans:
For Asynchronous Scans:
(completion_time - start_time) - io_durationThis provides accurate CPU usage metrics for both sync and async scanning patterns, enabling better performance analysis and resource planning.
Testing
ScanResultstructure