You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to capture all the retries of a method that uses a decorator to implement async retries. #1084 (comment) However, when the tracer tries to determine the segment name, it doesn't find the name of the original method.
Expected Behavior
I expected the segment name to use the original method name.
Current Behavior
It uses the name of the other decorator's anonymous function instead of the original method's function. An anonymous function's name is empty, so the segment name is empty.
consttracer=newTracer();functionpassThrough(){// A decorator that calls the original method.return(_target: unknown,_propertyKey: string,descriptor: PropertyDescriptor)=>{constoriginalMethod=descriptor.value!;descriptor.value=function(...args: unknown[]){returnoriginalMethod.apply(this,[...args]);};};}classMyClass{
@tracer.captureMethod()
@passThrough()asyncdoSomething(): Promise<string>{return'foo';}}constmyClass=newMyClass();awaitmyClass.doSomething();// Segment name will be "### "
Environment
Powertools version used: 1.2.1
Packaging format (Layers, npm): npm
AWS Lambda function runtime: node 16
Debugging logs:
Related issues, RFCs
None
The text was updated successfully, but these errors were encountered:
dreamorosi
added
tracer
This item relates to the Tracer Utility
and removed
triage
This item has not been triaged by a maintainer, please wait
labels
Sep 27, 2022
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Bug description
I wanted to capture all the retries of a method that uses a decorator to implement async retries. #1084 (comment) However, when the tracer tries to determine the segment name, it doesn't find the name of the original method.
Expected Behavior
I expected the segment name to use the original method name.
Current Behavior
It uses the name of the other decorator's anonymous function instead of the original method's function. An anonymous function's name is empty, so the segment name is empty.
Possible Solution
Use
String(_propertyKey)
instead oforiginalMethod.name
here: https://github.com/awslabs/aws-lambda-powertools-typescript/blob/06fbaae4db3825557aa84d40372a53422e42840d/packages/tracer/src/Tracer.ts#L437Steps to Reproduce
Environment
Related issues, RFCs
None
The text was updated successfully, but these errors were encountered: