Skip to content

Calling MetricsLogger.flush() causes RuntimeWarnings #52

Open
@Dunedan

Description

@Dunedan

Calling MetricsLogger().flush() as documented in the README causes RuntimeWarnings:

Here is a minimal example:

#!/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}

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions