Skip to content

Commit b6b8f75

Browse files
committed
add memorysize tag to enhanced metrics
1 parent a75fcae commit b6b8f75

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

aws/logs_monitoring/enhanced_lambda_metrics.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
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]
46+
4447
METRICS_TO_PARSE_FROM_REPORT = [
4548
DURATION_METRIC_NAME,
4649
BILLED_DURATION_METRIC_NAME,
@@ -440,6 +443,11 @@ def parse_metrics_from_report_log(report_log_line):
440443
return []
441444

442445
metrics = []
446+
tags = []
447+
448+
#loop is to account for adding cold start
449+
for tag in TAGS_TO_PARSE_FROM_REPORT:
450+
tags.append(tag + ':' + regex_match.group(tag))
443451

444452
for metric_name in METRICS_TO_PARSE_FROM_REPORT:
445453
metric_point_value = float(regex_match.group(metric_name))
@@ -451,6 +459,10 @@ def parse_metrics_from_report_log(report_log_line):
451459
"{}.{}".format(ENHANCED_METRICS_NAMESPACE_PREFIX, metric_name),
452460
metric_point_value,
453461
)
462+
463+
if tags:
464+
dd_metric.add_tags(tags)
465+
454466
metrics.append(dd_metric)
455467

456468
estimated_cost_metric_point = DatadogMetricPoint(
@@ -460,6 +472,10 @@ def parse_metrics_from_report_log(report_log_line):
460472
float(regex_match.group(MEMORY_ALLOCATED_FIELD_NAME)),
461473
),
462474
)
475+
476+
if tags:
477+
estimated_cost_metric_point.add_tags(tags)
478+
463479
metrics.append(estimated_cost_metric_point)
464480

465481
return metrics

0 commit comments

Comments
 (0)