You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core/metrics.md
+40-3
Original file line number
Diff line number
Diff line change
@@ -391,11 +391,11 @@ If you prefer setting environment variable for specific tests, and are using Pyt
391
391
yield
392
392
```
393
393
394
-
### Inspecting metrics
394
+
### Functional testing
395
395
396
-
As metrics are logged to standard output, you can read stdoutput and assert whether metrics are present. Here's an example using `pytest` with `capsys` built-in fixture:
396
+
As metrics are logged to standard output, you can read standard output and assert whether metrics are present. Here's an example using `pytest` with `capsys` built-in fixture:
397
397
398
-
=== "pytest_metrics_assertion.py"
398
+
=== "Assert single EMF blob with pytest.py"
399
399
400
400
```python hl_lines="6 9-10 23-34"
401
401
from aws_lambda_powertools import Metrics
@@ -424,4 +424,41 @@ As metrics are logged to standard output, you can read stdoutput and assert whet
424
424
assert "SuccessfulBooking" in metrics_output["_aws"]["CloudWatchMetrics"][0]["Metrics"][0]["Name"]
425
425
```
426
426
427
+
=== "Assert multiple EMF blobs with pytest"
428
+
429
+
```python hl_lines="8-9 11 21-23 25 29-30 32"
430
+
from aws_lambda_powertools import Metrics
431
+
from aws_lambda_powertools.metrics import MetricUnit
assert "SuccessfulBooking" in custom_metrics_blob # as per previous example
462
+
```
463
+
427
464
!!! tip "For more elaborate assertions and comparisons, check out [our functional testing for Metrics utility](https://github.com/awslabs/aws-lambda-powertools-python/blob/develop/tests/functional/test_metrics.py)"
0 commit comments