@@ -118,6 +118,11 @@ def get(self, resource_arn):
118118 Will refetch the tags if they are out of date, or a lambda arn is encountered
119119 which isn't in the tag list
120120
121+ Note: the ARNs in the cache have been lowercased, so resource_arn must be lowercased
122+
123+ Args:
124+ resource_arn (str): the arn we're getting tags from the cache for
125+
121126 Returns:
122127 lambda_tags (str[]): the list of "key:value" Datadog tag strings
123128 """
@@ -263,10 +268,12 @@ def parse_get_resources_response_for_tags_by_arn(get_resources_page):
263268 aws_resouce_tag_mappings = get_resources_page ["ResourceTagMappingList" ]
264269 for aws_resource_tag_mapping in aws_resouce_tag_mappings :
265270 function_arn = aws_resource_tag_mapping ["ResourceARN" ]
271+ lowercase_function_arn = function_arn .lower ()
272+
266273 raw_aws_tags = aws_resource_tag_mapping ["Tags" ]
267274 tags = map (get_dd_tag_string_from_aws_dict , raw_aws_tags )
268275
269- tags_by_arn [function_arn ] += tags
276+ tags_by_arn [lowercase_function_arn ] += tags
270277
271278 return tags_by_arn
272279
@@ -363,6 +370,7 @@ def generate_enhanced_lambda_metrics(log, tags_cache):
363370 Returns:
364371 DatadogMetricPoint[], where each metric has all of its tags
365372 """
373+ # Note: this arn attribute is always lowercased when it's created
366374 log_function_arn = log .get ("lambda" , {}).get ("arn" )
367375 log_message = log .get ("message" )
368376 timestamp = log .get ("timestamp" )
@@ -472,17 +480,20 @@ def calculate_estimated_cost(billed_duration_ms, memory_allocated):
472480 return BASE_LAMBDA_INVOCATION_PRICE + gb_seconds * LAMBDA_PRICE_PER_GB_SECOND
473481
474482
475- def get_enriched_lambda_log_tags (log ):
483+ def get_enriched_lambda_log_tags (log_event ):
476484 """ Retrieves extra tags from lambda, either read from the function arn, or by fetching lambda tags from the function itself.
477485
478486 Args:
479487 log (dict<str, str | dict | int>): a log parsed from the event in the split method
480488 """
481- log_function_arn = log .get ("lambda" , {}).get ("arn" )
489+ # Note that this arn attribute has been lowercased already
490+ log_function_arn = log_event .get ("lambda" , {}).get ("arn" )
491+
482492 if not log_function_arn :
483493 return []
484494 tags_from_arn = parse_lambda_tags_from_arn (log_function_arn )
485495 lambda_custom_tags = account_lambda_tags_cache .get (log_function_arn )
496+
486497 # Combine and dedup tags
487498 tags = list (set (tags_from_arn + lambda_custom_tags ))
488499 return tags
0 commit comments