Skip to content

Commit 8744555

Browse files
Strip empty chars
1 parent 1f103e4 commit 8744555

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

aws_lambda_powertools/metrics/provider/cloudwatch_emf/cloudwatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def add_dimension(self, name: str, value: str) -> None:
273273
f"Maximum number of dimensions exceeded ({MAX_DIMENSIONS}): Unable to add dimension {name}.",
274274
)
275275

276-
if not name or not value:
276+
if not name.strip() or not value.strip():
277277
warnings.warn(
278278
f"The dimension {name} doesn't meet the requirements and won't be added. "
279279
"Ensure the dimension name and value are non empty strings",

docs/core/metrics.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ If you're new to Amazon CloudWatch, there are five terminologies you must be awa
2525
* **Resolution**. It's a value representing the storage resolution for the corresponding metric. Metrics can be either Standard or High resolution. Read more [here](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html#high-resolution-metrics){target="_blank"}.
2626

2727
<figure>
28-
<img src="../../media/metrics_terminology.png" />
28+
<img src="../../media/metrics_terminology.png" alt="Terminology" />
2929
<figcaption>Metric terminology, visually explained</figcaption>
3030
</figure>
3131

@@ -131,6 +131,8 @@ If you'd like to remove them at some point, you can use `clear_default_dimension
131131
--8<-- "examples/metrics/src/set_default_dimensions_log_metrics.py"
132132
```
133133

134+
**Note:** Dimensions with empty values will not be included.
135+
134136
### Changing default timestamp
135137

136138
When creating metrics, we use the current timestamp. If you want to change the timestamp of all the metrics you create, utilize the `set_timestamp` function. You can specify a datetime object or an integer representing an epoch timestamp in milliseconds.

tests/functional/metrics/required_dependencies/test_metrics_cloudwatch_emf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ def test_add_dimensions_with_empty_value(namespace, capsys, metric):
10531053

10541054
# WHEN we try to add a dimension with empty value
10551055
with pytest.warns(UserWarning, match=f"The dimension {my_dimension} doesn't meet the requirements *"):
1056-
my_metrics.add_dimension(name="my_empty_dimension", value="")
1056+
my_metrics.add_dimension(name="my_empty_dimension", value=" ")
10571057

10581058
my_metrics.add_metric(**metric)
10591059
my_metrics.flush_metrics()

0 commit comments

Comments
 (0)