Releases: aws-powertools/powertools-lambda-typescript
v1.5.0
Summary
This release includes some bug fixes and quality of life improvements on the Logger utility as well as improvements on the bundle size of our public Lambda Layers.
Logger
Prior to this release, when creating child loggers, Logger was affected by a bug that caused some of the settings to not be properly reflected in its children. This release corrects the issue by reworking the logic used to create child loggers.
Additionally, thanks to @shdq's contribution, those who use jest
and Logger can now leverage the --silent
flag to silence logs emitted by Logger in their unit tests.
Lambda Layer
Thanks to a report from @Muthuveerappanv, we were able to shave ~3MB from the deployment package of our public Lambda Layers by removing @types
from the node_modules
folder. This will give you back some valuable space when using the layers.
Upcoming Utilities
The release also includes unreleased work on two new upcoming utilities: Idempotency and Parameters. On both fronts we have finished laying the foundations for the utilities and we will now start gradually adding features. Stay tuned for more updates on this topic in the next releases.
Governance
As part of this release we have also published a new and improved GitHub Project that you can use to stay updated with the team's progress as well as finding contributing opportunities. We also have added a new "Roadmap" section to the docs, use this page to learn about the team's priorities for the upcoming months.
Acknowledgements
A big thank you to @shdq who has been a big part of this release, to @ConnorKirk for his first contribution to the project, and to @jeffrey-baker-vg and the rest of the team for the hard work on Idempotency.
Changes
- tests(idempotency): add utility to workspace unit tests and CI (#1160) by @dreamorosi
- feat(idempotency): Add persistence layer and DynamoDB implementation (#1110) by @jeffrey-baker-vg
- feat(logger): pretty printing logs in local and non-prod environment (#1141) by @shdq
🌟New features and non-breaking changes
- feat(parameters): added
BaseProvider
class (#1168) by @dreamorosi
🌟 Minor Changes
📜 Documentation updates
- docs: add maintainers and public roadmap (#1167) by @dreamorosi
- docs: update environment variable tables for utilities (#1153) by @ConnorKirk
- docs: clarify nodejs16 requirement + fix command (#1152) by @dreamorosi
🐛 Bug and hot fixes
🔧 Maintenance
- chore: add install step in docs workflow (#1183) by @dreamorosi
- chore(layer): reduce size by 3 by removing @types packages (#1181) by @flochaz
- chore(internal): remove unused test folder from project's root (#1162) by @dreamorosi
- chore: add codespaces badge (#1155) by @dreamorosi
- chore(docs): update layer version to 5 (#1150) by @dreamorosi
This release was made possible by the following contributors:
@ConnorKirk, @dreamorosi, @flochaz, @jeffrey-baker-vg and @shdq
v1.4.1
Summary
This patch release fixes a bug in Metrics as well as introducing some improvements in the documentation and jsdoc examples that accompany all public APIs of the utilities.
The bug in Metrics caused the service name to be cleared from the default dimensions after metrics were published or after the first function invocation when using the middleware or decorator. The service name is automatically added to metrics emitted by the utility and should always be present as dimension.
Finally, thank you to @niko-achilles for helping raise the bar on the documentation. Below an example of the jsdoc string rendered in VS Code:
Changes
📜 Documentation updates
- docs(all): update & revise docstring examples (#1144) by @dreamorosi
🐛 Bug and hot fixes
- fix(metrics): store service name in defaultDimensions to avoid clearing it (#1146) by @dreamorosi
🔧 Maintenance
- chore(docs): update layer version to 5 (#1150) by @dreamorosi
- chore(internal): update workflow reference (#1148) by @dreamorosi
- chore(all): removed unused npm scripts + moved linting in PR checks (#1125) by @dreamorosi
- chore(docs): update docs with newer layer version (#1137) by @dreamorosi
This release was made possible by the following contributors:
@dreamorosi and @github-actions[bot]
v1.4.0
Summary
This release introduces a new feature in Tracer that allows customers to access the AWS X-Ray Root Trace ID. The release also includes a bug fix for Metrics where an issue prevented dimensions and metadata to be cleared on metrics publish. Finally, it also includes some updates to the docs, one of which introduces an example of how to use the Powertools layer with Pulumi.
Tracer
The Tracer utility now has a new public method called getRootXrayTraceId()
(docs). With this method you can access the root trace id and use it in your responses or downstream processing as correlation id.
Thank you @misterjoshua for suggesting the feature and helping review the PR.
Metrics
Prior to this release a bug in the Metrics utility prevented metadata and dimensions of metrics to leak between function executions. This was due to a faulty logic that didn't clear properly the two objects when metrics were published. Thanks to @shdq the bug has been fixed and unit tests around the behavior were added. Congrats @shdq for your first PR merged 🎉
Docs
Finally, thanks to @pierskarsenbarg's first contribution to this repo (💯) , the documentation now has an example of how to use the Powertools layer with Pulumi!
Changes
🌟New features and non-breaking changes
- feat(all): moved EnvService to commons + exposed getXrayTraceId in tracer (#1123) by @dreamorosi
📜 Documentation updates
- Added Pulumi code to deploy lambda with powertools (#1135) by @pierskarsenbarg
- docs: main page updates around support (#1133) by @dreamorosi
- docs(layers): fix format issues (#1122) by @dreamorosi
- docs: update layer version in docs (#1120) by @dreamorosi
🐛 Bug and hot fixes
🔧 Maintenance
- chore(governance): update issue templates to use forms (#1128) by @dreamorosi
This release was made possible by the following contributors:
v1.3.0
Summary
This release adds public AWS Lambda Layers, a new feature for Tracer, and bug fixes on all utilities.
AWS Lambda Layers
You can now use AWS Lambda Powertools for TypeScript by adding just a few lines to your configs and using our public AWS Lambda Layers.
Lambda Layer is a .zip file archive that can contain additional code, pre-packaged dependencies, data, or configuration files. Layers promote code sharing and separation of responsibilities so that you can iterate faster on writing business logic.
You can include Lambda Powertools Lambda Layer using AWS Lambda Console, or your preferred deployment framework. Lambda Layers also allow us to understand who uses this library in a non-intrusive way. This helps us justify and gain future investments for other Lambda Powertools languages.
When using AWS SAM or Serverless Framework:
With CDK:
New Features
Tracer
When using the captureMethod
decorator on your class method you can now specify a custom name for the subsegment that Tracer generates for you.
You can do so by passing a newly added subSegmentName
parameter to the decorator. This is useful for those cases in which the decorated method has an long or non-meaningful name but also in cases in which you want to nest method calls and represent this nesting in the segment names by using different levels of ###
/####
.
Bug Fixes
Metrics
The Metrics utility has two parameters captureColdStartMetric
and throwOnEmptyMetrics
that allow respectively to create a cold start metric for those invocations that had an initialization phase, and to throw an error before flushing metrics to ensure that at least one metric is emitted.
Prior to this release there was a bug that caused the parameters to be misinterpreted when passed to the logMetrics middleware. This release ensures that the parameters are parsed correctly and adds additional tests to verify and maintain the behavior.
Logger
The indectLambdaContext
decorator allows you to enrich your structured logs with key Lambda context information. The appendKeys
method instead allows you to append additional keys and values to logs while within the function handler's scope.
Prior to this release there was a bug that caused some of these additional keys and values to be cleared too soon due to the decorator not awaiting for the decorated method to return. This release fixes the issue and adds tests to prevent future regressions.
Tracer
The captureMethod
decorator allows you to trace Class methods and create segments for its operations.
Prior to this release, when using captureMethod
with certain 3rd party decorators the name of the decorated method was not detected correctly causing the segment name and its annotation to be mislabeled. This release changes the logic around name detection to ensure names are properly annotated.
Changes
- Chore(tracer): unit tests to verify decorators await decorated class methods (#1108) by @dreamorosi
- Fix: standardized and consistent linting strategy across Lerna targets (#1105) by @saragerion
🌟New features and non-breaking changes
- feat(tracer): specify subsegment name when capturing class method (#1092) by @dreamorosi
- feat: publish lib as Lambda Layer (#1095) by @flochaz
- feat(idempotency): create initial class structure for function idempotency (#1086) by @jeffrey-baker-vg
📜 Documentation updates
- docs: update layer version in docs (#1120) by @dreamorosi
- doc(layer): bump layer version to 2 to match the one built for latest version (1.2.1) (#1113) by @flochaz
🐛 Bug and hot fixes
- fix(all): update version command to use lint-fix (#1119) by @dreamorosi
- fix(tracer): captureMethod detects proper method name when used with external decorators (#1109) by @dreamorosi
- fix(metrics): captureColdStartMetric and throwOnEmptyMetrics when set to false was interpreted as true (#1090) by @flochaz
- fix(logger): wait for decorated method return before clearing out state (#1087) by @dreamorosi
- fix(build): remove leftover code in action that labels issues on merge (#1078) by @dreamorosi
🔧 Maintenance
- fix(all): update version command to use lint-fix (#1119) by @dreamorosi
- chore(layer): fix bundling and e2e tests by manually setting hash of asset (#1116) by @flochaz
- chore(build): fix ts-node version for layer-publisher (#1112) by @flochaz
- build(deps): bump vm2 from 3.9.9 to 3.9.11 (#1094) by @dependabot
- improv(build): allow to specify PR number when running e2e tests (#1079) by @dreamorosi
- fix(build): remove leftover code in action that labels issues on merge (#1078) by @dreamorosi
- chore(build): update make-release.yml to remove redundant publish step (#1075) by @dreamorosi
This release was made possible by the following contributors:
v1.2.1
Summary
We are thrilled to share that we have a new home on Discord!
We hope that this new chapter will allow us to connect and learn from each other, as well as shape together the feature of Powertools.
Join us here: https://discord.gg/B8zZKbbyET
Thanks @sthuber90 for opening the PR to update our docs and adding the new link.
Changes
📜 Documentation updates
- docs(home): add discord invitation link (#1074) by @sthuber90
This release was made possible by the following contributors:
v1.2.0
Summary
In this patch release we are updating the Metrics utility to support 3x more dimensions (up to 30) per metric, as well as adding a new way to suppress response capture to Tracer.
Metrics
A few weeks ago Amazon CloudWatch increased metric throughput. This release takes advantage of the new metric dimension to increase our validation limit to 30.
Thank you @sthuber90 for taking this feature and congrats for your first PR in this repo 🎉
Tracer
By default, when using the Tracer as a middleware or as a decorator, the utility captures the response returned by a method or Lambda handler and adds it as metadata on the current segment. This allows you to gain insights about the execution and the results in the context of your traces.
In some instances, for example if the response is too big (> 64 kB), or if it contains sensitive informations, you might want to disable this behavior.
With this release you can use the captureResponse: false
option in both tracer.captureLambdaHandler()
and tracer.captureMethod() decorators
, or use the same option in the Middy captureLambdaHander
middleware to instruct Tracer not to serialize function responses as metadata.
Once again, thank you @misterjoshua for proposing and implementing this behavior 🙌
🌟New features and non-breaking changes
- feat(metrics): increase maximum dimensions to 29 (#1072) by @sthuber90
- feat(tracer): allow disabling result capture for decorators and middleware (#1065) by @misterjoshua
🐛 Bug and hot fixes
- fix(docs): docs published with incorrect version number + api docs missing after release (#1066) by @dreamorosi
This release was made possible by the following contributors:
v1.1.1
Summary
This patch release addresses an issue with Lambda handlers written as a class and that uses the Powertools utilities to decorate some of its methods. The defect prevented class members from accessing the class instance and calling other methods or reading attributes.
Thanks to @misterjoshua, we have modified the implementation of the decorator and also improved our documentation to make sure that classes implementing LambdaInterface
can work properly. To learn more, check out this issue that contains a more detailed explanation.
import { Tracer } from '@aws-lambda-powertools/tracer';
import { LambdaInterface } from '@aws-lambda-powertools/commons';
const tracer = new Tracer({ serviceName: 'serverlessAirline' });
class Lambda implements LambdaInterface {
@tracer.captureLambdaHandler()
public async handler(_event: any, _context: any): Promise<void> {
/* ... */
}
}
const handlerClass = new Lambda();
export const handler = handlerClass.handler.bind(handlerClass); // <- Binding your handler method allows your handler to access `this`.
Finally, a big thank you to @misterjoshua who reported the bug, collaborated to the triaging, and submitted a PR proposing a fix 🎉
Changes
📜 Documentation updates
- chore(tracer): remove redundant export in docs & examples (#1062) by @dreamorosi
🐛 Bug and hot fixes
- Fix(metrics): decorated class methods cannot access
this
(#1059) by @dreamorosi - fix(logger): decorated class methods cannot access
this
(#1060) by @dreamorosi - fix(tracer): use instance as
this
in capture decorators (#1055) by @misterjoshua - fix(build): publish workflow concurrency + leftover dependencies (#1054) by @dreamorosi
🔧 Maintenance
- chore(tracer): remove redundant export in docs & examples (#1062) by @dreamorosi
This release was made possible by the following contributors:
v1.1.0
Summary
This release contains two bug fixes that were reported by community members:
Logger
was affected by a bug that prevented it from correctly clearing the state of attached attributes when the Lambda handler was throwing an error.Tracer
instead had a bug incaptureMethod
feature that caused the scope of the decorated method to be wrongly reassigned.
Over the past weeks the team has also been working on improving and strengthening the security of the CI/CD pipelines that allow to run unit and integration tests, as well as publishing the packages on NPM and the documentation.
Additionally, it contains some initial groundwork that will allow us to publish the libraries as Lambda layers - so stay tuned for news on this topic in the coming weeks!
Finally, a big thank you also to first-time contributors: @tsop14 and @ratscrew 🎉 Thank you for helping improving the library!
Changes
🌟New features and non-breaking changes
📜 Documentation updates
🐛 Bug and hot fixes
- Fix(build): e2e workflow failing (#1047) by @dreamorosi
- fix(logger): fix clearstate bug when lambda handler throws (#1045) by @saragerion
- fix: wrong scope in captureMethod (#1026) by @ratscrew
🔧 Maintenance
- feat(build): publish lib as a Lambda Layer (#884) by @flochaz
- chore(build): broke up pr workflow & measure package size (#1031) by @dreamorosi
- chore(ci): housekeeping scripts & workflows related to PRs (#1023) by @dreamorosi
This release was made possible by the following contributors:
v1.0.2
Summary
This release introduces changes entirely related to our documentation and examples.
📚 Documentation improvements 📚
- Clarified that people can use the library in both TypeScript and JavaScript code bases
- Added references to the Serverless TypeScript Demo application
- Added a single copy-paste-able command to install all three utilities at once
- Added Call to Actions to contribute and help us drive our roadmap
- Improved consistency with the messaging of the Launch blog post
- Changed font size and removed the Table of Contents on the right side to improve readability in smaller screens
- Improved UX when zooming in and scrolling through images
- Added images in Logger, Tracer and Metrics to showcase outputs in CloudWatch (with ALT)
- Changed order of examples to: Middy, Decorator, Manual instrumentation
- Added license link
📚 Examples 📚
Examples in the repository have been updated to use version 1.x 🚀
Changes
📜 Documentation updates
- docs: minor improvements and fixes (#1022) by @saragerion
- docs: minor improvements (#1021) by @saragerion
🔧 Maintenance
- chore(docs): bump version in examples (#1020) by @dreamorosi
This release was made possible by the following contributors:
@dreamorosi, @github-actions[bot] and @saragerion
v.1.0.1
Note: Version bump for all packages.