diff --git a/src/OpenTelemetry.Contrib.Extensions.AWSXRay/Resources/AWSECSResourceDetector.cs b/src/OpenTelemetry.Contrib.Extensions.AWSXRay/Resources/AWSECSResourceDetector.cs index d252b35bb7..0379246622 100644 --- a/src/OpenTelemetry.Contrib.Extensions.AWSXRay/Resources/AWSECSResourceDetector.cs +++ b/src/OpenTelemetry.Contrib.Extensions.AWSXRay/Resources/AWSECSResourceDetector.cs @@ -84,7 +84,7 @@ internal static List> ExtractMetadataV4ResourceAttr return new List>(); } - var httpClientHandler = new HttpClientHandler(); + using var httpClientHandler = new HttpClientHandler(); var metadataV4ContainerResponse = ResourceDetectorUtils.SendOutRequest(metadataV4Url, "GET", null, httpClientHandler).Result; var metadataV4TaskResponse = ResourceDetectorUtils.SendOutRequest($"{metadataV4Url.TrimEnd('/')}/task", "GET", null, httpClientHandler).Result; @@ -105,9 +105,9 @@ internal static List> ExtractMetadataV4ResourceAttr return new List>(); } - if (!clusterArn.StartsWith("arn:")) + if (!clusterArn.StartsWith("arn:", StringComparison.Ordinal)) { - var baseArn = containerArn.Substring(containerArn.LastIndexOf(":")); + var baseArn = containerArn.Substring(containerArn.LastIndexOf(":", StringComparison.Ordinal)); clusterArn = $"{baseArn}:cluster/{clusterArn}"; } @@ -119,8 +119,8 @@ internal static List> ExtractMetadataV4ResourceAttr var launchType = taskResponse.Value("LaunchType") switch { - string type when "ec2".Equals(type.ToLower()) => AWSSemanticConventions.ValueEcsLaunchTypeEc2, - string type when "fargate".Equals(type.ToLower()) => AWSSemanticConventions.ValueEcsLaunchTypeFargate, + string type when string.Equals("ec2", type, StringComparison.OrdinalIgnoreCase) => AWSSemanticConventions.ValueEcsLaunchTypeEc2, + string type when string.Equals("fargate", type, StringComparison.OrdinalIgnoreCase) => AWSSemanticConventions.ValueEcsLaunchTypeFargate, _ => null, }; @@ -151,7 +151,7 @@ internal static List> ExtractMetadataV4ResourceAttr resourceAttributes.Add(new KeyValuePair(AWSSemanticConventions.AttributeEcsTaskRevision, revision)); } - if ("awslogs".Equals(containerResponse.Value("LogDriver"))) + if (string.Equals("awslogs", containerResponse.Value("LogDriver"), StringComparison.Ordinal)) { JObject? logOptions = containerResponse.Value("LogOptions"); if (logOptions != null)