Skip to content

Commit

Permalink
Merge pull request #1 from serkan-ozal/feature/initial-impl
Browse files Browse the repository at this point in the history
Initial impl
  • Loading branch information
Serkan ÖZAL authored Mar 28, 2022
2 parents 09a8656 + 27d4060 commit a36e3fb
Show file tree
Hide file tree
Showing 8 changed files with 2,759 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: NPM Build

on:
workflow_dispatch:
pull_request:
branches:
- "master"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up NodeJS
uses: actions/setup-node@v2
with:
node-version: "10"
cache: "npm"
- name: NPM Install
run: npm install
- name: NPM Lint
run: npm run lint
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: NPM Publish

on:
workflow_dispatch:
inputs:
version_scale:
description: "Version scale"
required: true
default: "patch"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Configure Git User
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
- name: Use Node.js 10.x
uses: actions/setup-node@v2
with:
node-version: "10.x"
registry-url: https://registry.npmjs.org
- name: NPM Install
run: npm install
- name: NPM Lint
run: npm run lint
- name: NPM Publish
run: npm run release-${{ github.event.inputs.version_scale }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": true,
"singleQuote": true
}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Change Log

All notable changes to this project will be documented in this file.
See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="0.0.1"></a>
# 0.0.1 (2022-03-29)

### Features

* Initial release
112 changes: 111 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,111 @@
# treq
# treq

`treq` is a library to automatically trace requires/imports in your serverless applications
and gives you insights about the most expensive modules in terms of coldstart overhead.

