Skip to content

Commit

Permalink
use .net framework version instead of Clr profiler version
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek committed Nov 30, 2023
1 parent e2d00e1 commit 4c89888
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@ public class ProcessRuntimeDetector : IResourceDetector
/// <returns>Resource with key-value pairs of resource attributes.</returns>
public Resource Detect()
{
#if NETFRAMEWORK
var frameworkDescriptionParts = RuntimeInformation.FrameworkDescription.Split(' ');
var netFrameworkVersion = frameworkDescriptionParts.Length > 1 ? frameworkDescriptionParts[frameworkDescriptionParts.Length - 1] : "unknown";
#endif

return new Resource(new List<KeyValuePair<string, object>>(3)
{
new(ProcessRuntimeSemanticConventions.AttributeProcessRuntimeDescription, RuntimeInformation.FrameworkDescription),
#if NETFRAMEWORK
new(ProcessRuntimeSemanticConventions.AttributeProcessRuntimeName, ".NET Framework"),
new(ProcessRuntimeSemanticConventions.AttributeProcessRuntimeVersion, netFrameworkVersion),
#else
new(ProcessRuntimeSemanticConventions.AttributeProcessRuntimeName, ".NET"),
#endif
new(ProcessRuntimeSemanticConventions.AttributeProcessRuntimeVersion, Environment.Version.ToString()),
#endif
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void TestProcessRuntimeAttributes()
#if NETFRAMEWORK
Assert.Matches(@"^\.NET Framework \d+\.\d+\.\d+\.\d+$", resourceAttributes[ProcessRuntimeSemanticConventions.AttributeProcessRuntimeDescription]);
Assert.Equal(".NET Framework", resourceAttributes[ProcessRuntimeSemanticConventions.AttributeProcessRuntimeName]);
Assert.Matches(@"^\d+\.\d+\.\d+\.\d+$", resourceAttributes[ProcessRuntimeSemanticConventions.AttributeProcessRuntimeVersion]);
Assert.Matches(@"^4.[1-9]\d*\.\d+\.\d+$", resourceAttributes[ProcessRuntimeSemanticConventions.AttributeProcessRuntimeVersion]);
#else
Assert.Matches(@"^\.NET \d+\.\d+\.\d+$", resourceAttributes[ProcessRuntimeSemanticConventions.AttributeProcessRuntimeDescription]);
Assert.Equal(".NET", resourceAttributes[ProcessRuntimeSemanticConventions.AttributeProcessRuntimeName]);
Expand Down

0 comments on commit 4c89888

Please sign in to comment.