4f04e9e1b5
* add metrics to host apps * merge fixes and compiles * Use ME.Console and OTel for logging to correlate * clean up * clean up for metrics * fix self-review comments * fix seq initialization * clean up for http traces and rhino 8 * use latest SDK * formatting
44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using System.Runtime.InteropServices;
|
|
using OpenTelemetry.Resources;
|
|
|
|
namespace Speckle.Connectors.Logging.Internal;
|
|
|
|
internal static class ResourceCreator
|
|
{
|
|
internal static ResourceBuilder Create(string applicationAndVersion, string slug, string connectorVersion) =>
|
|
ResourceBuilder
|
|
.CreateEmpty()
|
|
.AddService(serviceName: Consts.TRACING_SOURCE, serviceVersion: connectorVersion)
|
|
.AddAttributes(
|
|
new List<KeyValuePair<string, object>>
|
|
{
|
|
new(Consts.SERVICE_NAME, applicationAndVersion),
|
|
new(Consts.SERVICE_SLUG, slug),
|
|
new(Consts.OS_NAME, Environment.OSVersion.ToString()),
|
|
new(Consts.OS_TYPE, RuntimeInformation.ProcessArchitecture.ToString()),
|
|
new(Consts.OS_SLUG, DetermineHostOsSlug()),
|
|
new(Consts.RUNTIME_NAME, RuntimeInformation.FrameworkDescription)
|
|
}
|
|
);
|
|
|
|
private static string DetermineHostOsSlug()
|
|
{
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
{
|
|
return "Windows";
|
|
}
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
|
{
|
|
return "MacOS";
|
|
}
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
{
|
|
return "Linux";
|
|
}
|
|
|
|
return RuntimeInformation.OSDescription;
|
|
}
|
|
}
|