diff --git a/aws_lambda_powertools/metrics/base.py b/aws_lambda_powertools/metrics/base.py index 89a6dc6f4cd..b96356192ab 100644 --- a/aws_lambda_powertools/metrics/base.py +++ b/aws_lambda_powertools/metrics/base.py @@ -391,7 +391,11 @@ def decorate(event, context): self._add_cold_start_metric(context=context) finally: if not raise_on_empty_metrics and not self.metric_set: - warnings.warn("No metrics to publish, skipping", stacklevel=2) + warnings.warn( + "No application metrics to publish. The cold-start metric may be published if enabled. " + "If application metrics should never be empty, consider using 'raise_on_empty_metrics'", + stacklevel=2, + ) else: metrics = self.serialize_metric_set() self.clear_metrics() diff --git a/tests/functional/test_metrics.py b/tests/functional/test_metrics.py index 2a53b42cd16..c0c41f3bf88 100644 --- a/tests/functional/test_metrics.py +++ b/tests/functional/test_metrics.py @@ -728,7 +728,10 @@ def lambda_handler(evt, context): warnings.simplefilter("default") lambda_handler({}, {}) assert len(w) == 1 - assert str(w[-1].message) == "No metrics to publish, skipping" + assert str(w[-1].message) == ( + "No application metrics to publish. The cold-start metric may be published if enabled. " + "If application metrics should never be empty, consider using 'raise_on_empty_metrics'" + ) def test_log_metrics_with_implicit_dimensions_called_twice(capsys, metric, namespace, service):