Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 70cd5dc

Browse files
add cloudwatch as a static dependency for Lambda API (#3079)
1 parent e8b7076 commit 70cd5dc

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

‎localstack/utils/bootstrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
API_DEPENDENCIES = {
4747
'dynamodbstreams': ['kinesis'],
4848
'es': ['elasticsearch'],
49-
'lambda': ['logs'],
49+
'lambda': ['logs', 'cloudwatch'],
5050
'kinesis': ['dynamodb'],
5151
'firehose': ['kinesis']
5252
}

‎localstack/utils/cloudwatch/cloudwatch_util.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ def publish_lambda_metric(metric, value, kwargs):
2727
if not config.service_port('cloudwatch'):
2828
return
2929
cw_client = aws_stack.connect_to_service('cloudwatch')
30-
cw_client.put_metric_data(Namespace='AWS/Lambda',
31-
MetricData=[{
32-
'MetricName': metric,
33-
'Dimensions': dimension_lambda(kwargs),
34-
'Timestamp': datetime.now(),
35-
'Value': value
36-
}]
37-
)
30+
try:
31+
cw_client.put_metric_data(Namespace='AWS/Lambda',
32+
MetricData=[{
33+
'MetricName': metric,
34+
'Dimensions': dimension_lambda(kwargs),
35+
'Timestamp': datetime.now(),
36+
'Value': value
37+
}]
38+
)
39+
except Exception as e:
40+
LOG.info('Unable to put metric data for metric "%s" to CloudWatch: %s' % (metric, e))
3841

3942

4043
def publish_lambda_duration(time_before, kwargs):

0 commit comments

Comments
 (0)