awslabs / awslabs/aws-embedded-metrics-python

Don't generate output without metrics

Open
#51 10 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
231
Forks
44
PR merge metrics
No merged PRs in 30d

Description

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

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

foo()
```

I'd expect no output from this script, however this is what I get (pretty-printed for better readabillity):
```json
{
"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.

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.