Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case insensitive service provider #1478

Merged
merged 3 commits into from
Dec 23, 2024

Conversation

chadpatel
Copy link
Contributor

@chadpatel chadpatel commented Dec 19, 2024

Description of the issue

The application, app and service service name provider ec2 tags are currently case sensitive, there are also bugs in exactness in how these are being compared due to excessive use of strings.Contains

Description of changes

Update InstanceTags to return a []string with the tag keys instead of the raw newline delimited list. This is a more friendly API to reason about. We can then convert it to a map with lowercase keys that we use for comparison.

I also fixed the asg lookup to also be an exact match instead. These matches are relatively efficient as I am converting the arrays to maps for O(1) lookups instead of having to repeatedly loop through the whole strings using Contains or slices.Contains

Related to: #1474

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Unit tests updated

Pooja tested manually for me on her cluster

Key
	
Value

APPLICATION
poojardy_test_application
Field	Value
@entity.Attributes.AWS.ServiceNameSource	
ResourceTags
@entity.Attributes.EC2.AutoScalingGroup	
asg-compass
@entity.Attributes.EC2.InstanceId	
i-0b6fe6aab9e76873b
@entity.Attributes.PlatformType	
AWS::EC2
@entity.KeyAttributes.Environment	
ec2:asg-compass
@entity.KeyAttributes.Name	
poojardy_test_application
@entity.KeyAttributes.Type	
Service
@ingestionTime	
1734719476173
@log	
957688854012:agent_log_group
@logStream	
agent_log_stream
@message	
2024-12-20T18:31:14Z I! CWAGENT_LOG_LEVEL is set to "DEBUG"
@timestamp	
1734719475179

Key
	
Value

APP
app_testing

1
2024-12-20T18:34:55.016Z
2024-12-20T18:34:53Z D! [logagent] open file count, 1
Field	Value
@entity.Attributes.AWS.ServiceNameSource	
ResourceTags
@entity.Attributes.EC2.AutoScalingGroup	
asg-compass
@entity.Attributes.EC2.InstanceId	
i-0b6fe6aab9e76873b
@entity.Attributes.PlatformType	
AWS::EC2
@entity.KeyAttributes.Environment	
ec2:asg-compass
@entity.KeyAttributes.Name	
app_testing
@entity.KeyAttributes.Type	
Service
@ingestionTime	
1734719695505
@log	
957688854012:agent_log_group
@logStream	
agent_log_stream
@message	
2024-12-20T18:34:53Z D! [logagent] open file count, 1
@timestamp	
1734719695016

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh -- done
  2. Run make lint

@chadpatel chadpatel requested a review from a team as a code owner December 19, 2024 22:34
@chadpatel chadpatel changed the title Patchad case insensitive service provider Case insensitive service provider Dec 23, 2024
@chadpatel chadpatel merged commit 03cbd6b into main Dec 23, 2024
7 checks passed
@chadpatel chadpatel deleted the patchad-case-insensitive-service-provider branch December 23, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants