Skip to content

Commit 90a5240

Browse files
authored
chore(docs): review docs highlighted code snippets (#1469)
1 parent 6d0ed9e commit 90a5240

File tree

4 files changed

+89
-111
lines changed

4 files changed

+89
-111
lines changed

Diff for: docs/core/logger.md

+28-28
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ These settings will be used across all logs emitted:
6868
ShoppingCartApiFunction:
6969
Type: AWS::Serverless::Function
7070
Properties:
71-
Runtime: nodejs16.x
71+
Runtime: nodejs18.x
7272
Environment:
7373
Variables:
7474
LOG_LEVEL: WARN
@@ -112,7 +112,7 @@ This functionality will include the following keys in your structured logs:
112112
You can install Middy by running `npm i @middy/core`.
113113
Learn more about [its usage and lifecycle in the official Middy documentation](https://middy.js.org/docs/intro/getting-started){target="_blank"}.
114114

115-
```typescript hl_lines="1-2 13"
115+
```typescript hl_lines="1 13"
116116
--8<-- "docs/snippets/logger/middy.ts"
117117
```
118118

@@ -402,7 +402,7 @@ The `createChild` method allows you to create a child instance of the Logger, wh
402402

403403
=== "Example CloudWatch Logs excerpt"
404404

405-
```json hl_lines="15-21"
405+
```json hl_lines="21"
406406
{
407407
"level": "INFO",
408408
"message": "This is an INFO log, from the parent logger",
@@ -590,31 +590,31 @@ This is how the printed log would look:
590590
=== "Example CloudWatch Logs excerpt"
591591

592592
```json
593-
{
594-
"message": "This is an INFO log",
595-
"service": "serverlessAirline",
596-
"awsRegion": "eu-west-1",
597-
"correlationIds": {
598-
"awsRequestId": "c6af9ac6-7b61-11e6-9a41-93e812345678",
599-
"xRayTraceId": "abcdef123456abcdef123456abcdef123456",
600-
"myCustomCorrelationId": "foo-bar-baz"
601-
},
602-
"lambdaFunction": {
603-
"name": "shopping-cart-api-lambda-prod-eu-west-1",
604-
"arn": "arn:aws:lambda:eu-west-1:123456789012:function:shopping-cart-api-lambda-prod-eu-west-1",
605-
"memoryLimitInMB": 128,
606-
"version": "$LATEST",
607-
"coldStart": true
608-
},
609-
"logLevel": "INFO",
610-
"timestamp": "2021-12-12T23:13:53.404Z",
611-
"logger": {
612-
"sampleRateValue": "0.5",
613-
"name": "aws-lambda-powertools-typescript",
614-
"version": "0.0.1"
615-
},
616-
"awsAccountId": "123456789012"
617-
}
593+
{
594+
"message": "This is an INFO log",
595+
"service": "serverlessAirline",
596+
"awsRegion": "eu-west-1",
597+
"correlationIds": {
598+
"awsRequestId": "c6af9ac6-7b61-11e6-9a41-93e812345678",
599+
"xRayTraceId": "abcdef123456abcdef123456abcdef123456",
600+
"myCustomCorrelationId": "foo-bar-baz"
601+
},
602+
"lambdaFunction": {
603+
"name": "shopping-cart-api-lambda-prod-eu-west-1",
604+
"arn": "arn:aws:lambda:eu-west-1:123456789012:function:shopping-cart-api-lambda-prod-eu-west-1",
605+
"memoryLimitInMB": 128,
606+
"version": "$LATEST",
607+
"coldStart": true
608+
},
609+
"logLevel": "INFO",
610+
"timestamp": "2021-12-12T23:13:53.404Z",
611+
"logger": {
612+
"sampleRateValue": "0.5",
613+
"name": "aws-lambda-powertools-typescript",
614+
"version": "0.0.1"
615+
},
616+
"awsAccountId": "123456789012"
617+
}
618618
```
619619

620620
!!! tip "Custom Log formatter and Child loggers"

Diff for: docs/core/metrics.md

+52-74
Original file line numberDiff line numberDiff line change
@@ -251,25 +251,21 @@ See below an example of how to automatically flush metrics with the Middy-compat
251251

252252
=== "Example CloudWatch Logs excerpt"
253253

254-
```json hl_lines="2 7 10 15 22"
254+
```json
255255
{
256256
"successfulBooking": 1.0,
257257
"_aws": {
258-
"Timestamp": 1592234975665,
259-
"CloudWatchMetrics": [
260-
{
261-
"Namespace": "serverlessAirline",
262-
"Dimensions": [
263-
[
264-
"service"
265-
]
266-
],
267-
"Metrics": [
268-
{
269-
"Name": "successfulBooking",
270-
"Unit": "Count"
271-
}
272-
]
258+
"Timestamp": 1592234975665,
259+
"CloudWatchMetrics": [{
260+
"Namespace": "serverlessAirline",
261+
"Dimensions": [
262+
[ "service" ]
263+
],
264+
"Metrics": [{
265+
"Name": "successfulBooking",
266+
"Unit": "Count"
267+
}]
268+
}]
273269
},
274270
"service": "orders"
275271
}
@@ -293,25 +289,21 @@ The `logMetrics` decorator of the metrics utility can be used when your Lambda h
293289

294290
=== "Example CloudWatch Logs excerpt"
295291

296-
```json hl_lines="2 7 10 15 22"
292+
```json
297293
{
298294
"successfulBooking": 1.0,
299295
"_aws": {
300-
"Timestamp": 1592234975665,
301-
"CloudWatchMetrics": [
302-
{
303-
"Namespace": "successfulBooking",
304-
"Dimensions": [
305-
[
306-
"service"
307-
]
308-
],
309-
"Metrics": [
310-
{
311-
"Name": "successfulBooking",
312-
"Unit": "Count"
313-
}
314-
]
296+
"Timestamp": 1592234975665,
297+
"CloudWatchMetrics": [{
298+
"Namespace": "successfulBooking",
299+
"Dimensions": [
300+
[ "service" ]
301+
],
302+
"Metrics": [{
303+
"Name": "successfulBooking",
304+
"Unit": "Count"
305+
}]
306+
}]
315307
},
316308
"service": "orders"
317309
}
@@ -332,27 +324,21 @@ You can manually flush the metrics with `publishStoredMetrics` as follows:
332324

333325
=== "Example CloudWatch Logs excerpt"
334326

335-
```json hl_lines="2 7 10 15 22"
327+
```json
336328
{
337329
"successfulBooking": 1.0,
338330
"_aws": {
339-
"Timestamp": 1592234975665,
340-
"CloudWatchMetrics": [
341-
{
342-
"Namespace": "successfulBooking",
343-
"Dimensions": [
344-
[
345-
"service"
346-
]
347-
],
348-
"Metrics": [
349-
{
350-
"Name": "successfulBooking",
351-
"Unit": "Count"
352-
}
353-
]
354-
}
355-
]
331+
"Timestamp": 1592234975665,
332+
"CloudWatchMetrics": [{
333+
"Namespace": "successfulBooking",
334+
"Dimensions": [
335+
[ "service" ]
336+
],
337+
"Metrics": [{
338+
"Name": "successfulBooking",
339+
"Unit": "Count"
340+
}]
341+
}]
356342
},
357343
"service": "orders"
358344
}
@@ -410,35 +396,27 @@ You can add high-cardinality data as part of your Metrics log with the `addMetad
410396

411397
=== "Example CloudWatch Logs excerpt"
412398

413-
```json hl_lines="23"
399+
```json hl_lines="31"
414400
{
415401
"successfulBooking": 1.0,
416402
"_aws": {
417-
"Timestamp": 1592234975665,
418-
"CloudWatchMetrics": [
419-
{
420-
"Namespace": "serverlessAirline",
421-
"Dimensions": [
422-
[
423-
"service"
424-
]
425-
],
426-
"Metrics": [
427-
{
428-
"Namespace": "exampleApplication",
403+
"Timestamp": 1592234975665,
404+
"CloudWatchMetrics": [{
405+
"Namespace": "serverlessAirline",
429406
"Dimensions": [
430-
[
431-
"service"
432-
]
407+
[ "service" ]
433408
],
434-
"Metrics": [
435-
{
436-
"Name": "successfulBooking",
437-
"Unit": "Count"
438-
}
439-
]
440-
}
441-
]
409+
"Metrics": [{
410+
"Namespace": "exampleApplication",
411+
"Dimensions": [
412+
[ "service" ]
413+
],
414+
"Metrics": [{
415+
"Name": "successfulBooking",
416+
"Unit": "Count"
417+
}]
418+
}]
419+
}]
442420
},
443421
"service": "orders",
444422
"bookingId": "7051cd10-6283-11ec-90d6-0242ac120003"

Diff for: docs/core/tracer.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The `Tracer` utility is instantiated outside of the Lambda handler. In doing thi
7272
HelloWorldFunction:
7373
Type: AWS::Serverless::Function
7474
Properties:
75-
Runtime: nodejs16.x
75+
Runtime: nodejs18.x
7676
Tracing: Active
7777
Environment:
7878
Variables:
@@ -89,7 +89,7 @@ You can quickly start by importing the `Tracer` class, initialize it outside the
8989
You can install Middy by running `npm i @middy/core`.
9090
Learn more about [its usage and lifecycle in the official Middy documentation](https://middy.js.org/docs/intro/getting-started){target="_blank"}.
9191

92-
```typescript hl_lines="1-2 14 16"
92+
```typescript hl_lines="1 14 16"
9393
--8<-- "docs/snippets/tracer/middy.ts"
9494
```
9595

Diff for: docs/index.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ You can install Powertools using one of the following options:
3131

3232
### Lambda Layer
3333

34-
???+ warning "As of now, Container Image deployment (OCI) or inline Lambda functions do not support Lambda Layers."
34+
??? warning "As of now, Container Image deployment (OCI) or inline Lambda functions do not support Lambda Layers"
3535

3636
[Lambda Layer](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html){target="_blank"} 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.
3737

3838
You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https://docs.aws.amazon.com/lambda/latest/dg/invocation-layers.html#invocation-layers-using){target="_blank"}, or your preferred deployment framework.
3939

40-
??? note "Note: Click to expand and copy any regional Lambda Layer ARN"
40+
??? note "Click to expand and copy any regional Lambda Layer ARN"
4141

4242
| Region | Layer ARN |
4343
| ---------------- | ------------------------------------------------------------------------------------------------------------ |
@@ -67,7 +67,7 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https:
6767
| `af-south-1` | [arn:aws:lambda:af-south-1:094274105915:layer:AWSLambdaPowertoolsTypeScript:11](#){: .copyMe}:clipboard: |
6868
| `me-south-1` | [arn:aws:lambda:me-south-1:094274105915:layer:AWSLambdaPowertoolsTypeScript:11](#){: .copyMe}:clipboard: |
6969

70-
??? note "Note: Click to expand and copy code snippets for popular frameworks"
70+
??? note "Click to expand and copy code snippets for popular frameworks"
7171

7272
=== "SAM"
7373

@@ -81,7 +81,7 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https:
8181

8282
If you use `esbuild` to bundle your code, make sure to exclude `@aws-lambda-powertools` from being bundled since the packages will be already present the Layer:
8383

84-
```yaml hl_lines="5"
84+
```yaml hl_lines="5-14"
8585
MyLambdaFunction:
8686
Type: AWS::Serverless::Function
8787
Properties:
@@ -173,7 +173,7 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https:
173173

174174
=== "Terraform"
175175

176-
```terraform hl_lines="9 36"
176+
```terraform hl_lines="18"
177177
terraform {
178178
required_version = "~> 1.0.5"
179179
required_providers {
@@ -224,7 +224,7 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https:
224224

225225
=== "Amplify"
226226

227-
```zsh
227+
```zsh hl_lines="9 19"
228228
# Create a new one with the layer
229229
❯ amplify add function
230230
? Select which capability you want to add: Lambda function (serverless function)
@@ -247,7 +247,7 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https:
247247
? Do you want to edit the local lambda function now? No
248248
```
249249

250-
!!! info "Using Powertools via Lambda Layer? Simply add the Powertools utilities you are using as a development dependency."
250+
!!! info "Using Powertools via Lambda Layer? Simply add the Powertools utilities you are using as a development dependency"
251251

252252
??? question "Want to inspect the contents of the Layer?"
253253
Change {region} to your AWS region, e.g. `eu-west-1`

0 commit comments

Comments
 (0)