Skip to content

Commit 82b253b

Browse files
committed
fixed formatting
1 parent b6b8f75 commit 82b253b

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

aws/logs_monitoring/enhanced_lambda_metrics.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@
4141
+ r"Max\s+Memory\s+Used:\s+(?P<{}>\d+)\s+MB".format(MAX_MEMORY_USED_METRIC_NAME)
4242
)
4343

44-
#Pull memorysize tag and cold start from report
45-
TAGS_TO_PARSE_FROM_REPORT = [MEMORY_ALLOCATED_FIELD_NAME]
44+
# Pull memorysize tag and cold start from report
45+
TAGS_TO_PARSE_FROM_REPORT = [
46+
MEMORY_ALLOCATED_FIELD_NAME,
47+
]
4648

4749
METRICS_TO_PARSE_FROM_REPORT = [
4850
DURATION_METRIC_NAME,
@@ -184,7 +186,8 @@ def submit_to_dd(self):
184186
if not timestamp:
185187
timestamp = time()
186188

187-
log.debug("Submitting metric {} {} {}".format(self.name, self.value, self.tags))
189+
log.debug("Submitting metric {} {} {}".format(
190+
self.name, self.value, self.tags))
188191
lambda_stats.distribution(
189192
self.name, self.value, timestamp=timestamp, tags=self.tags
190193
)
@@ -244,7 +247,8 @@ def get_dd_tag_string_from_aws_dict(aws_key_value_tag_dict):
244247
key:value colon-separated string built from the dict
245248
ex: "creator:swf"
246249
"""
247-
key = sanitize_aws_tag_string(aws_key_value_tag_dict["Key"], remove_colons=True)
250+
key = sanitize_aws_tag_string(
251+
aws_key_value_tag_dict["Key"], remove_colons=True)
248252
value = sanitize_aws_tag_string(aws_key_value_tag_dict.get("Value"))
249253
# Value is optional in DD and AWS
250254
if not value:
@@ -290,17 +294,21 @@ def build_tags_by_arn_cache():
290294
tags_by_arn_cache (dict<str, str[]>): each Lambda's tags in a dict keyed by ARN
291295
"""
292296
tags_by_arn_cache = {}
293-
get_resources_paginator = resource_tagging_client.get_paginator("get_resources")
297+
get_resources_paginator = resource_tagging_client.get_paginator(
298+
"get_resources")
294299

295300
try:
296301
for page in get_resources_paginator.paginate(
297-
ResourceTypeFilters=[GET_RESOURCES_LAMBDA_FILTER], ResourcesPerPage=100
302+
ResourceTypeFilters=[
303+
GET_RESOURCES_LAMBDA_FILTER], ResourcesPerPage=100
298304
):
299305
lambda_stats.distribution(
300-
"{}.get_resources_api_calls".format(ENHANCED_METRICS_NAMESPACE_PREFIX),
306+
"{}.get_resources_api_calls".format(
307+
ENHANCED_METRICS_NAMESPACE_PREFIX),
301308
1,
302309
)
303-
page_tags_by_arn = parse_get_resources_response_for_tags_by_arn(page)
310+
page_tags_by_arn = parse_get_resources_response_for_tags_by_arn(
311+
page)
304312
tags_by_arn_cache.update(page_tags_by_arn)
305313

306314
except ClientError:
@@ -445,7 +453,7 @@ def parse_metrics_from_report_log(report_log_line):
445453
metrics = []
446454
tags = []
447455

448-
#loop is to account for adding cold start
456+
# loop is to account for adding cold start
449457
for tag in TAGS_TO_PARSE_FROM_REPORT:
450458
tags.append(tag + ':' + regex_match.group(tag))
451459

@@ -466,13 +474,14 @@ def parse_metrics_from_report_log(report_log_line):
466474
metrics.append(dd_metric)
467475

468476
estimated_cost_metric_point = DatadogMetricPoint(
469-
"{}.{}".format(ENHANCED_METRICS_NAMESPACE_PREFIX, ESTIMATED_COST_METRIC_NAME),
477+
"{}.{}".format(ENHANCED_METRICS_NAMESPACE_PREFIX,
478+
ESTIMATED_COST_METRIC_NAME),
470479
calculate_estimated_cost(
471480
float(regex_match.group(BILLED_DURATION_METRIC_NAME)),
472481
float(regex_match.group(MEMORY_ALLOCATED_FIELD_NAME)),
473482
),
474483
)
475-
484+
476485
if tags:
477486
estimated_cost_metric_point.add_tags(tags)
478487

0 commit comments

Comments
 (0)