You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core/logger.md
+3-2
Original file line number
Diff line number
Diff line change
@@ -118,8 +118,9 @@ This functionality will include the following keys in your structured logs:
118
118
119
119
=== "Decorator"
120
120
121
-
!!! info
122
-
Powertools decorators can only be attached to class methods and follow the experimetal decorators proposal implementation found in TypeScript 4.x. As such, you need to enable the `experimentalDecorators` compiler option in your `tsconfig.json` file to use them.
121
+
!!! note
122
+
The class method decorators in this project follow the experimental implementation enabled via the [`experimentalDecorators` compiler option](https://www.typescriptlang.org/tsconfig#experimentalDecorators) in TypeScript. Additionally, they are implemented in a way that fits asynchronous methods. When decorating a synchronous method, the decorator replaces its implementation with an asynchronous one causing the caller to have to `await` the now decorated method.
123
+
If this is not the desired behavior, you can call the `logger.injectLambdaContext()` method directly in your handler.
Copy file name to clipboardExpand all lines: docs/core/metrics.md
+6-5
Original file line number
Diff line number
Diff line change
@@ -211,8 +211,9 @@ You can add default dimensions to your metrics by passing them as parameters in
211
211
212
212
=== "with logMetrics decorator"
213
213
214
-
!!! info
215
-
Powertools decorators can only be attached to class methods and follow the experimetal decorators proposal implementation found in TypeScript 4.x. As such, you need to enable the `experimentalDecorators` compiler option in your `tsconfig.json` file to use them.
214
+
!!! note
215
+
The class method decorators in this project follow the experimental implementation enabled via the [`experimentalDecorators` compiler option](https://www.typescriptlang.org/tsconfig#experimentalDecorators) in TypeScript. Additionally, they are implemented in a way that fits asynchronous methods. When decorating a synchronous method, the decorator replaces its implementation with an asynchronous one causing the caller to have to `await` the now decorated method.
216
+
If this is not the desired behavior, you can use the `logMetrics` middleware instead.
@@ -276,9 +277,9 @@ See below an example of how to automatically flush metrics with the Middy-compat
276
277
277
278
#### Using the class decorator
278
279
279
-
!!! info
280
-
Decorators can only be attached to a class declaration, method, accessor, property, or parameter. Therefore, if you prefer to write your handler as a standard function rather than a Class method, check the [middleware](#using-a-middleware) or [manual](#manually) method sections instead.
281
-
See the [official TypeScript documentation](https://www.typescriptlang.org/docs/handbook/decorators.html) for more details.
280
+
!!! note
281
+
The class method decorators in this project follow the experimental implementation enabled via the [`experimentalDecorators` compiler option](https://www.typescriptlang.org/tsconfig#experimentalDecorators) in TypeScript. Additionally, they are implemented in a way that fits asynchronous methods. When decorating a synchronous method, the decorator replaces its implementation with an asynchronous one causing the caller to have to `await` the now decorated method.
282
+
If this is not the desired behavior, you can use the `logMetrics` middleware instead.
282
283
283
284
The `logMetrics` decorator of the metrics utility can be used when your Lambda handler function is implemented as method of a Class.
Copy file name to clipboardExpand all lines: docs/core/tracer.md
+11-6
Original file line number
Diff line number
Diff line change
@@ -97,8 +97,9 @@ You can quickly start by importing the `Tracer` class, initialize it outside the
97
97
98
98
=== "Decorator"
99
99
100
-
!!! info
101
-
Powertools decorators can only be attached to class methods and follow the experimetal decorators proposal implementation found in TypeScript 4.x. As such, you need to enable the `experimentalDecorators` compiler option in your `tsconfig.json` file to use them.
100
+
!!! note
101
+
The class method decorators in this project follow the experimental implementation enabled via the [`experimentalDecorators` compiler option](https://www.typescriptlang.org/tsconfig#experimentalDecorators) in TypeScript. Additionally, they are implemented in a way that fits asynchronous methods. When decorating a synchronous method, the decorator replaces its implementation with an asynchronous one causing the caller to have to `await` the now decorated method.
102
+
If this is not the desired behavior, you can use one of the other patterns instead.
102
103
103
104
```typescript hl_lines="8"
104
105
--8<-- "docs/snippets/tracer/decorator.ts"
@@ -152,10 +153,14 @@ When using the `captureLambdaHandler` decorator or middleware, Tracer performs t
152
153
153
154
### Methods
154
155
155
-
You can trace other Class methods using the `captureMethod` decorator or any arbitrary function using manual instrumentation.
156
+
You can trace other class methods using the `captureMethod` decorator or any arbitrary asynchronous function using manual instrumentation.
156
157
157
158
=== "Decorator"
158
159
160
+
!!! note
161
+
The class method decorators in this project follow the experimental implementation enabled via the [`experimentalDecorators` compiler option](https://www.typescriptlang.org/tsconfig#experimentalDecorators) in TypeScript. Additionally, they are implemented in a way that fits asynchronous methods. When decorating a synchronous method, the decorator replaces its implementation with an asynchronous one causing the caller to have to `await` the now decorated method.
162
+
If this is not the desired behavior, you can use manual instrumentation instead.
@@ -181,7 +186,7 @@ You can patch any AWS SDK clients by calling the `captureAWSv3Client` method:
181
186
182
187
=== "index.ts"
183
188
184
-
```typescript hl_lines="5"
189
+
```typescript hl_lines="6"
185
190
--8<-- "docs/snippets/tracer/captureAWSv3.ts"
186
191
```
187
192
@@ -192,15 +197,15 @@ You can patch all AWS SDK v2 clients by calling the `captureAWS` method:
192
197
193
198
=== "index.ts"
194
199
195
-
```typescript hl_lines="5"
200
+
```typescript hl_lines="6"
196
201
--8<-- "docs/snippets/tracer/captureAWSAll.ts"
197
202
```
198
203
199
204
If you're looking to shave a few microseconds, or milliseconds depending on your function memory configuration, you can patch only specific AWS SDK v2 clients using `captureAWSClient`:
Copy file name to clipboardExpand all lines: docs/utilities/idempotency.md
+6-2
Original file line number
Diff line number
Diff line change
@@ -164,6 +164,10 @@ The function this example has two arguments, note that while wrapping it with th
164
164
165
165
You can also use the `@idempotent` decorator to make your Lambda handler idempotent, similar to the `makeIdempotent` function wrapper.
166
166
167
+
!!! info
168
+
The class method decorators in this project follow the experimental implementation enabled via the [`experimentalDecorators` compiler option](https://www.typescriptlang.org/tsconfig#experimentalDecorators) in TypeScript. Additionally, they are implemented in a way that fits asynchronous methods. When decorating a synchronous method, the decorator replaces its implementation with an asynchronous one causing the caller to have to `await` the now decorated method.
169
+
If this is not the desired behavior, you can use one of the other patterns to make your logic idempotent.
170
+
167
171
=== "index.ts"
168
172
169
173
```typescript hl_lines="17"
@@ -183,8 +187,8 @@ The configuration options for the `@idempotent` decorator are the same as the on
183
187
### MakeHandlerIdempotent Middy middleware
184
188
185
189
!!! tip "A note about Middy"
186
-
Currently we support only Middy `v3.x` that you can install it by running `npm i @middy/core@~3`.
187
-
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"}.
190
+
Currently we support only Middy `v3.x` that you can install it by running `npm i @middy/core@~3`.
191
+
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"}.
188
192
189
193
If you are using [Middy](https://middy.js.org){target="_blank"} as your middleware engine, you can use the `makeHandlerIdempotent` middleware to make your Lambda handler idempotent. Similar to the `makeIdempotent` function wrapper, you can quickly make your Lambda handler idempotent by initializing the `DynamoDBPersistenceLayer` class and using it with the `makeHandlerIdempotent` middleware.
0 commit comments