88using System . IO ;
99using Microsoft . DotNet . Configurer ;
1010using System . Linq ;
11+ using RuntimeEnvironment = Microsoft . DotNet . PlatformAbstractions . RuntimeEnvironment ;
12+ using RuntimeInformation = System . Runtime . InteropServices . RuntimeInformation ;
1113
1214namespace Microsoft . DotNet . Cli . Telemetry
1315{
@@ -40,6 +42,8 @@ public TelemetryCommonProperties(
4042 private const string CurrentPathHash = "Current Path Hash" ;
4143 private const string MachineId = "Machine ID" ;
4244 private const string DockerContainer = "Docker Container" ;
45+ private const string KernelVersion = "Kernel Version" ;
46+
4347 private const string TelemetryProfileEnvironmentVariable = "DOTNET_CLI_TELEMETRY_PROFILE" ;
4448 private const string CannotFindMacAddress = "Unknown" ;
4549
@@ -57,7 +61,8 @@ public Dictionary<string, string> GetTelemetryCommonProperties()
5761 { TelemetryProfile , Environment . GetEnvironmentVariable ( TelemetryProfileEnvironmentVariable ) } ,
5862 { DockerContainer , _userLevelCacheWriter . RunWithCache ( IsDockerContainerCacheKey , ( ) => _dockerContainerDetector . IsDockerContainer ( ) . ToString ( "G" ) ) } ,
5963 { CurrentPathHash , _hasher ( _getCurrentDirectory ( ) ) } ,
60- { MachineId , _userLevelCacheWriter . RunWithCache ( MachineIdCacheKey , GetMachineId ) }
64+ { MachineId , _userLevelCacheWriter . RunWithCache ( MachineIdCacheKey , GetMachineId ) } ,
65+ { KernelVersion , GetKernelVersion ( ) }
6166 } ;
6267 }
6368
@@ -73,5 +78,44 @@ private string GetMachineId()
7378 return Guid . NewGuid ( ) . ToString ( ) ;
7479 }
7580 }
81+
82+ /// <summary>
83+ /// Returns a string identifying the OS kernel.
84+ /// For Unix this currently comes from "uname -srv".
85+ /// For Windows this currently comes from RtlGetVersion().
86+ ///
87+ /// Here are some example values:
88+ ///
89+ /// Alpine.36 Linux 4.9.60-linuxkit-aufs #1 SMP Mon Nov 6 16:00:12 UTC 2017
90+ /// Centos.73 Linux 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017
91+ /// Debian.87 Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07)
92+ /// Debian.90 Linux 4.9.0-2-amd64 #1 SMP Debian 4.9.18-1 (2017-03-30)
93+ /// fedora.25 Linux 4.11.3-202.fc25.x86_64 #1 SMP Mon Jun 5 16:38:21 UTC 2017
94+ /// Fedora.26 Linux 4.14.15-200.fc26.x86_64 #1 SMP Wed Jan 24 04:26:15 UTC 2018
95+ /// Fedora.27 Linux 4.14.14-300.fc27.x86_64 #1 SMP Fri Jan 19 13:19:54 UTC 2018
96+ /// OpenSuse.423 Linux 4.4.104-39-default #1 SMP Thu Jan 4 08:11:03 UTC 2018 (7db1912)
97+ /// RedHat.69 Linux 2.6.32-696.20.1.el6.x86_64 #1 SMP Fri Jan 12 15:07:59 EST 2018
98+ /// RedHat.72 Linux 3.10.0-514.21.1.el7.x86_64 #1 SMP Sat Apr 22 02:41:35 EDT 2017
99+ /// RedHat.73 Linux 3.10.0-514.21.1.el7.x86_64 #1 SMP Sat Apr 22 02:41:35 EDT 2017
100+ /// SLES.12 Linux 4.4.103-6.38-default #1 SMP Mon Dec 25 20:44:33 UTC 2017 (e4b9067)
101+ /// suse.422 Linux 4.4.49-16-default #1 SMP Sun Feb 19 17:40:35 UTC 2017 (70e9954)
102+ /// Ubuntu.1404 Linux 3.19.0-65-generic #73~14.04.1-Ubuntu SMP Wed Jun 29 21:05:22 UTC 2016
103+ /// Ubuntu.1604 Linux 4.13.0-1005-azure #7-Ubuntu SMP Mon Jan 8 21:37:36 UTC 2018
104+ /// Ubuntu.1604.WSL Linux 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014
105+ /// Ubuntu.1610 Linux 4.8.0-45-generic #48-Ubuntu SMP Fri Mar 24 11:46:39 UTC 2017
106+ /// Ubuntu.1704 Linux 4.10.0-19-generic #21-Ubuntu SMP Thu Apr 6 17:04:57 UTC 2017
107+ /// Ubuntu.1710 Linux 4.13.0-25-generic #29-Ubuntu SMP Mon Jan 8 21:14:41 UTC 2018
108+ /// OSX1012 Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jan 11 22:59:40 PST 2018; root:xnu-3789.73.8~1/RELEASE_X86_64
109+ /// OSX1013 Darwin 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64
110+ /// Windows.10 Microsoft Windows 10.0.14393
111+ /// Windows.10.Core Microsoft Windows 10.0.14393
112+ /// Windows.10.Nano Microsoft Windows 10.0.14393
113+ /// Windows.7 Microsoft Windows 6.1.7601 S
114+ /// Windows.81 Microsoft Windows 6.3.9600
115+ /// </summary>
116+ private static string GetKernelVersion ( )
117+ {
118+ return RuntimeInformation . OSDescription ;
119+ }
76120 }
77121}
0 commit comments