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
docs: surface new 1.12.0 features and enhancements (#344)
* docs: update AppSync Resolver to emphasize correlation, typos
* docs: remove additional note banners to ease reading
* docs: surface usage of new correlation_id and paths
* docs: add note on reusing a single table for idempotency state
* docs(parameters): refresh to use new navigation
* docs(parameters): add new force_fetch param
* docs(parameters): surface how to change cache TTL
* Update docs/utilities/parameters.md
Co-authored-by: Michael Brewer <[email protected]>
Co-authored-by: Michael Brewer <[email protected]>
@@ -143,6 +143,89 @@ When debugging in non-production environments, you can instruct Logger to log th
143
143
...
144
144
```
145
145
146
+
#### Setting a Correlation ID
147
+
148
+
> New in 1.12.0
149
+
150
+
You can set a Correlation ID using `correlation_id_path` param by passing a [JMESPath expression](https://jmespath.org/tutorial.html){target="_blank"}.
We provide [built-in JMESPath expressions](#built-in-correlation-id-expressions) for known event sources, where either a request ID or X-Ray Trace ID are present.
190
+
191
+
=== "collect.py"
192
+
193
+
```python hl_lines="2"
194
+
from aws_lambda_powertools import Logger
195
+
from aws_lambda_powertools.logging import correlation_paths
You can append additional keys using either mechanism:
@@ -188,24 +271,58 @@ You can append your own keys to your existing Logger via `structure_logs(append=
188
271
189
272
This example will add `order_id` if its value is not empty, and in subsequent invocations where `order_id` might not be present it'll remove it from the logger.
190
273
191
-
#### Setting correlation ID
274
+
#### extra parameter
192
275
193
-
You can set a correlation_id to your existing Logger via `set_correlation_id(value)` method.
276
+
> New in 1.10.0
277
+
278
+
Extra parameter is available for all log levels' methods, as implemented in the standard logging library - e.g. `logger.info, logger.warning`.
279
+
280
+
It accepts any dictionary, and all keyword arguments will be added as part of the root structure of the logs for that log statement.
281
+
282
+
!!! info "Any keyword argument added using `extra` will not be persisted for subsequent messages."
283
+
284
+
=== "extra_parameter.py"
285
+
286
+
```python hl_lines="6"
287
+
logger = Logger(service="payment")
288
+
289
+
fields = { "request_id": "1123" }
290
+
291
+
logger.info("Hello", extra=fields)
292
+
```
293
+
=== "Example CloudWatch Logs excerpt"
294
+
295
+
```json hl_lines="7"
296
+
{
297
+
"timestamp": "2021-01-12 14:08:12,357",
298
+
"level": "INFO",
299
+
"location": "collect.handler:1",
300
+
"service": "payment",
301
+
"sampling_rate": 0.0,
302
+
"request_id": "1123",
303
+
"message": "Collecting payment"
304
+
}
305
+
```
306
+
307
+
#### set_correlation_id method
308
+
309
+
> New in 1.12.0
310
+
311
+
You can set a correlation_id to your existing Logger via `set_correlation_id(value)` method by passing any string value.
194
312
195
313
=== "collect.py"
196
314
197
-
```python hl_lines="8"
315
+
```python hl_lines="6"
198
316
from aws_lambda_powertools import Logger
199
-
from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEvent
Copy file name to clipboardExpand all lines: docs/utilities/data_classes.md
+12-9Lines changed: 12 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -106,8 +106,12 @@ It is used for either API Gateway REST API or HTTP API using v1 proxy event.
106
106
107
107
### AppSync Resolver
108
108
109
-
Used when building a Lambda GraphQL Resolvers with [Amplify GraphQL Transform Library](https://docs.amplify.aws/cli/graphql-transformer/function){target="_blank"}
110
-
and can also be used for [AppSync Direct Lambda Resolvers](https://aws.amazon.com/blogs/mobile/appsync-direct-lambda/){target="_blank"}.
109
+
> New in 1.12.0
110
+
111
+
Used when building Lambda GraphQL Resolvers with [Amplify GraphQL Transform Library](https://docs.amplify.aws/cli/graphql-transformer/function){target="_blank"} (`@function`),
112
+
and [AppSync Direct Lambda Resolvers](https://aws.amazon.com/blogs/mobile/appsync-direct-lambda/){target="_blank"}.
113
+
114
+
In this example, we also use the new Logger `correlation_id` and built-in `correlation_paths` to extract, if available, X-Ray Trace ID in AppSync request headers:
In this example we are modifying the wrapped dict response fields, so we need to return the json serializable wrapped event in `event.raw_event`
257
261
258
-
!!! info "NOTE "
259
-
This example is based on the AWS Cognito docs for [Define Auth Challenge Lambda Trigger](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-define-auth-challenge.html){target="_blank"}
262
+
This example is based on the AWS Cognito docs for [Define Auth Challenge Lambda Trigger](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-define-auth-challenge.html){target="_blank"}.
This example is based on the AWS Cognito docs for [Create Auth Challenge Lambda Trigger](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-create-auth-challenge.html){target="_blank"}
416
+
This example is based on the AWS Cognito docs for [Create Auth Challenge Lambda Trigger](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-create-auth-challenge.html){target="_blank"}.
This example is based on the AWS Cognito docs for [Verify Auth Challenge Response Lambda Trigger](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-verify-auth-challenge-response.html){target="_blank"}
434
+
This example is based on the AWS Cognito docs for [Verify Auth Challenge Response Lambda Trigger](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-verify-auth-challenge-response.html){target="_blank"}.
0 commit comments