Skip to content

Commit e474b3c

Browse files
authored
Merge pull request #272 from DataDog/jordan.storms/add_memorysize_tag_to_enhanced_metrics
Add memorysize tag to enhanced metrics
2 parents a75fcae + 4df0c49 commit e474b3c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

aws/logs_monitoring/enhanced_lambda_metrics.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
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 = [
46+
MEMORY_ALLOCATED_FIELD_NAME,
47+
]
48+
4449
METRICS_TO_PARSE_FROM_REPORT = [
4550
DURATION_METRIC_NAME,
4651
BILLED_DURATION_METRIC_NAME,
@@ -440,6 +445,11 @@ def parse_metrics_from_report_log(report_log_line):
440445
return []
441446

442447
metrics = []
448+
tags = []
449+
450+
# loop is to account for adding cold start
451+
for tag in TAGS_TO_PARSE_FROM_REPORT:
452+
tags.append(tag + ":" + regex_match.group(tag))
443453

444454
for metric_name in METRICS_TO_PARSE_FROM_REPORT:
445455
metric_point_value = float(regex_match.group(metric_name))
@@ -451,6 +461,10 @@ def parse_metrics_from_report_log(report_log_line):
451461
"{}.{}".format(ENHANCED_METRICS_NAMESPACE_PREFIX, metric_name),
452462
metric_point_value,
453463
)
464+
465+
if tags:
466+
dd_metric.add_tags(tags)
467+
454468
metrics.append(dd_metric)
455469

456470
estimated_cost_metric_point = DatadogMetricPoint(
@@ -460,6 +474,10 @@ def parse_metrics_from_report_log(report_log_line):
460474
float(regex_match.group(MEMORY_ALLOCATED_FIELD_NAME)),
461475
),
462476
)
477+
478+
if tags:
479+
estimated_cost_metric_point.add_tags(tags)
480+
463481
metrics.append(estimated_cost_metric_point)
464482

465483
return metrics

0 commit comments

Comments
 (0)