# aws-xray-ts-decorator

> Instrument your Promises with AWS X-Ray in Typescript with elegant decorators

Latest version **0.0.9** (published 2019-12-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install aws-xray-ts-decorator
pnpm add aws-xray-ts-decorator
yarn add aws-xray-ts-decorator
bun add aws-xray-ts-decorator
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.9 |
| Published | 2019-12-10 |
| First published | 2019-12-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | RafalWilinski |
| Maintainers | rwilinski |
| Keywords | aws, x-ray, typescript, decorator |

## Links

- npm: https://www.npmjs.com/package/aws-xray-ts-decorator
- Repository: https://github.com/RafalWilinski/aws-xray-ts-decorator
- Homepage: https://github.com/RafalWilinski/aws-xray-ts-decorator#readme
- Issues: https://github.com/RafalWilinski/aws-xray-ts-decorator/issues
- npm.io page: https://npm.io/package/aws-xray-ts-decorator

## Dependencies (1)

- [aws-xray-sdk](https://npm.io/package/aws-xray-sdk.md) 2.5.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.0.9 (latest) — 2019-12-10
- 0.0.8 — 2019-12-09
- 0.0.7 — 2019-12-04
- 0.0.6 — 2019-12-04
- 0.0.5 — 2019-12-04
- 0.0.4 — 2019-12-04
- 0.0.3 — 2019-12-04
- 0.0.2 — 2019-12-04
- 0.0.1 — 2019-12-04

## README

# 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.

<p>
  <a href="https://github.com/RafalWilinski/aws-xray-ts-decorator/blob/master/LICENSE">
    <img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" target="_blank" />
  </a>
  <a href="https://twitter.com/rafalwilinski">
    <img alt="Twitter: rafalwilinski" src="https://img.shields.io/twitter/follow/rafalwilinski.svg?style=social" target="_blank" />
  </a>
</p>


## Install

```sh
yarn add aws-xray-ts-decorator
```

or with NPM

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

## Usage

```java
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](https://github.com/RafalWilinski/aws-xray-ts-decorator/blob/master/examples/index.ts).

## Author

👤 **Rafal Wilinski &lt;raf.wilinski@gmail.com&gt;**

- Twitter: [@rafalwilinski](https://twitter.com/rafalwilinski)
- Github: [@RafalWilinski](https://github.com/RafalWilinski)

## 🤝 Contributing

Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/RafalWilinski/aws-xray-ts-decorator/issues).

## Show your support

Give a ⭐️ if this project helped you!

## 📝 License

Copyright © 2019 [Rafal Wilinski &lt;raf.wilinski@gmail.com&gt;](https://github.com/RafalWilinski).<br />
This project is [MIT](https://github.com/RafalWilinski/aws-xray-ts-decorator/blob/master/LICENSE) licensed.

---
_Source: https://npm.io/package/aws-xray-ts-decorator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
