Skip to content

Commit

Permalink
feat!: add ESM support & logger extensibility (#2117)
Browse files Browse the repository at this point in the history
* feat(logger): Support for external observability providers (#1511)

* Updated formatAttributes for additional parameters and LogItem return type

* Updated the unit tests to pass with new formatter

* Updated Powertool named objects to Powertools

* Updated tests to match new naming consistency

* Updated for tests for new naming consistency

* Updated formatter for new design decisions

* Update Logger for ephemeral attributes

* Update bringYourOwnFormatter documentation to match new formatter

---------

Co-authored-by: erikayao93 <[email protected]>

* chore(logger): PowertoolsLogFormatter docstring and variable naming update (#1585)

* Updated formatAttributes for additional parameters and LogItem return type

* Updated the unit tests to pass with new formatter

* Updated Powertool named objects to Powertools

* Updated tests to match new naming consistency

* Updated for tests for new naming consistency

* Updated formatter for new design decisions

* Update Logger for ephemeral attributes

* Update bringYourOwnFormatter documentation to match new formatter

* Fixed incorrect return type, renamed variable for consistency

* feat(logger): Support for external observability providers (#1511)

* Updated formatAttributes for additional parameters and LogItem return type

* Updated the unit tests to pass with new formatter

* Updated Powertool named objects to Powertools

* Updated tests to match new naming consistency

* Updated for tests for new naming consistency

* Updated formatter for new design decisions

* Update Logger for ephemeral attributes

* Update bringYourOwnFormatter documentation to match new formatter

---------

Co-authored-by: erikayao93 <[email protected]>

* chore(logger): PowertoolsLogFormatter docstring and variable naming update (#1585)

* Updated formatAttributes for additional parameters and LogItem return type

* Updated the unit tests to pass with new formatter

* Updated Powertool named objects to Powertools

* Updated tests to match new naming consistency

* Updated for tests for new naming consistency

* Updated formatter for new design decisions

* Update Logger for ephemeral attributes

* Update bringYourOwnFormatter documentation to match new formatter

* Fixed incorrect return type, renamed variable for consistency

* chore(maintenance): bump dependencies & drop nodejs14x (#1687)

* chore: update release script to mark all utilities as alpha

* chore: restore version to ease conflicts

* chore: release version change

* chore: release version change

* chore(maintenance): remove `createLogger` and `createTracer` helpers (#1722)

* chore(maintenance): bump dependencies & drop nodejs14x (#1687)

* chore: add pre-release script

* chore: restore deps

* chore: added v2 shim

* chore(maintenance): remove logger and tracer helper function

* chore: remove imports

* chore: fix deps & versions

* tests: moved unit tests

* tests: move logger tests

* chore: added v2 shim

* chore: added v2 shim

* feat(logger): add esmodule support (#1734)

* feat(logger): add esm build output

* fix(Logger): Remove barrel files update references

* test(Logger): update jest/ts-jest to use ESM

* chore(Logger): remove unused lodash.merge

* fix(logger): reinstate lodash.merge

* chore(logger): revert TS assertion

* chore(logger): revert format changes

* chore(logger): update postbuild to remove incremental tsbuildinfo files

* fix(logger): correct reference to types output

* feat(logging): add middleware export

* chore(logger): replace postbuild script with echo statement

* feat(logger): add typesVersions property and barrel files to /types

* chore(logger): file not used, can be added back if needed

* chore(logger): add space back to README

* chore(logger): revert space in README

* feat(commons): add esmodule support (#1735)

* chore(logger): adapt logger to commons exports

* feat(commons): add esmodule support

* chore: address sonar findings

* chore(commons): exported version

* chore: fixed imports in examples

* chore(parameters): fixed imports

* chore(metrics): fixed imports

* chore(tracer): fixed imports

* chore(idempotency): fixed imports

* chore(commons): test coverage

* chore(batch): fix imports

* feat(parameters): add esmodule support (#1736)

* feat(batch): add esmodule support (#1737)

* feat(internal): add esmodule support (#1738)

* feat(testing): add esmodule support

* chore(all): update imports

* feat(metrics): add esmodule support (#1739)

* feat(tracer): add esmodule support (#1741)

* feat(tracer): add esmodule support

* chore(docs): update imports

* feat(idempotency): add esmodule support  (#1743)

* feat(idempotency): add esmodule support

* chore(metrics): fix import

* chore(ci): v2 release line

* chore(ci): fix alpha versioning pre-release

* docs(maintenance): add processes tab (#1747)

* docs(maintenance): update mkdocs to support tabs

* chore(ci): add parallel test npm script

* chore(ci): add jest command

* docs(maintenance): add testing page to navbar

* docs(maintenance): add contributing info

* chore: update roadmap

* chore: update release drafter workflow to allow for manual trigger

* fix formatting

* docs: maintainers handbook

* chore: link to new location

* fix links

* Update docs/maintainers.md

Co-authored-by: Alexander Schueren <[email protected]>

---------

Co-authored-by: Alexander Schueren <[email protected]>

* chore(docs): add invisible unicode char to decorator docs (#1755)

* chore: remove extra comma

* chore(docs): upgrade doc intro

* feat(logger): align sampling debug logs feature implementation with the other runtimes (#1744)

* test(logger): remove logsSampled field, add default sampleRateValue

* test(logger): add tests for sampling debug logs feature

* feat(logger): change implementation to make sampling decision at per-function level

* refactor(logger): remove redundant createLogger method

* refactor(logger): remove getSampleRateValue method

* test(logger): improve tests

* refactor(logger): return createLogger() back with the detailed comment of the method importance

* test(logger): add constructor/custom config/env var priority tests for sampling rate feature, improve description

* refactor(logger): address review comments

* feat(logger): add refreshSampleRateCalculation method and tests

* test(logger): adjust end-to-end tests

* chore(logger): refactor types and interfaces (#1758)

* chore(logger): refactor types and interfaces

* chore: grouped type files

* chore: fix code smell

* chore: fix ci

* chore: fix ci

* chore(maintenance): bump Middy v4 & run tests (#1760)

* chore(parameters): fix esm bundling

* chore(parameters): change declare client param

* chore(layers) widen version check in e2e

* chore(maintenance): enable `isolatedModules` and isolate cache (#1765)

* chore(layers) widen version check in e2e

* chore(maintenance): enable isolatedModules

* chore: remove redundant comments from tsconfig

* chore: changed path of tsbuild cache

* fix: idempotency types

* build(maintenance): bump aws sdk dev dependencies

* chore(parameters): add export types

* chore(logger): set default UTC timezone (#1775)

* chore(parameters): add export types

* chore(logger): set default utc timezone

* chore(logger): pass down envvarsservice to log formatter

* fix(metrics): deduplicate dimensions when serialising (#1780)

* fix: deduplicate dimensions when serializing

* fix tests

* remove tsbuildinfo

* remove whitespace

* fix gitignore again

* play some sonar games

* fix test

* chore(release): v1.14.2 [skip ci]

* feat(metrics): log directly to stdout  (#1786)

* chore(commons): move isDevMode to commons

* chore(logger): move isDev config out of logger to commons

* feat(metrics): use own console object by default

* tests(layers): fix unit tests

* feat(maintenance): add support for nodejs20.x runtime (#1790)

* feat(maintenance): support nodejs20.x runtime

* tests(metrics): fix object ordering in tests

* build(testing): bump cdk

* build(maintenance): revert aws-cdk-lib to support nodejs14

* tests(maintenance): set runtime with family

* chore(docs): patch runtime in cdk

* chore(docs): patch runtime in cdk

* chore(maintenance): increment version in commons ahead of release

* chore(commons): simplify config service interface

* chore(release): v1.15.0 [skip ci]

* feat(logger): add support for `AWS_LAMBDA_LOG_LEVEL` and `POWERTOOLS_LOG_LEVEL` (#1795)

* feat(logger): support advanced logging

* docs(logger): add alc info

* feat(logger): support alc

* docs: fix alc docs links

* tests(logger): add unit tests for the feature

* docs(logger): make POWERTOOLS_LOG_LEVEL default

* chore(release): v1.16.0 [skip ci]

* chore(maintenance): drop support for Node.js 14 (#1802)

* chore: package lock

* chore(docs): update docs url in comments & readme files (#1728)

* chore(ci): update v2 release workflow (#1745)

* docs(maintenance): add processes tab (#1747)

* docs(maintenance): update mkdocs to support tabs

* chore(ci): add parallel test npm script

* chore(ci): add jest command

* docs(maintenance): add testing page to navbar

* docs(maintenance): add contributing info

* chore: update roadmap

* chore: update release drafter workflow to allow for manual trigger

* fix formatting

* docs: maintainers handbook

* chore: link to new location

* fix links

* Update docs/maintainers.md

Co-authored-by: Alexander Schueren <[email protected]>

---------

Co-authored-by: Alexander Schueren <[email protected]>

* chore(maintenance): add --require-hashes flag to pip installs (#1827)

* bump version to 9.5.2, rerun pip-compile with correct deps (#1830)

* chore(ci): Dependabot fine tuning (#1862)

* ignore major updates for mike

* set versioning strategy for cdk, dependabot is running on auto upgrade strategy per default

* ignore middy major upgrades

* remove CodeQL, it's enough to have Sonar

* update package-lock

* chore(deps-dev): bump @aws-sdk/client-cloudwatch from 3.438.0 to 3.485.0 (#1857)

* chore(deps-dev): bump @types/node from 20.11.0 to 20.11.2 (#1912)

* chore(deps): fix dependencies and dependabot config (#1917)

* chore(deps-dev): bump @typescript-eslint/parser from 6.19.0 to 6.19.1 (#1946)

Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.19.0 to 6.19.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.19.1/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @typescript-eslint/eslint-plugin (#1948)

Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.19.0 to 6.19.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.19.1/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(ci): refactor workflows to scope permissions (#1978)

* chore(maintenance): rebase conflicts

* chore(maintenance): rebase conflicts

* chore: rebase conflicts

* chore: remove v2 specific release

* chore: release patch script

* docs: update docs & snippets

* chore: address SonarCloud findings

* chore: address SonarCloud findings

* chore: address SonarCloud findings

* tests: coverage

* chore: add layers v2

* chore: bump ua version

* docs: add install steps to batch

* chore: fix install command

* chore: remove unused dependency

* Update examples/cdk/package.json

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Erika Yao <[email protected]>
Co-authored-by: erikayao93 <[email protected]>
Co-authored-by: Ant Stanley <[email protected]>
Co-authored-by: Alexander Schueren <[email protected]>
Co-authored-by: Sergei Cherniaev <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
8 people authored Feb 28, 2024
1 parent f92538c commit 3b99263
Show file tree
Hide file tree
Showing 404 changed files with 4,621 additions and 5,178 deletions.
9 changes: 6 additions & 3 deletions .github/actions/cached-node-modules/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ inputs:
nodeVersion: # id of input
description: 'Node.js version to use in the cache key'
default: '20'
build:
description: 'Whether to build the packages or not'
default: 'true'
outputs:
cache-hit:
description: "Whether the cache was hit or not"
Expand All @@ -17,7 +20,7 @@ runs:
shell: bash
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: '**/node_modules'
# Use the combo between node version, name, and SHA-256 hash of the lock file as cache key so that
Expand All @@ -29,8 +32,8 @@ runs:
run: npm ci
shell: bash
- name: Build packages
# Regardless of whether the cache was hit or not, we need to build the packages.
#
# Regardless of whether the cache was hit or not, we need to build the packages, unless the caller says otherwise
if: inputs.build == 'true'
# We build the shared package first, then the others in parallel to speed up the process
# even though we could just run `npm run build` in the root folder and build them in
# sequence, but still in the correct order.
Expand Down
2 changes: 2 additions & 0 deletions .github/scripts/release_patch_package_json.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const betaPackages = [];
types,
files,
private,
type,
} = pkgJson;

let version = originalVersion;
Expand Down Expand Up @@ -71,6 +72,7 @@ const betaPackages = [];
main,
types,
files,
type,
};

// Not all utilities have these fields, so only add them if they exist to avoid
Expand Down
81 changes: 0 additions & 81 deletions .github/workflows/make-v2-release.yml

This file was deleted.

8 changes: 6 additions & 2 deletions .github/workflows/make-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ jobs:
uses: ./.github/actions/cached-node-modules
- name: Version
id: bump-version
run: npx lerna version --conventional-commits --no-git-tag-version --no-push --no-commit-hooks --yes
- name: Update user agent version
run: |
npx lerna version --conventional-commits --no-git-tag-version --no-push --no-commit-hooks --yes
git add .
VERSION=$(cat lerna.json | jq .version -r)
echo -e "// this file is auto generated, do not modify\nexport const VERSION = '$VERSION';" > packages/commons/src/version.ts
- name: Stage changes
run: git add .
- name: Set release version
id: set-release-version
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ tmp

# TS build files
tsconfig.tsbuildinfo
.tsbuildinfo
.tsbuildinfo
2 changes: 1 addition & 1 deletion MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
> [!IMPORTANT]
> Maintainers' playbook moved: https://docs.powertools.aws.dev/lambda/typescript/latest/maintainers/
> Maintainers' playbook moved: https://docs.powertools.aws.dev/lambda/typescript/latest/maintainers/
47 changes: 21 additions & 26 deletions docs/core/logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ The library has three optional settings, which can be set via environment variab

These settings will be used across all logs emitted:

| Setting | Description | Environment variable | Default Value | Allowed Values | Example Value | Constructor parameter |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------------- | ------------------- | ------------------------------------------------------ | ------------------- | --------------------- |
| **Service name** | Sets the name of service of which the Lambda function is part of, that will be present across all log statements | `POWERTOOLS_SERVICE_NAME` | `service_undefined` | Any string | `serverlessAirline` | `serviceName` |
| **Logging level** | Sets how verbose Logger should be, from the most verbose to the least verbose (no logs) | `POWERTOOLS_LOG_LEVEL` | `INFO` | `DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL`, `SILENT` | `ERROR` | `logLevel` |
| **Sample rate** | Probability that a Lambda invocation will print all the log items regardless of the log level setting | `POWERTOOLS_LOGGER_SAMPLE_RATE` | `0` | `0.0` to `1.0` | `0.1` | `sampleRateValue` |
| Setting | Description | Environment variable | Default Value | Allowed Values | Example Value | Constructor parameter |
| ----------------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------------- | ------------------- | ------------------------------------------------------ | ------------------- | --------------------- |
| **Service name** | Sets the name of service of which the Lambda function is part of, that will be present across all log statements | `POWERTOOLS_SERVICE_NAME` | `service_undefined` | Any string | `serverlessAirline` | `serviceName` |
| **Logging level** | Sets how verbose Logger should be, from the most verbose to the least verbose (no logs) | `POWERTOOLS_LOG_LEVEL` | `INFO` | `DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL`, `SILENT` | `ERROR` | `logLevel` |
| **Sample rate** | Probability that a Lambda invocation will print all the log items regardless of the log level setting | `POWERTOOLS_LOGGER_SAMPLE_RATE` | `0` | `0.0` to `1.0` | `0.1` | `sampleRateValue` |

See all environment variables in the [Environment variables](../index.md/#environment-variables) section.
Check API docs to learn more about [Logger constructor options](https://docs.powertools.aws.dev/lambda/typescript/latest/api/types/_aws_lambda_powertools_logger.types.ConstructorOptions.html){target="_blank"}.
Expand Down Expand Up @@ -110,10 +110,10 @@ This functionality will include the following keys in your structured logs:
=== "Middy Middleware"

!!! tip "A note about Middy"
Currently we support only Middy `v3.x` that you can install it by running `npm i @middy/core@~3`.
We guarantee support only for Middy.js `v4.x`, that you can install it by running `npm i @middy/core@~4`.
Check their docs to learn more about [Middy and its middleware stack](https://middy.js.org/docs/intro/getting-started){target="_blank"} as well as [best practices when working with Powertools](https://middy.js.org/docs/integrations/lambda-powertools#best-practices){target="_blank"}.

```typescript hl_lines="1 13"
```typescript hl_lines="2 14"
--8<-- "docs/snippets/logger/middy.ts"
```

Expand All @@ -131,7 +131,7 @@ This functionality will include the following keys in your structured logs:

=== "Manual"

```typescript hl_lines="6"
```typescript hl_lines="10"
--8<-- "docs/snippets/logger/manual.ts"
```

Expand Down Expand Up @@ -163,7 +163,7 @@ When debugging in non-production environments, you can instruct Logger to log th

=== "Middy Middleware"

```typescript hl_lines="10"
```typescript hl_lines="15"
--8<-- "docs/snippets/logger/eventMiddy.ts"
```

Expand Down Expand Up @@ -236,7 +236,7 @@ If you want to make sure that persistent attributes added **inside the handler f

=== "Middy Middleware"

```typescript hl_lines="30"
```typescript hl_lines="31"
--8<-- "docs/snippets/logger/clearStateMiddy.ts"
```

Expand Down Expand Up @@ -509,23 +509,21 @@ The `createChild` method allows you to create a child instance of the Logger, wh
}
```

### Sampling logs
### Sampling debug logs

Use sampling when you want to print all the log items generated in your code, based on a **percentage of your concurrent/cold start invocations**.
Use sampling when you want to dynamically change your log level to **DEBUG** based on a **percentage of your concurrent/cold start invocations**.

You can do that by setting a "sample rate", a float value ranging from `0.0` (0%) to `1` (100%), by using a `POWERTOOLS_LOGGER_SAMPLE_RATE` env var or passing the `sampleRateValue` parameter in the Logger constructor.
This number represents the probability that a Lambda invocation will print all the log items regardless of the log level setting.

For example, by setting the "sample rate" to `0.5`, roughly 50% of your lambda invocations will print all the log items, including the `debug` ones.
You can use values ranging from `0` to `1` (100%) when setting the `sampleRateValue` constructor option or `POWERTOOLS_LOGGER_SAMPLE_RATE` env var.

!!! tip "When is this useful?"
In production, to avoid log data pollution and reduce CloudWatch costs, developers are encouraged to use the logger with `logLevel` equal to `ERROR` or `WARN`.
This means that only errors or warnings will be printed.
Let's imagine a sudden spike increase in concurrency triggered a transient issue downstream. When looking into the logs you might not have enough information, and while you can adjust log levels it might not happen again.

However, it might still be useful to print all the logs (including debug ones) of a very small percentage of invocations to have a better understanding of the behaviour of your code in production even when there are no errors.

**Sampling decision happens at the Logger initialization**. This means sampling may happen significantly more or less than depending on your traffic patterns, for example a steady low number of invocations and thus few cold starts.
If you want to reset the sampling decision and refresh it for each invocation, you can call the `logger.refreshSampleRateCalculation()` method at the beginning or end of your handler.
This feature takes into account transient issues where additional debugging information can be useful.

Sampling decision happens at the Logger initialization. This means sampling may happen significantly more or less than depending on your traffic patterns, for example a steady low number of invocations and thus few cold starts.

!!! note
Open a [feature request](https://github.com/aws-powertools/powertools-lambda-typescript/issues/new?assignees=&labels=type%2Ffeature-request%2Ctriage&projects=aws-powertools%2F7&template=feature_request.yml&title=Feature+request%3A+TITLE) if you want Logger to calculate sampling for every invocation

=== "handler.ts"

Expand Down Expand Up @@ -639,7 +637,7 @@ You can customize the structure (keys and values) of your log items by passing a

=== "handler.ts"

```typescript hl_lines="2 5"
```typescript hl_lines="2 6"
--8<-- "docs/snippets/logger/bringYourOwnFormatterHandler.ts"
```

Expand Down Expand Up @@ -700,9 +698,6 @@ This is a Jest sample that provides the minimum information necessary for Logger
--8<-- "docs/snippets/logger/unitTesting.ts"
```

!!! tip
If you don't want to declare your own dummy Lambda Context, you can use [`ContextExamples.helloworldContext`](https://github.com/aws-powertools/powertools-lambda-typescript/blob/main/packages/commons/src/samples/resources/contexts/hello-world.ts#L3-L16) from [`@aws-lambda-powertools/commons`](https://www.npmjs.com/package/@aws-lambda-powertools/commons).

### Suppress logs with Jest

When unit testing your code with [Jest](https://jestjs.io) you can use the `POWERTOOLS_DEV` environment variable in conjunction with the Jest `--silent` CLI option to suppress logs from Logger.
Expand Down
8 changes: 4 additions & 4 deletions docs/core/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ npm install @aws-lambda-powertools/metrics

!!! warning "Caution"

Using the Lambda [Advanced Logging Controls](...docs link) feature requires you to update your version of Powertools for AWS Lambda (TypeScript) to at least v1.15.0 to ensure metrics are reported correctly to Amazon CloudWatch Metrics.
Using the Lambda [Advanced Logging Controls](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html#monitoring-cloudwatchlogs-advanced) feature requires you to update your version of Powertools for AWS Lambda (TypeScript) to at least v1.15.0 to ensure metrics are reported correctly to Amazon CloudWatch Metrics.

### Usage

Expand Down Expand Up @@ -253,7 +253,7 @@ See below an example of how to automatically flush metrics with the Middy-compat

=== "handler.ts"

```typescript hl_lines="20"
```typescript hl_lines="2 17"
--8<-- "docs/snippets/metrics/middy.ts"
```

Expand Down Expand Up @@ -368,7 +368,7 @@ You can optionally capture cold start metrics with the `logMetrics` middleware o

=== "Middy Middleware"

```typescript hl_lines="21"
```typescript hl_lines="18"
--8<-- "docs/snippets/metrics/captureColdStartMetricMiddy.ts"
```

Expand Down Expand Up @@ -398,7 +398,7 @@ You can add high-cardinality data as part of your Metrics log with the `addMetad

=== "handler.ts"

```typescript hl_lines="18"
```typescript hl_lines="15"
--8<-- "docs/snippets/metrics/addMetadata.ts"
```

Expand Down
8 changes: 4 additions & 4 deletions docs/core/tracer.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ You can quickly start by importing the `Tracer` class, initialize it outside the
=== "Middy Middleware"

!!! tip "A note about Middy"
Currently we support only Middy `v3.x` that you can install it by running `npm i @middy/core@~3`.
We guarantee support only for Middy.js `v4.x`, that you can install it by running `npm i @middy/core@~4`.
Check their docs to learn more about [Middy and its middleware stack](https://middy.js.org/docs/intro/getting-started){target="_blank"} as well as [best practices when working with Powertools](https://middy.js.org/docs/integrations/lambda-powertools#best-practices){target="_blank"}.

```typescript hl_lines="1 14 16"
```typescript hl_lines="2 15 17"
--8<-- "docs/snippets/tracer/middy.ts"
```

Expand Down Expand Up @@ -197,7 +197,7 @@ You can patch all AWS SDK v2 clients by calling the `captureAWS` method:

=== "index.ts"

```typescript hl_lines="6"
```typescript hl_lines="7"
--8<-- "docs/snippets/tracer/captureAWSAll.ts"
```

Expand Down Expand Up @@ -284,7 +284,7 @@ Alternatively, use the `captureResponse: false` option in both `tracer.captureLa

=== "middy.ts"

```typescript hl_lines="17"
```typescript hl_lines="18"
--8<-- "docs/snippets/tracer/disableCaptureResponseMiddy.ts"
```

Expand Down
Loading

0 comments on commit 3b99263

Please sign in to comment.