Skip to content

Commit

Permalink
Adopt $(NetFrameworkMinimumSupportedVersion) and fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Mancioppi committed Jan 11, 2023
1 parent 7c7c9c3 commit 212e90a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
<TargetFrameworks>$(NetFrameworkMinimumSupportedVersion);netstandard2.0</TargetFrameworks>
<Description>OpenTelemetry extensions for AWS X-Ray.</Description>
<MinVerTagPrefix>Extensions.AWSXRay-</MinVerTagPrefix>
</PropertyGroup>
Expand All @@ -11,7 +11,7 @@
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<ItemGroup Condition="'$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'">
<Compile Remove="Resources\AWSECSResourceDetector.cs" />
<Compile Remove="Resources\AWSEKSResourceDetector.cs" />
<Compile Remove="Resources\AWSLambdaResourceDetector.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ public IEnumerable<KeyValuePair<string, object>> Detect()
AWSXRayEventSource.Log.ResourceAttributesExtractException(nameof(AWSECSResourceDetector), ex);
}

try
{
resourceAttributes.AddRange(this.ExtractMetadataV4ResourceAttributes());
}
catch (Exception ex)
{
AWSXRayEventSource.Log.ResourceAttributesExtractException(nameof(AWSECSResourceDetector), ex);
}

return resourceAttributes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);$(NetFrameworkMinimumSupportedVersion)</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -20,9 +20,8 @@
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Contrib.Extensions.AWSXRay\OpenTelemetry.Contrib.Extensions.AWSXRay.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' != '$(NetFrameworkMinimumSupportedVersion)'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<Reference Include="System.Net.Http" />
<None Update="Resources\ecs_metadata\metadatav4-response-container-ec2.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand All @@ -37,24 +36,7 @@
</None>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<Reference Include="System.Net.Http" />
<None Update="Resources\ecs_metadata\metadatav4-response-container-ec2.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Resources\ecs_metadata\metadatav4-response-task-ec2.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Resources\ecs_metadata\metadatav4-response-container-fargate.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Resources\ecs_metadata\metadatav4-response-task-fargate.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<ItemGroup Condition="'$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'">
<Compile Remove="Resources\TestAWSECSResourceDetector.cs" />
<Compile Remove="Resources\TestAWSEKSResourceDetector.cs" />
<Compile Remove="Resources\TestAWSLambdaResourceDetector.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http;

using OpenTelemetry.Contrib.Extensions.AWSXRay.Resources;
using Xunit;

namespace OpenTelemetry.Contrib.Extensions.AWSXRay.Tests.Resources;
Expand Down Expand Up @@ -71,8 +73,8 @@ public async void TestEcsMetadataV4Ec2()
await using (var metadataEndpoint = new MockEcsMetadataEndpoint("ecs_metadata/metadatav4-response-container-ec2.json", "ecs_metadata/metadatav4-response-task-ec2.json"))
{
Environment.SetEnvironmentVariable(AWSECSMetadataURLV4Key, metadataEndpoint.Address.ToString());

var resourceAttributes = new AWSECSResourceDetector().Detect().ToDictionary(x => x.Key, x => x.Value);
var tmp = new AWSECSResourceDetector().Detect();
var resourceAttributes = tmp.ToDictionary(x => x.Key, x => x.Value);

Assert.Equal(resourceAttributes[AWSSemanticConventions.AttributeCloudProvider], "aws");
Assert.Equal(resourceAttributes[AWSSemanticConventions.AttributeCloudPlatform], "aws_ecs");
Expand Down

0 comments on commit 212e90a

Please sign in to comment.