awslabs / awslabs/aws-embedded-metrics-python

Calling MetricsLogger.flush() causes RuntimeWarnings

Open
#52 10 comments 2 reactions 0 assignees View on GitHub
documentation
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.