powertools-lambda-typescript
powertools-lambda-typescript copied to clipboard
feat(tracer): specify subsegment name when capturing class method
Description of your changes
Community member @misterjoshua suggested a feature in #1084 to allow customers to set a custom name for the subsegment generated by the Tracer.captureMethod method.
At the moment Tracer automatically sets the subsegment name to the same value of the name of the method. This is a sensible choice but in some cases, when using non descriptive method names, customers might want to set their own names.
This PR adds an optional parameter to the options for captureMethod so that the custom name can be set. The PR also splits the type used for the options in captureMethod and captureLambdaHandler so that the new parameter is valid only for the former (the latter will always be called ## index.${HANDLER NAME} for now).
The PR also adds unit test cases as well as e2e test cases and does some light housekeeping around the e2e tests and docstrings related to this feature.
How to verify this change
Check out newly added unit test cases and new e2e test cases (results here).
Related issues, RFCs
Issue number: #1084
PR status
Is this ready for review?: YES
Is it a breaking change?: NO
Checklist
- [x] My changes meet the tenets criteria
- [x] I have performed a self-review of my own code
- [x] I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [ ] I have made corresponding changes to the examples
- [x] My changes generate no new warnings
- [x] The code coverage hasn't decreased
- [x] I have added tests that prove my change is effective and works
- [x] New and existing unit tests pass locally and in Github Actions
- [x] Any dependent changes have been merged and published in downstream module
- [x] The PR title follows the conventional commit semantics
Breaking change checklist
N/A
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Just a few small nitpicks in the docs. Otherwise, this looks good to me.
Thank you for taking a look at this and good spotting the mistakes in the docstrings, I have committed your suggestions :)