Skip to content

Bug: @tracer.captureMethod() is not bound to the decorated class #1028

Closed
@ratscrew

Description

@ratscrew

Bug description

The @tracer.captureMethod() decorator is bound to the decorator not the class its decorating.

export class Lambda implements LambdaInterface {
   @tracer.captureMethod()
   myMethod(){

      //other method is undefined as "this" is no longer the Lambda class
      this.otherMethod()
   }

   otherMethod(){}
}

Expected Behavior

this.otherMethod() should call the this.otherMethod() in the same class

Current Behavior

this.otherMethod() is undefined

Possible Solution

see #1026
the @tracer.captureLambdaHandler() decorator already does this

Steps to Reproduce

  1. create a class with two or methods in it
  2. add the decorator @tracer.captureMethod() to one or more of the function
  3. call another method or prop in the decorated method
  4. the method or prop will be undefined

Environment

  • Powertools version used: 1.0.2
  • Packaging format (Layers, npm):
  • AWS Lambda function runtime:
  • Debugging logs:

Related issues, RFCs

#1026

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcompletedThis item is complete and has been merged/shippedtracerThis item relates to the Tracer Utility

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions