0.0.9 ā€¢ Published 4 years ago

aws-xray-ts-decorator v0.0.9

Weekly downloads
194
License
ISC
Repository
github
Last release
4 years ago

AWS X-Ray Typescript Decorator

Tired of using AWSXRay.captureAsyncFunc and/or AWSXRay.capturePromise polluting the body of your methods? Instrument your class async methods and Promises with this simple yet elegant decorator.

Install

yarn add aws-xray-ts-decorator

or with NPM

npm install aws-xray-ts-decorator --save

Usage

class MyTestClass {
  // All of these arguments are optional
  @XRayInstrumented({
    segmentName: "customSegmentName", // by default it's name of called function
    metadata: { // Add custom metadata as StringMap
      memberId: "1"
    },
    annotations: { // Add custom annotations as StringMap
      context: "this is important!"
    },
    forceCreateSegment: true, // Creates new AWSXRay.Segment if such is not created yet
    addParamsMetadata: true // Adds function parameters as metadata of subsegment
  })
  someAsyncMethod(input: number): Promise<any> {
    ...
  }
}

This snippet will start a subsegment customSegmentName before someAsyncMethod gets invoked and close it as soon as it resolves.

For more details, see example.

Author

šŸ‘¤ Rafal Wilinski <raf.wilinski@gmail.com>

šŸ¤ Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

Show your support

Give a ā­ļø if this project helped you!

šŸ“ License

Copyright Ā© 2019 Rafal Wilinski <raf.wilinski@gmail.com>. This project is MIT licensed.

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago