awslabs / awslabs/aws-embedded-metrics-python
Calling MetricsLogger.flush() causes RuntimeWarnings
- Dominant language
- Python
- Stars
- 231
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Description
Calling `MetricsLogger().flush()` as documented in the README causes RuntimeWarnings:
Here is a minimal example:
```python
#!/usr/bin/env python3
import os
os.environ["AWS_LAMBDA_FUNCTION_NAME"] = "dummy-function-name"
from aws_embedded_metrics import metric_scope
@metric_scope
def foo(metrics):
metrics.put_metric("foo", 1, "Count")
metrics.flush()
foo()
```
Output when calling:
```
./poc.py:11: RuntimeWarning: coroutine 'MetricsLogger.flush' was never awaited
metrics.flush()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
{"LogGroup": "dummy-function-name", "ServiceName": "dummy-function-name", "ServiceType": "AWS::Lambda::Function", "executionEnvironment": "", "memorySize": "", "functionVersion": "", "logStreamId": "", "_aws": {"Timestamp": 1598540408195, "CloudWatchMetrics": [{"Dimensions": [["LogGroup", "ServiceName", "ServiceType"]], "Metrics": [{"Name": "foo", "Unit": "Count"}], "Namespace": "aws-embedded-metrics"}]}, "foo": 1}
```
Contributor guide
Assessment
This issue has not been assessed yet.