Skip to content

Feature Request: Log Function Arguments for Performance Correlation #1

@thelastbackspace

Description

@thelastbackspace

Description

Add the ability to log and display function arguments alongside performance metrics to help users correlate slow function executions with specific inputs.

Use Case

As highlighted by a user: "For example, say you call a function several times and of of the executions runs several times as long. You'd probably want to present that invocation's arguments directly with the function when logging so the association is more obvious."

This would be particularly valuable when:

  • The same function is called multiple times with different arguments
  • Some invocations are significantly slower than others
  • Developers need to identify which specific inputs cause performance issues

Proposed Implementation

Several possible approaches:

  1. Extend tracking methods:

    • Add an option to track() and createTrackable() to capture function arguments
    • Example: tracePerf.track(myFunction, { captureArgs: true })
  2. Include in execution records:

    • Store argument values in execution records
    • Display them in the execution flow chart
  3. Argument filtering:

    • Allow users to specify which arguments to capture (for privacy or to avoid logging large objects)
    • Example: tracePerf.track(myFunction, { captureArgs: ['id', 'limit'] })
  4. Argument transformation:

    • Provide hooks to transform arguments before logging (e.g., to mask sensitive data)

Considerations

  • Performance impact: Capturing and storing arguments could add overhead
  • Memory usage: Large arguments could significantly increase memory usage
  • Privacy: Need to be careful about logging sensitive information
  • Circular references: Need to handle circular references in arguments

Questions

  • Should we limit the depth of object serialization?
  • Should we have a max size limit for captured arguments?
  • Should we provide a way to filter or transform arguments before logging?

Related Features

  • This could be extended to also capture return values for even more comprehensive debugging

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions