feat: Ability to limit number of recorded function calls #171
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.
Fixes #162.
Summary
Added the ability to limit the number of recorded function calls, both total and per function. This approach ensures no orphaned calls are recorded, as the check is made at the start of the function call recording.
The limits can be configured via environment variables (
APPMAP_MAX_RECORDED_CALLS
&APPMAP_MAX_RECORDED_CALLS_PER_FUNCTION
) and configuration file, with default values of 10,000,000 total calls and 100,000 calls per function.Introduced a new test case that generates an AppMap with enforced total and per-function call limits.
Detailed Description
This PR introduces functionality and configuration updates to limit the number of function calls and total calls that can be recorded by the AppMap recorder.
File:
src/Recording.ts
callCountPerFunction
andtotalCallCount
to track the number of calls per function and the total number of calls, respectively.willExceedFunctionCallLimits
was added to determine if the next function call would exceed predefined limits specified in the configuration.functionCall
method:File:
src/config.ts
Config
class:Config
constructor.readConfigFile
function:max_recorded_calls
andmax_recorded_calls_per_function
.File:
src/recorder.ts
record
function to skip recordings that would exceed the specified function call limits.Testing
mapping a script using function call limits
to validate the behavior of the new function call limits feature.callLimits.js
for testing:a
,b
, andc
multiple times to test the limits.