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

Expose patched function name in aspects framework #46

Closed
seabaylea opened this issue Nov 9, 2015 · 3 comments
Closed

Expose patched function name in aspects framework #46

seabaylea opened this issue Nov 9, 2015 · 3 comments
Assignees
Milestone

Comments

@seabaylea
Copy link
Member

The aspects patching framework allows you to specify an array of function names to patch. eg. for aspect.around:

var functionNames = [];
aspect.around(target.prototype, functionNames,
    function(target, args) {},
    function(target. args, rc) {}
);

This means you can patch multiple functions in the same way with the same code, but there's no way of knowing the name of the actual function that is running. This is useful if you want to add it to the raised monitoring event.

Passing the function name through to the function callbacks as an additional (last) parameter provides access to the name of the function without breaking existing code, eg:

var functionNames = [];
aspect.around(target.prototype, functionNames,
    function(target, args, funcName) {},
    function(target. args, rc, funcName) {}
);
@seabaylea seabaylea self-assigned this Nov 9, 2015
@seabaylea seabaylea added this to the 1.0.4 milestone Nov 9, 2015
@seabaylea
Copy link
Member Author

@tunniclm Any view on the addition of the patched function name as a new last parameter passed to the supplied before and after callbacks?

Note that this only applies to aspect.before(), aspect.after() and aspect.around(). The aspect.aroundCallback() call doesn't take a function name - you should already have that from a previous call to aspect.before() or aspect.around().

@tunniclm
Copy link
Contributor

@seabaylea This approach seems reasonable to me, adding as the last argument should prevent breakage of existing usage code.

@seabaylea
Copy link
Member Author

Closing with PR #49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants