diff --git a/build/Common.props b/build/Common.props
index a35274d9ae..20078f7b13 100644
--- a/build/Common.props
+++ b/build/Common.props
@@ -9,6 +9,7 @@
net462
net6.0
netstandard2.0
+ latest-All
diff --git a/build/OpenTelemetryContrib.test.ruleset b/build/OpenTelemetryContrib.test.ruleset
index eabc727093..9818eca018 100644
--- a/build/OpenTelemetryContrib.test.ruleset
+++ b/build/OpenTelemetryContrib.test.ruleset
@@ -4,6 +4,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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)
diff --git a/test/OpenTelemetry.Contrib.Extensions.AWSXRay.Tests/Resources/TestAWSECSResourceDetector.cs b/test/OpenTelemetry.Contrib.Extensions.AWSXRay.Tests/Resources/TestAWSECSResourceDetector.cs
index 4a43a46fd3..53d029ba0d 100644
--- a/test/OpenTelemetry.Contrib.Extensions.AWSXRay.Tests/Resources/TestAWSECSResourceDetector.cs
+++ b/test/OpenTelemetry.Contrib.Extensions.AWSXRay.Tests/Resources/TestAWSECSResourceDetector.cs
@@ -50,7 +50,11 @@ public void Dispose()
[Fact]
public void TestNotOnEcs()
{
- Assert.Empty(new AWSECSResourceDetector().Detect().Attributes);
+ var ecsResourceDetector = new AWSECSResourceDetector();
+ var resourceAttributes = ecsResourceDetector.Detect();
+
+ Assert.NotNull(resourceAttributes);
+ Assert.Empty(resourceAttributes.Attributes);
}
[Fact]
@@ -151,14 +155,14 @@ public MockEcsMetadataEndpoint(string containerJsonPath, string taskJsonPath)
var content = await File.ReadAllTextAsync($"{Environment.CurrentDirectory}/Resources/{containerJsonPath}");
var data = Encoding.UTF8.GetBytes(content);
context.Response.ContentType = "application/json";
- await context.Response.Body.WriteAsync(data, 0, data.Length);
+ await context.Response.Body.WriteAsync(data);
}
else if (context.Request.Method == HttpMethods.Get && context.Request.Path == "/task")
{
var content = await File.ReadAllTextAsync($"{Environment.CurrentDirectory}/Resources/{taskJsonPath}");
var data = Encoding.UTF8.GetBytes(content);
context.Response.ContentType = "application/json";
- await context.Response.Body.WriteAsync(data, 0, data.Length);
+ await context.Response.Body.WriteAsync(data);
}
else
{
diff --git a/test/OpenTelemetry.Contrib.Extensions.AWSXRay.Tests/Resources/TestAWSEKSResourceDetector.cs b/test/OpenTelemetry.Contrib.Extensions.AWSXRay.Tests/Resources/TestAWSEKSResourceDetector.cs
index 55ed6258b7..338ca4aaa2 100644
--- a/test/OpenTelemetry.Contrib.Extensions.AWSXRay.Tests/Resources/TestAWSEKSResourceDetector.cs
+++ b/test/OpenTelemetry.Contrib.Extensions.AWSXRay.Tests/Resources/TestAWSEKSResourceDetector.cs
@@ -28,7 +28,11 @@ public class TestAWSEKSResourceDetector
[Fact]
public void TestDetect()
{
- Assert.Empty(new AWSEKSResourceDetector().Detect().Attributes); // will be null as it's not in eks environment
+ var eksResourceDetector = new AWSEKSResourceDetector();
+ var resourceAttributes = eksResourceDetector.Detect();
+
+ Assert.NotNull(resourceAttributes);
+ Assert.Empty(resourceAttributes.Attributes);
}
[Fact]
diff --git a/test/OpenTelemetry.Contrib.Extensions.AWSXRay.Tests/Trace/TestAWSXRayPropagator.cs b/test/OpenTelemetry.Contrib.Extensions.AWSXRay.Tests/Trace/TestAWSXRayPropagator.cs
index a314b89850..b3a6b4aa35 100644
--- a/test/OpenTelemetry.Contrib.Extensions.AWSXRay.Tests/Trace/TestAWSXRayPropagator.cs
+++ b/test/OpenTelemetry.Contrib.Extensions.AWSXRay.Tests/Trace/TestAWSXRayPropagator.cs
@@ -29,11 +29,7 @@ public class TestAWSXRayPropagator
private const string TraceId = "5759e988bd862e3fe1be46a994272793";
private const string ParentId = "53995c3f42cd8ad8";
-#if NETFRAMEWORK
- private static readonly string[] Empty = new string[0];
-#else
private static readonly string[] Empty = Array.Empty();
-#endif
private static readonly Func, string, IEnumerable> Getter = (headers, name) =>
{