```
START RequestId: 7419d6fb-7dcb-4c53-a689-0d1d352328bc Version: $LATEST
2022-03-28T20:28:47.740Z undefined INFO |-- require('/var/task/index.js') took 630.785845 ms
2022-03-28T20:28:47.740Z undefined INFO ..|-- require('@aws-sdk/client-dynamodb') took 282.050937 ms
2022-03-28T20:28:47.740Z undefined INFO ....|-- require('./DynamoDB') took 262.586494 ms
2022-03-28T20:28:47.740Z undefined INFO ......|-- require('./commands/BatchExecuteStatementCommand') took 54.849051 ms
2022-03-28T20:28:47.740Z undefined INFO ........|-- require('@aws-sdk/smithy-client') took 10.210297 ms
2022-03-28T20:28:47.740Z undefined INFO ........|-- require('../protocols/Aws_json1_0') took 25.35611 ms
2022-03-28T20:28:47.740Z undefined INFO ..........|-- require('uuid') took 11.320902 ms
2022-03-28T20:28:47.740Z undefined INFO ......|-- require('./DynamoDBClient') took 187.273312 ms
2022-03-28T20:28:47.740Z undefined INFO ........|-- require('@aws-sdk/config-resolver') took 12.8885 ms
2022-03-28T20:28:47.740Z undefined INFO ........|-- require('@aws-sdk/middleware-endpoint-discovery') took 12.118507 ms
2022-03-28T20:28:47.740Z undefined INFO ........|-- require('@aws-sdk/middleware-retry') took 13.529461 ms
2022-03-28T20:28:47.740Z undefined INFO ........|-- require('@aws-sdk/middleware-signing') took 17.70112 ms
2022-03-28T20:28:47.740Z undefined INFO ..........|-- require('./configurations') took 14.718523 ms
2022-03-28T20:28:47.740Z undefined INFO ............|-- require('@aws-sdk/signature-v4') took 11.853916 ms
2022-03-28T20:28:47.740Z undefined INFO ..............|-- require('./SignatureV4') took 10.149309 ms
2022-03-28T20:28:47.740Z undefined INFO ........|-- require('./runtimeConfig') took 123.567573 ms
2022-03-28T20:28:47.740Z undefined INFO ..........|-- require('@aws-sdk/client-sts') took 120.895623 ms
2022-03-28T20:28:47.740Z undefined INFO ............|-- require('./STS') took 116.251668 ms
2022-03-28T20:28:47.741Z undefined INFO ..............|-- require('./commands/AssumeRoleCommand') took 22.53696 ms
2022-03-28T20:28:47.741Z undefined INFO ................|-- require('../protocols/Aws_query') took 20.750245 ms
2022-03-28T20:28:47.741Z undefined INFO ..................|-- require('entities') took 14.045998 ms
2022-03-28T20:28:47.741Z undefined INFO ..............|-- require('./STSClient') took 89.669653 ms
2022-03-28T20:28:47.741Z undefined INFO ................|-- require('./runtimeConfig') took 87.875766 ms
2022-03-28T20:28:47.741Z undefined INFO ..................|-- require('@aws-sdk/credential-provider-node') took 84.898272 ms
2022-03-28T20:28:47.741Z undefined INFO ....................|-- require('./defaultProvider') took 83.672074 ms
2022-03-28T20:28:47.741Z undefined INFO ......................|-- require('@aws-sdk/credential-provider-ini') took 76.227651 ms
2022-03-28T20:28:47.741Z undefined INFO ........................|-- require('./fromIni') took 75.707995 ms
2022-03-28T20:28:47.741Z undefined INFO ..........................|-- require('./resolveProfileData') took 70.243135 ms
2022-03-28T20:28:47.741Z undefined INFO ............................|-- require('./resolveAssumeRoleCredentials') took 12.684291 ms
2022-03-28T20:28:47.741Z undefined INFO ..............................|-- require('./resolveCredentialSource') took 12.257091 ms
2022-03-28T20:28:47.741Z undefined INFO ................................|-- require('@aws-sdk/credential-provider-imds') took 11.887286 ms
2022-03-28T20:28:47.741Z undefined INFO ............................|-- require('./resolveSsoCredentials') took 54.422646 ms
2022-03-28T20:28:47.741Z undefined INFO ..............................|-- require('@aws-sdk/credential-provider-sso') took 53.719582 ms
2022-03-28T20:28:47.741Z undefined INFO ................................|-- require('./fromSSO') took 52.288542 ms
2022-03-28T20:28:47.741Z undefined INFO ..................................|-- require('./resolveSSOCredentials') took 50.657345 ms
2022-03-28T20:28:47.741Z undefined INFO ....................................|-- require('@aws-sdk/client-sso') took 50.277645 ms
2022-03-28T20:28:47.741Z undefined INFO ......................................|-- require('./SSO') took 43.303073 ms
2022-03-28T20:28:47.741Z undefined INFO ........................................|-- require('./SSOClient') took 35.038433 ms
2022-03-28T20:28:47.741Z undefined INFO ..........................................|-- require('./runtimeConfig') took 34.253186 ms
2022-03-28T20:28:47.741Z undefined INFO ............................................|-- require('@aws-sdk/node-http-handler') took 14.914675 ms
2022-03-28T20:28:47.741Z undefined INFO ..|-- require('@aws-sdk/client-s3') took 138.489329 ms
2022-03-28T20:28:47.741Z undefined INFO ....|-- require('./S3') took 123.365087 ms
2022-03-28T20:28:47.741Z undefined INFO ......|-- require('./commands/AbortMultipartUploadCommand') took 44.071934 ms
2022-03-28T20:28:47.741Z undefined INFO ........|-- require('../models/models_0') took 10.537944 ms
2022-03-28T20:28:47.741Z undefined INFO ........|-- require('../protocols/Aws_restXml') took 27.656476 ms
2022-03-28T20:28:47.741Z undefined INFO ......|-- require('./commands/DeleteObjectsCommand') took 15.740644 ms
2022-03-28T20:28:47.741Z undefined INFO ........|-- require('@aws-sdk/middleware-flexible-checksums') took 15.35287 ms
2022-03-28T20:28:47.741Z undefined INFO ..........|-- require('./flexibleChecksumsMiddleware') took 13.63264 ms
2022-03-28T20:28:47.741Z undefined INFO ............|-- require('./selectChecksumAlgorithmFunction') took 10.345904 ms
2022-03-28T20:28:47.741Z undefined INFO ......|-- require('./S3Client') took 18.328771 ms
2022-03-28T20:28:47.741Z undefined INFO ........|-- require('./runtimeConfig') took 12.748143 ms
2022-03-28T20:28:47.741Z undefined INFO ..|-- require('@aws-sdk/client-sqs') took 24.766564 ms
2022-03-28T20:28:47.741Z undefined INFO ....|-- require('./SQS') took 19.305477 ms
2022-03-28T20:28:47.741Z undefined INFO ..|-- require('@aws-sdk/client-ssm') took 185.064697 ms
2022-03-28T20:28:47.741Z undefined INFO ....|-- require('./SSM') took 135.679327 ms
2022-03-28T20:28:47.741Z undefined INFO ......|-- require('./commands/AddTagsToResourceCommand') took 62.956037 ms
2022-03-28T20:28:47.741Z undefined INFO ........|-- require('../models/models_0') took 17.333932 ms
2022-03-28T20:28:47.741Z undefined INFO ........|-- require('../protocols/Aws_json1_1') took 44.988784 ms
2022-03-28T20:28:47.741Z undefined INFO ..........|-- require('../models/models_1') took 11.553608 ms
2022-03-28T20:28:47.742Z undefined INFO ....|-- require('./commands') took 19.612849 ms
2022-03-28T20:28:47.742Z undefined INFO ......|-- require('./ListDocumentsCommand') took 13.616722 ms
2022-03-28T20:28:47.742Z undefined INFO ....|-- require('./pagination') took 19.10802 ms
END RequestId: 7419d6fb-7dcb-4c53-a689-0d1d352328bc
REPORT RequestId: 7419d6fb-7dcb-4c53-a689-0d1d352328bc Duration: 2.86 ms Billed Duration: 3 ms Memory Size: 2048 MB Max Memory Used: 95 MB Init Duration: 798.59 ms
XRAY TraceId: 1-62421a7e-0920949e7de8b8455b00f7c4 SegmentId: 05b5512a6f0e008a Sampled: true
```

## Installation

### As NPM package

To install the middleware, you can use NPM:

```
npm install --save treq
```

### As AWS Lambda Layer

Coming soon ...


## Usage

* Configure `treq` to be required/bootstrapped automatically at startup by setting `NODE_OPTIONS` environment variable:
```
NODE_OPTIONS=-r treq
```

* **Optionally**, you can configure require duration threshold (in milliseconds) for tracing.
Requires/imports take lower than the threshold are ignored from tracing.
By default, the threshold is `10` milliseconds and it can be configured by `TREQ_DURATION_THRESHOLD` environment variable.


## Contributing

Everyone is very welcome to contribute to this repository.
Feel free to [raise issues](https://github.com/serkan-ozal/treq/issues)
or to [submit Pull Requests](https://github.com/serkan-ozal/treq/pulls).


## License

Licensed under [MIT License](LICENSE).
Loading

0 comments on commit a36e3fb

Please sign in to comment.