Skip to content

Commit d1ff84d

Browse files
author
Michael Brewer
authored
Merge branch 'develop' into docs/1064-data-classes
2 parents 3ac53a7 + 9d8dd1b commit d1ff84d

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

Diff for: CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
44

55
This project follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format for changes and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## 1.26.1 - 2022-06-07
8+
### Bug Fixes
9+
10+
* **metrics:** raise SchemaValidationError for >8 metric dimensions ([#1240](https://github.com/awslabs/aws-lambda-powertools-python/issues/1240))
11+
12+
### Documentation
13+
14+
* **governance:** link roadmap and maintainers doc
15+
* **maintainers:** initial maintainers playbook ([#1222](https://github.com/awslabs/aws-lambda-powertools-python/issues/1222))
16+
* **roadmap:** use pinned pause issue instead
17+
18+
### Maintenance
19+
20+
* **deps-dev:** bump mypy from 0.950 to 0.960 ([#1224](https://github.com/awslabs/aws-lambda-powertools-python/issues/1224))
21+
* **deps-dev:** bump mypy-boto3-secretsmanager from 1.23.0.post1 to 1.23.8 ([#1225](https://github.com/awslabs/aws-lambda-powertools-python/issues/1225))
22+
23+
724
## 1.26.0 - 2022-05-20
825

926
### Bug Fixes

Diff for: aws_lambda_powertools/metrics/base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ def serialize_metric_set(
178178
metadata = self.metadata_set
179179

180180
if self.service and not self.dimension_set.get("service"):
181-
self.dimension_set["service"] = self.service
181+
# self.service won't be a float
182+
self.add_dimension(name="service", value=self.service) # type: ignore[arg-type]
182183

183184
if len(metrics) == 0:
184185
raise SchemaValidationError("Must contain at least one metric.")

Diff for: docs/core/metrics.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ If you're new to Amazon CloudWatch, there are two terminologies you must be awar
3030

3131
Metric has two global settings that will be used across all metrics emitted:
3232

33-
Setting | Description | Environment variable | Constructor parameter
34-
------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------- | -------------------------------------------------
35-
**Metric namespace** | Logical container where all metrics will be placed e.g. `ServerlessAirline` | `POWERTOOLS_METRICS_NAMESPACE` | `namespace`
36-
**Service** | Optionally, sets **service** metric dimension across all metrics e.g. `payment` | `POWERTOOLS_SERVICE_NAME` | `service`
33+
| Setting | Description | Environment variable | Constructor parameter |
34+
| -------------------- | ------------------------------------------------------------------------------- | ------------------------------ | --------------------- |
35+
| **Metric namespace** | Logical container where all metrics will be placed e.g. `ServerlessAirline` | `POWERTOOLS_METRICS_NAMESPACE` | `namespace` |
36+
| **Service** | Optionally, sets **service** metric dimension across all metrics e.g. `payment` | `POWERTOOLS_SERVICE_NAME` | `service` |
3737

3838
???+ tip
3939
Use your application or main service as the metric namespace to easily group all metrics.
@@ -191,7 +191,7 @@ This decorator also **validates**, **serializes**, and **flushes** all your metr
191191
???+ tip "Tip: Metric validation"
192192
If metrics are provided, and any of the following criteria are not met, **`SchemaValidationError`** exception will be raised:
193193

194-
* Maximum of 9 dimensions
194+
* Maximum of 8 user-defined dimensions
195195
* Namespace is set, and no more than one
196196
* Metric units must be [supported by CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html)
197197

Diff for: pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "aws_lambda_powertools"
3-
version = "1.26.0"
3+
version = "1.26.1"
44
description = "A suite of utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, batching, idempotency, feature flags, and more."
55
authors = ["Amazon Web Services"]
66
include = ["aws_lambda_powertools/py.typed", "THIRD-PARTY-LICENSES"]

Diff for: tests/functional/test_metrics.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,11 @@ def test_schema_no_metrics(service, namespace):
319319
my_metrics.serialize_metric_set()
320320

321321

322-
def test_exceed_number_of_dimensions(metric, namespace):
322+
def test_exceed_number_of_dimensions(metric, namespace, monkeypatch):
323323
# GIVEN we we have more dimensions than CloudWatch supports
324-
dimensions = [{"name": f"test_{i}", "value": "test"} for i in range(11)]
324+
# and that service dimension is injected like a user-defined dimension (N+1)
325+
monkeypatch.setenv("POWERTOOLS_SERVICE_NAME", "test_service")
326+
dimensions = [{"name": f"test_{i}", "value": "test"} for i in range(9)]
325327

326328
# WHEN we attempt to serialize them into a valid EMF object
327329
# THEN it should fail validation and raise SchemaValidationError

0 commit comments

Comments
 (0)