Skip to content

Don't generate output without metrics #51

Open
@Dunedan

Description

@Dunedan

When initializing a metrics context, but not emitting metrics, aws-embedded-metrics still generates output.

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):
    pass

foo()

I'd expect no output from this script, however this is what I get (pretty-printed for better readabillity):

{
    "LogGroup": "dummy-function-name",
    "ServiceName": "dummy-function-name",
    "ServiceType": "AWS::Lambda::Function",
    "executionEnvironment": "",
    "memorySize": "",
    "functionVersion": "",
    "logStreamId": "",
    "_aws": {
        "Timestamp": 1598537498307,
        "CloudWatchMetrics": [
            {
                "Dimensions": [
                    [
                        "LogGroup",
                        "ServiceName",
                        "ServiceType"
                    ]
                ],
                "Metrics": [],
                "Namespace": "aws-embedded-metrics"
            }
        ]
    }
}

I believe this behavior is unintended and I see not much benefit in such output without actual metrics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions