Skip to content

Commit a0e8615

Browse files
committed
Fixed merge conflicts
2 parents a93e905 + 6c19444 commit a0e8615

34 files changed

+957
-271
lines changed

.github/release-drafter.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,20 @@ categories:
2020
- title: '🚒 Deprecations'
2121
labels:
2222
- 'deprecated'
23+
- title: '🔧 Maintenance'
24+
labels:
25+
- 'internal'
26+
- 'dependencies'
2327
exclude-labels:
2428
- 'skip-changelog'
2529
tag-template: 'v$NEXT_PATCH_VERSION'
2630
template: |
27-
## Changes
31+
## Summary
2832
2933
**[Human readable summary of changes]**
3034
35+
## Changes
36+
3137
$CHANGES
3238
3339
## This release was made possible by the following contributors:

.github/workflows/release-drafter.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
update_release_draft:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: release-drafter/release-drafter@v5.15.0
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,60 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [0.2.0-beta.19](https://github.com/awslabs/aws-lambda-powertools-typescript/compare/v0.2.0-beta.18...v0.2.0-beta.19) (2022-01-04)
7+
8+
9+
### Bug Fixes
10+
11+
* **metrics:** Support multiple addMetric() call with the same metric name ([#390](https://github.com/awslabs/aws-lambda-powertools-typescript/issues/390)) ([91a2bba](https://github.com/awslabs/aws-lambda-powertools-typescript/commit/91a2bbabbed67b6c4a802e6313dfef6243ebffc8))
12+
13+
14+
15+
16+
17+
# [0.2.0-beta.18](https://github.com/awslabs/aws-lambda-powertools-typescript/compare/v0.2.0-beta.17...v0.2.0-beta.18) (2022-01-04)
18+
19+
**Note:** Version bump only for package aws-lambda-powertools-typescript
20+
21+
22+
23+
24+
25+
# [0.2.0-beta.17](https://github.com/awslabs/aws-lambda-powertools-typescript/compare/v0.2.0-beta.16...v0.2.0-beta.17) (2022-01-04)
26+
27+
**Note:** Version bump only for package aws-lambda-powertools-typescript
28+
29+
30+
31+
32+
33+
# [0.2.0-beta.16](https://github.com/awslabs/aws-lambda-powertools-typescript/compare/v0.2.0-beta.15...v0.2.0-beta.16) (2022-01-03)
34+
35+
36+
### Bug Fixes
37+
38+
* **logger:** correct log level in cloudwatch ([#386](https://github.com/awslabs/aws-lambda-powertools-typescript/issues/386)) ([23ee7f4](https://github.com/awslabs/aws-lambda-powertools-typescript/commit/23ee7f4fd612dfaa8e5c084a2294721ad78ed759))
39+
40+
41+
42+
43+
44+
# [0.2.0-beta.15](https://github.com/awslabs/aws-lambda-powertools-typescript/compare/v0.2.0-beta.14...v0.2.0-beta.15) (2022-01-03)
45+
46+
47+
### Bug Fixes
48+
49+
* **metrics:** export middy middleware ([#380](https://github.com/awslabs/aws-lambda-powertools-typescript/issues/380)) ([6107725](https://github.com/awslabs/aws-lambda-powertools-typescript/commit/61077256b14d1e061155be9c5f9ae95be0a33417))
50+
51+
52+
### Features
53+
54+
* **metrics:** rename method purgeStoredMetrics to publishStoredMetrics ([#377](https://github.com/awslabs/aws-lambda-powertools-typescript/issues/377)) ([c9265b0](https://github.com/awslabs/aws-lambda-powertools-typescript/commit/c9265b0b76789048e6f7019d3a6f58afe37c39e5))
55+
56+
57+
58+
59+
660
# [0.2.0-beta.14](https://github.com/awslabs/aws-lambda-powertools-typescript/compare/v0.2.0-beta.12...v0.2.0-beta.14) (2022-01-03)
761

862

docs/core/logger.md

Lines changed: 83 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -459,63 +459,131 @@ For example, by setting the "sample rate" to `0.5`, roughly 50% of your lambda i
459459

460460
=== "handler.ts"
461461

462-
```typescript hl_lines="5"
462+
```typescript hl_lines="6"
463463
import { Logger } from "@aws-lambda-powertools/logger";
464464

465+
// Notice the log level set to 'ERROR'
465466
const logger = new Logger({
466467
logLevel: "ERROR",
467468
sampleRateValue: 0.5
468469
});
469470

470471
export const handler = async (_event: any, _context: any) => {
471-
472-
// 0.5 means that you have 50% chance that these logs will be printed
473-
logger.info("This is INFO log #1");
474-
logger.info("This is INFO log #2");
475-
logger.info("This is INFO log #3");
476-
logger.info("This is INFO log #4");
472+
473+
// This log item (equal to log level 'ERROR') will be printed to standard output
474+
// in all Lambda invocations
475+
logger.error("This is an ERROR log");
476+
477+
// These log items (below the log level 'ERROR') have ~50% chance
478+
// of being printed in a Lambda invocation
479+
logger.debug("This is a DEBUG log that has 50% chance of being printed");
480+
logger.info("This is an INFO log that has 50% chance of being printed");
481+
logger.warn("This is a WARN log that has 50% chance of being printed");
477482
478483
// Optional: refresh sample rate calculation on runtime
479484
// logger.refreshSampleRateCalculation();
480485

481486
};
482487
```
483488

484-
=== "Example CloudWatch Logs excerpt"
489+
=== "Example CloudWatch Logs excerpt - Invocation #1"
485490

486-
```json hl_lines="4 12 20 28"
491+
```json
487492
{
488-
"level": "INFO",
489-
"message": "This is INFO log #1",
493+
"level": "ERROR",
494+
"message": "This is an ERROR log",
490495
"sampling_rate": "0.5",
491496
"service": "serverlessAirline",
492497
"timestamp": "2021-12-12T22:59:06.334Z",
493498
"xray_trace_id": "abcdef123456abcdef123456abcdef123456"
494499
}
495500
{
496-
"level": "INFO",
497-
"message": "This is INFO log #2",
501+
"level": "DEBUG",
502+
"message": "This is a DEBUG log that has 50% chance of being printed",
498503
"sampling_rate": "0.5",
499504
"service": "serverlessAirline",
500505
"timestamp": "2021-12-12T22:59:06.337Z",
501506
"xray_trace_id": "abcdef123456abcdef123456abcdef123456"
502507
}
503508
{
504509
"level": "INFO",
505-
"message": "This is INFO log #3",
510+
"message": "This is an INFO log that has 50% chance of being printed",
506511
"sampling_rate": "0.5",
507512
"service": "serverlessAirline",
508513
"timestamp": "2021-12-12T22:59:06.338Z",
509514
"xray_trace_id": "abcdef123456abcdef123456abcdef123456"
510515
}
516+
{
517+
"level": "WARN",
518+
"message": "This is a WARN log that has 50% chance of being printed",
519+
"sampling_rate": "0.5",
520+
"service": "shopping-cart-api",
521+
"timestamp": "2021-12-12T22:59:06.338Z",
522+
"xray_trace_id": "abcdef123456abcdef123456abcdef123456"
523+
}
524+
```
525+
526+
=== "Example CloudWatch Logs excerpt - Invocation #2"
527+
528+
```json
529+
{
530+
"level": "ERROR",
531+
"message": "This is an ERROR log",
532+
"sampling_rate": "0.5",
533+
"service": "shopping-cart-api",
534+
"timestamp": "2021-12-12T22:59:06.334Z",
535+
"xray_trace_id": "abcdef123456abcdef123456abcdef123456"
536+
}
537+
```
538+
539+
=== "Example CloudWatch Logs excerpt - Invocation #3"
540+
541+
```json
542+
{
543+
"level": "ERROR",
544+
"message": "This is an ERROR log",
545+
"sampling_rate": "0.5",
546+
"service": "shopping-cart-api",
547+
"timestamp": "2021-12-12T22:59:06.334Z",
548+
"xray_trace_id": "abcdef123456abcdef123456abcdef123456"
549+
}
550+
{
551+
"level": "DEBUG",
552+
"message": "This is a DEBUG log that has 50% chance of being printed",
553+
"sampling_rate": "0.5",
554+
"service": "shopping-cart-api",
555+
"timestamp": "2021-12-12T22:59:06.337Z",
556+
"xray_trace_id": "abcdef123456abcdef123456abcdef123456"
557+
}
511558
{
512559
"level": "INFO",
513-
"message": "This is INFO log #4",
560+
"message": "This is an INFO log that has 50% chance of being printed",
514561
"sampling_rate": "0.5",
515562
"service": "serverlessAirline",
516563
"timestamp": "2021-12-12T22:59:06.338Z",
517564
"xray_trace_id": "abcdef123456abcdef123456abcdef123456"
518565
}
566+
{
567+
"level": "WARN",
568+
"message": "This is a WARN log that has 50% chance of being printed",
569+
"sampling_rate": "0.5",
570+
"service": "shopping-cart-api",
571+
"timestamp": "2021-12-12T22:59:06.338Z",
572+
"xray_trace_id": "abcdef123456abcdef123456abcdef123456"
573+
}
574+
```
575+
576+
=== "Example CloudWatch Logs excerpt - Invocation #4"
577+
578+
```json
579+
{
580+
"level": "ERROR",
581+
"message": "This is an ERROR log",
582+
"sampling_rate": "0.5",
583+
"service": "shopping-cart-api",
584+
"timestamp": "2021-12-12T22:59:06.334Z",
585+
"xray_trace_id": "abcdef123456abcdef123456abcdef123456"
586+
}
519587
```
520588

521589
### Custom Log formatter (Bring Your Own Formatter)

docs/core/metrics.md

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,54 @@ You can create metrics using the `addMetric` method, and you can create dimensio
134134
!!! warning "Do not create metrics or dimensions outside the handler"
135135
Metrics or dimensions added in the global scope will only be added during cold start. Disregard if that's the intended behaviour.
136136

137+
### Adding multi-value metrics
138+
You can call `addMetric()` with the same name multiple times. The values will be grouped together in an array.
139+
140+
=== "addMetric() with the same name"
141+
142+
```typescript hl_lines="8 10"
143+
import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
144+
import { Context } from 'aws-lambda';
145+
146+
147+
const metrics = new Metrics({namespace:"serverlessAirline", service:"orders"});
148+
149+
export const handler = async (event: any, context: Context) => {
150+
metrics.addMetric('performedActionA', MetricUnits.Count, 2);
151+
// do something else...
152+
metrics.addMetric('performedActionA', MetricUnits.Count, 1);
153+
}
154+
```
155+
=== "Example CloudWatch Logs excerpt"
156+
157+
```json hl_lines="2-5 18-19"
158+
{
159+
"performedActionA": [
160+
2,
161+
1
162+
],
163+
"_aws": {
164+
"Timestamp": 1592234975665,
165+
"CloudWatchMetrics": [
166+
{
167+
"Namespace": "serverlessAirline",
168+
"Dimensions": [
169+
[
170+
"service"
171+
]
172+
],
173+
"Metrics": [
174+
{
175+
"Name": "performedActionA",
176+
"Unit": "Count"
177+
}
178+
]
179+
}
180+
]
181+
},
182+
"service": "orders"
183+
}
184+
```
137185
### Adding default dimensions
138186

139187
You can add default dimensions to your metrics by passing them as parameters in 4 ways:
@@ -326,8 +374,6 @@ See below an example of how to automatically flush metrics with the Middy-compat
326374
"Unit": "Count"
327375
}
328376
]
329-
}
330-
]
331377
},
332378
"service": "orders"
333379
}
@@ -380,8 +426,6 @@ The `logMetrics` decorator of the metrics utility can be used when your Lambda h
380426
"Unit": "Count"
381427
}
382428
]
383-
}
384-
]
385429
},
386430
"service": "orders"
387431
}
@@ -494,12 +538,20 @@ You can add high-cardinality data as part of your Metrics log with the `addMetad
494538
],
495539
"Metrics": [
496540
{
497-
"Name": "successfulBooking",
498-
"Unit": "Count"
541+
"Namespace": "exampleApplication",
542+
"Dimensions": [
543+
[
544+
"service"
545+
]
546+
],
547+
"Metrics": [
548+
{
549+
"Name": "successfulBooking",
550+
"Unit": "Count"
551+
}
552+
]
499553
}
500554
]
501-
}
502-
]
503555
},
504556
"service": "orders",
505557
"bookingId": "7051cd10-6283-11ec-90d6-0242ac120003"

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"packages": [
33
"packages/*"
44
],
5-
"version": "0.2.0-beta.14",
5+
"version": "0.2.0-beta.19",
66
"npmClient": "npm",
77
"message": "chore(release): %s [skip ci]"
88
}

packages/commons/CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,46 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [0.2.0-beta.19](https://github.com/awslabs/aws-lambda-powertools-typescript/compare/v0.2.0-beta.18...v0.2.0-beta.19) (2022-01-04)
7+
8+
**Note:** Version bump only for package @aws-lambda-powertools/commons
9+
10+
11+
12+
13+
14+
# [0.2.0-beta.18](https://github.com/awslabs/aws-lambda-powertools-typescript/compare/v0.2.0-beta.17...v0.2.0-beta.18) (2022-01-04)
15+
16+
**Note:** Version bump only for package @aws-lambda-powertools/commons
17+
18+
19+
20+
21+
22+
# [0.2.0-beta.17](https://github.com/awslabs/aws-lambda-powertools-typescript/compare/v0.2.0-beta.16...v0.2.0-beta.17) (2022-01-04)
23+
24+
**Note:** Version bump only for package @aws-lambda-powertools/commons
25+
26+
27+
28+
29+
30+
# [0.2.0-beta.16](https://github.com/awslabs/aws-lambda-powertools-typescript/compare/v0.2.0-beta.15...v0.2.0-beta.16) (2022-01-03)
31+
32+
**Note:** Version bump only for package @aws-lambda-powertools/commons
33+
34+
35+
36+
37+
38+
# [0.2.0-beta.15](https://github.com/awslabs/aws-lambda-powertools-typescript/compare/v0.2.0-beta.14...v0.2.0-beta.15) (2022-01-03)
39+
40+
**Note:** Version bump only for package @aws-lambda-powertools/commons
41+
42+
43+
44+
45+
646
# [0.2.0-beta.14](https://github.com/awslabs/aws-lambda-powertools-typescript/compare/v0.2.0-beta.12...v0.2.0-beta.14) (2022-01-03)
747

848
**Note:** Version bump only for package @aws-lambda-powertools/commons

0 commit comments

Comments
 (0)