Skip to content
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

Refactor getModulePath and fix decorator errors #87

Merged
merged 6 commits into from
Jul 13, 2023

Conversation

keturiosakys
Copy link
Member

@keturiosakys keturiosakys commented Jul 12, 2023

This PR fixes several issues:

  • Decorators were throwing out this values for the methods they were wrapping. Core wrapper autometrics now uses Function.apply to preserve the this context.
  • Using Function.apply also doesn't require copying all of the parameters using the spread operator which should reduce memory footprint for functions that have large parameter objects they're passing around.
  • Refactors getModulePath utility: it now constructs a custom stack trace with only the necessary information to get the filename without string parsing.

It also adds a test to ensure decorators work properly.

Copy link
Member

@flenter flenter left a comment

Choose a reason for hiding this comment

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

🎉 nice

packages/lib/src/utils.ts Outdated Show resolved Hide resolved
@keturiosakys keturiosakys merged commit 2eecb01 into main Jul 13, 2023
2 checks passed
@keturiosakys keturiosakys deleted the fix-decorator-errors branch July 13, 2023 08:58
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.

2 participants