Releases: aws-powertools/powertools-lambda-typescript
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.
v1.0.0
Changes
With this release, we move from release candidate to General Availability 🎉🎉🎉!
This means APIs for the core utilities Tracer, Logger, and Metrics are now stable and they are ready to be used in AWS Lambda functions written in JavaScript and TypeScript running in production.
Quick links: 📜Documentation | NPM | Feature request | Bug Report
Tracer
🤩 Key features 🤩
- Auto capture cold start and service name as annotations, and responses or full exceptions as metadata
- Auto-disable when not running in AWS Lambda environment
- Automatically trace HTTP(s) clients and generate segments for each request
- Support tracing functions via decorators, middleware, and manual instrumentation
- Support tracing AWS SDK v2 and v3 via AWS X-Ray SDK for Node.js
import { Tracer, captureLambdaHandler } from '@aws-lambda-powertools/tracer';
// Using Middy for the first time? Learn more at https://middy.js.org
import middy from '@middy/core';
const tracer = new Tracer();
const lambdaHandler = async (_event: any, _context: any): Promise<void> => {
/* ... */
};
// Wrap the handler with middy
export const handler = middy(lambdaHandler)
// Use the middleware by passing the Tracer instance as a parameter
.use(captureLambdaHandler(tracer));
Logger
🤩 Key features 🤩
- Capture key fields from Lambda context, cold start and structure logging output as JSON
- Log Lambda event when instructed (disabled by default)
- Log sampling prints all the logs for a percentage of invocations (disabled by default)
- Append additional keys to structured log at any point in time
import { Logger, injectLambdaContext } from '@aws-lambda-powertools/logger';
// Using Middy for the first time? Learn more at https://middy.js.org
import middy from '@middy/core';
const logger = new Logger();
const lambdaHandler = async (_event: any, _context: any): Promise<void> => {
logger.info('This is an INFO log with some context');
};
// Wrap the handler with middy
export const handler = middy(lambdaHandler)
.use(injectLambdaContext(logger));
Metrics
🤩 Key features 🤩
- Aggregate up to 100 metrics using a single CloudWatch EMF object (large JSON blob)
- Validate against common metric definitions mistakes (metric unit, values, max dimensions, max metrics, etc)
- Metrics are created asynchronously by CloudWatch service, no custom stacks needed
- Context manager to create a one off metric with a different dimension
import { Metrics, MetricUnits, logMetrics } from '@aws-lambda-powertools/metrics';
import middy from '@middy/core';
const metrics = new Metrics({ namespace: 'myApplication' });
const lambdaHandler = async (_event: any, _context: any): Promise<void> => {
metrics.addMetric('successfulBooking', MetricUnits.Count, 1);
};
// Wrap the handler with middy
export const handler = middy(lambdaHandler)
.use(logMetrics(metrics));
Samples and Starters
https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples
https://github.com/aws-samples/serverless-typescript-demo
🌟Special thank you
We'd like to extend our gratitude to the following people who helped with contributions, feedbacks, and their opinions while we were in developer preview:
@heitorlessa, @AWSDB, @SH4DY, @okoskine, @goverdhan07, @JavierMendozaGomez, @bahrmichael, @alan-churley, @alex-m-aws, @kozub, @roman-boiko, @willfarrell, @lmammino
v0.12.0-rc.1
Summary
In this release candidate version we have made some updates to the documentation to clarify the settings needed for the Tracer utility to work as well as fixing some bugs in both Tracer and Logger that emerged during the testing phase that we have been running in the past weeks.
Changes
- Revert "build: bump lerna (#1014)" (#1018) by @saragerion
- Revert "chore(release): v0.12.0-rc.0 [skip ci]" (#1017) by @saragerion
🌟New features and non-breaking changes
- feat(tracer): auto disable when running inside amplify mock (#1010) by @dreamorosi
📜 Documentation updates
- docs: added note about active tracing (#1011) by @dreamorosi
- docs: update docs to reflect RC status (#1009) by @dreamorosi
🐛 Bug and hot fixes
- fix(tracer): capture method throws errors correctly (#1016) by @dreamorosi
- fix(logger): POWERTOOLS_LOGGER_LOG_EVENT precedence is respected (#1015) by @dreamorosi
🔧 Maintenance
- build(dev-deps): bump lerna from 4.x to 5.x (#1014) by @dreamorosi
- build(deps): bump parse-url from 6.0.0 to 6.0.2 (#1013) by @dependabot
This release was made possible by the following contributors:
v0.11.1-rc.0
Summary
With this release, we move from beta developer preview to Release Candidate (RC) 🎉 🎉 🎉
In this stage we are looking to gather as much feedback as possible as well as discovering unknown unknowns that might have slipped through the unit and integration test cases we have implemented so far.
We consider the Logger, Metrics, and Tracer utilities complete in terms of features but we anticipate that there might be some additional releases between now and the General Availability release to fix any bug or issue that are found.
Over the next few weeks we encourage all of you to try the new RC release(s) and let us know what you think as well as reporting any issue or sharp edge that you might find. We will be doing the same and test-drive the utilities in some non-trivial workloads.
Finally, we want to take a moment to thank you all for the patience and the enthusiasm towards the project that we have seen so far. We know that we have a long way to go and we look forward to see what you will do with AWS Powertools for TypeScript; now go build 🔧!
Changes
🔧 Maintenance
- chore: updated rc release flow (#1005) by @dreamorosi
This release was made possible by the following contributors:
v0.11.0
Summary
This release introduces 2 main features for the Logger utility: clear state functionality, and log event.
Clear state
The Logger utility is commonly initialized in the global scope, outside the handler function.
When you attach persistent log attributes through the persistentLogAttributes
constructor option or via the appendKeys
, addPersistentLogAttributes
methods, this data is attached to the Logger instance.
Due to the Lambda Execution Context reuse, this means those persistent log attributes may be reused across invocations.
This PR introduces a new flag that developers can enable to "clear the state" across invocations.
If developers want to make sure that persistent attributes added inside the handler function code are not persisted across invocations, they can now set the parameter clearState
as true
in the injectLambdaContext
middleware or decorator.
Log event
This PR introduces a new functionality: logging Lambda events. Developers can opt in for this behaviour by one of the following methods:
- passing the parameter
logEvent
set totrue
to theinjectLambdaContext
middleware - passing the parameter
logEvent
set totrue
to theinjectLambdaContext
decorator - setting the env var
POWERTOOLS_LOGGER_LOG_EVENT
to through while using the injectLambdaContext middleware/decorator
Note that this functionality is only available when using a middleware or decorator.
The Lambda invocation will then print one log item with the following key-value pairs:
logLevel
INFOmessage
key with valueLambda invocation event
event
key with the current Lambda invocation event as value
Logging a Lambda event is very typical use of a logger in AWS Lambda. This logic aims to simplify and reduce the code that developers need to maintain.
Improvements
We disabled the dependabot updates in favour of periodic, manual dependencies upgrades as the current dependabot setup was disrupting the maintainers' focus and was polluting out PRs.
We also added a useful Github Action plugin that will comment the size of the utilities package so we can monitor it we are add code or dependencies.
Changes
- build: bump examples version (#928) by @dreamorosi
🌟New features and non-breaking changes
- Feat(logger): log event functionality (#1004) by @saragerion
- Feat(logger): add clear state functionality (#902) by @saragerion
🔧 Maintenance
- chore: disable dependabot for dependencies upgrades (#992) by @dreamorosi
- feat (build): Add package size check in PR workflow (#878) by @flochaz
- build(deps-dev): bump esbuild from 0.14.45 to 0.14.46 (#985) by @dependabot
- build(deps): bump aws-sdk from 2.1156.0 to 2.1157.0 (#984) by @dependabot
- build(deps-dev): bump typescript from 4.7.3 to 4.7.4 (#982) by @dependabot
- build(deps-dev): bump eslint from 8.17.0 to 8.18.0 (#983) by @dependabot
- build(deps-dev): bump @types/node from 17.0.42 to 18.0.0 (#973) by @dependabot
- build(deps-dev): bump esbuild from 0.14.43 to 0.14.45 (#971) by @dependabot
- build(deps): bump aws-sdk from 2.1152.0 to 2.1156.0 (#976) by @dependabot
- build(deps): bump mkdocs-material from 8.3.3 to 8.3.6 in /docs (#981) by @dependabot
- build(deps-dev): bump @typescript-eslint/parser from 5.27.1 to 5.28.0 (#968) by @dependabot
- build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.27.1 to 5.28.0 (#969) by @dependabot
- build(deps): bump broken Depdendabot deps (#945) by @dreamorosi
- build(deps-dev): bump @types/node from 17.0.41 to 17.0.42 (#961) by @dependabot
- build(deps): bump @aws-sdk/client-sts from 3.100.0 to 3.105.0 (#948) by @dependabot
- build(deps-dev): bump typescript from 4.6.4 to 4.7.3 (#953) by @dependabot
- build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.27.0 to 5.27.1 (#959) by @dependabot
- build(deps): bump @types/aws-lambda from 8.10.97 to 8.10.100 (#955) by @dependabot
- build(deps-dev): bump esbuild from 0.14.42 to 0.14.43 (#954) by @dependabot
- build(deps-dev): bump @typescript-eslint/parser from 5.27.0 to 5.27.1 (#958) by @dependabot
- build(deps): bump aws-sdk from 2.1148.0 to 2.1152.0 (#949) by @dependabot
- build(deps): bump mkdocs-material from 8.3.0 to 8.3.3 in /docs (#957) by @dependabot
- build(deps-dev): bump @commitlint/cli from 17.0.1 to 17.0.2 (#952) by @dependabot
- build(deps-dev): bump eslint from 8.16.0 to 8.17.0 (#950) by @dependabot
- build(deps-dev): bump @types/node from 17.0.38 to 17.0.41 (#960) by @dependabot
- build(deps): bump actions/setup-python from 3 to 4 (#947) by @dependabot
- build(deps-dev): bump ts-node from 10.8.0 to 10.8.1 (#946) by @dependabot
- build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.26.0 to 5.27.0 (#940) by @dependabot
- build(deps-dev): bump typedoc from 0.22.15 to 0.22.17 (#935) by @dependabot
- build(deps): bump aws-cdk-lib from 2.25.0 to 2.27.0 (#942) by @dependabot
- build(deps-dev): bump @aws-cdk/cloudformation-diff from 2.25.0 to 2.27.0 (#937) by @dependabot
- build(deps): bump constructs from 10.1.19 to 10.1.25 (#933) by @dependabot
- build(deps-dev): bump cdk-assets from 2.25.0 to 2.27.0 (#931) by @dependabot
- build(deps-dev): bump @aws-cdk/cx-api from 2.25.0 to 2.27.0 (#929) by @dependabot
- build(deps): bump @aws-sdk/client-sts from 3.95.0 to 3.100.0 (#917) by @dependabot
- build(deps-dev): bump @types/node from 17.0.35 to 17.0.38 (#939) by @dependabot
- build(deps-dev): bump @typescript-eslint/parser from 5.26.0 to 5.27.0 (#943) by @dependabot
- build(deps-dev): bump esbuild from 0.14.40 to 0.14.42 (#941) by @dependabot
- build(deps): bump mkdocs-material from 8.2.15 to 8.3.0 in /docs (#944) by @dependabot
- build(deps): bump aws-sdk from 2.1140.0 to 2.1148.0 (#930) by @dependabot
This release was made possible by the following contributors:
@dependabot, @dependabot[bot], @dreamorosi, @flochaz and @saragerion
v0.10.0
Summary
This release adds support for the Node.js 16.x runtime that has recently been released for AWS Lambda, as well as extending support to the Node.js 12.x one by moving to es2019
as transpile target.
Additionally, this release introduces the option of removing persistent keys from a logger instance. This can be done using the newly introduced removeKeys
method that accepts as parameter an array of keys to be removed.
Changes
🌟New features and non-breaking changes
- feat(logger): add removeKeys functionality (#901) by @saragerion
- feat(all): nodejs16x support (#877) by @dreamorosi
📜 Documentation updates
- chore(examples): updated contributing & docs with SAM (#876) by @dreamorosi
🐛 Bug and hot fixes
- build(all): use es2019 target to support on Node12 (#925) by @ijemmy
- fix(commons): rename tests subfolder to samples to avoid being deleted by tools such as node-prune (#882) by @flochaz
🔧 Maintenance
- chore(examples): cleanup old examples (#903) by @dreamorosi
- build(deps): bump constructs from 10.1.12 to 10.1.19 (#920) by @dependabot
- build(deps-dev): bump @aws-cdk/cx-api from 2.24.1 to 2.25.0 (#913) by @dependabot
- build(deps-dev): bump @aws-cdk/cloudformation-diff from 2.24.1 to 2.25.0 (#911) by @dependabot
- build(deps-dev): bump cdk-assets from 2.24.1 to 2.25.0 (#907) by @dependabot
- build(deps): bump aws-cdk-lib from 2.24.1 to 2.25.0 (#904) by @dependabot
- build(deps-dev): bump @types/lodash.pickby from 4.6.6 to 4.6.7 (#914) by @dependabot
- build(deps-dev): bump @types/lodash.clonedeep from 4.5.6 to 4.5.7 (#906) by @dependabot
- build(deps-dev): bump esbuild from 0.14.39 to 0.14.40 (#905) by @dependabot
- build(deps-dev): bump ts-node from 10.7.0 to 10.8.0 (#908) by @dependabot
- build(deps-dev): bump eslint from 8.15.0 to 8.16.0 (#910) by @dependabot
- build(deps-dev): bump @typescript-eslint/parser from 5.25.0 to 5.26.0 (#918) by @dependabot
- build(deps-dev): bump @commitlint/cli from 17.0.0 to 17.0.1 (#919) by @dependabot
- build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.25.0 to 5.26.0 (#922) by @dependabot
- build(deps-dev): bump axios from 0.27.1 to 0.27.2 (#923) by @dependabot
- chore(examples): updated contributing & docs with SAM (#876) by @dreamorosi