diff --git a/src/Management/src/Endpoint/Actuators/Info/Contributors/RuntimeInfoContributor.cs b/src/Management/src/Endpoint/Actuators/Info/Contributors/RuntimeInfoContributor.cs new file mode 100644 index 0000000000..dc940d8a8b --- /dev/null +++ b/src/Management/src/Endpoint/Actuators/Info/Contributors/RuntimeInfoContributor.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; + +namespace Steeltoe.Management.Endpoint.Actuators.Info.Contributors; + +internal sealed class RuntimeInfoContributor : IInfoContributor +{ + public Task ContributeAsync(InfoBuilder builder, CancellationToken cancellationToken) + { + ArgumentNullException.ThrowIfNull(builder); + + builder.WithInfo("runtime", new Dictionary + { + ["runtimeName"] = RuntimeInformation.FrameworkDescription, + ["runtimeVersion"] = System.Environment.Version.ToString(), + ["runtimeIdentifier"] = RuntimeInformation.RuntimeIdentifier, + ["processArchitecture"] = RuntimeInformation.ProcessArchitecture.ToString(), + ["osArchitecture"] = RuntimeInformation.OSArchitecture.ToString(), + ["osDescription"] = RuntimeInformation.OSDescription, + ["osVersion"] = System.Environment.OSVersion.ToString() + }); + + return Task.CompletedTask; + } +} diff --git a/src/Management/src/Endpoint/Actuators/Info/EndpointServiceCollectionExtensions.cs b/src/Management/src/Endpoint/Actuators/Info/EndpointServiceCollectionExtensions.cs index dd699748b6..93bca54b2e 100644 --- a/src/Management/src/Endpoint/Actuators/Info/EndpointServiceCollectionExtensions.cs +++ b/src/Management/src/Endpoint/Actuators/Info/EndpointServiceCollectionExtensions.cs @@ -54,6 +54,7 @@ private static void RegisterDefaultInfoContributors(IServiceCollection services) services.TryAddEnumerable(ServiceDescriptor.Singleton()); services.TryAddEnumerable(ServiceDescriptor.Singleton()); services.TryAddEnumerable(ServiceDescriptor.Singleton()); + services.TryAddEnumerable(ServiceDescriptor.Singleton()); } /// diff --git a/src/Management/test/Endpoint.Test/Actuators/Info/InfoActuatorTest.cs b/src/Management/test/Endpoint.Test/Actuators/Info/InfoActuatorTest.cs index 56350212d3..7d7756a273 100644 --- a/src/Management/test/Endpoint.Test/Actuators/Info/InfoActuatorTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/Info/InfoActuatorTest.cs @@ -4,6 +4,7 @@ using System.Net; using System.Reflection; +using System.Runtime.InteropServices; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.Configuration; @@ -33,6 +34,13 @@ public sealed class InfoActuatorTest private static readonly Assembly SteeltoeAssembly = typeof(IInfoContributor).Assembly; private static readonly string SteeltoeFileVersion = SteeltoeAssembly.GetCustomAttribute()!.Version; private static readonly string SteeltoeProductVersion = SteeltoeAssembly.GetCustomAttribute()!.InformationalVersion; + private static readonly string RuntimeName = RuntimeInformation.FrameworkDescription; + private static readonly string RuntimeVersion = System.Environment.Version.ToString(); + private static readonly string RuntimeIdentifier = RuntimeInformation.RuntimeIdentifier; + private static readonly string ProcessArchitecture = RuntimeInformation.ProcessArchitecture.ToString(); + private static readonly string OSArchitecture = RuntimeInformation.OSArchitecture.ToString(); + private static readonly string OSDescription = RuntimeInformation.OSDescription; + private static readonly string OSVersion = System.Environment.OSVersion.ToString(); [Fact] public async Task Registers_dependent_services() @@ -184,6 +192,15 @@ public async Task Endpoint_returns_expected_data(HostBuilderType hostBuilderType }, "build": { "version": "{{AppAssemblyVersion}}" + }, + "runtime": { + "runtimeName": "{{RuntimeName}}", + "runtimeVersion": "{{RuntimeVersion}}", + "runtimeIdentifier": "{{RuntimeIdentifier}}", + "processArchitecture": "{{ProcessArchitecture}}", + "osArchitecture": "{{OSArchitecture}}", + "osDescription": "{{OSDescription}}", + "osVersion": "{{OSVersion}}" } } """); diff --git a/src/Steeltoe.All.sln.DotSettings b/src/Steeltoe.All.sln.DotSettings index a27b0a5ed6..112d0c37d2 100644 --- a/src/Steeltoe.All.sln.DotSettings +++ b/src/Steeltoe.All.sln.DotSettings @@ -604,6 +604,7 @@ See the LICENSE file in the project root for more information. IO IP MQ + OS OSX UAA False