From 198abe4ab63d92254a218a70a2edce11cb592a1d Mon Sep 17 00:00:00 2001 From: christianwade Date: Thu, 6 Dec 2018 19:59:49 -0800 Subject: [PATCH] telemetry --- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../BismNormalizerTests.cs | 4 +- .../BismNormalizer.Tests/Settings.Designer.cs | 38 +++++++++++ .../BismNormalizer.Tests/Settings.settings | 9 +++ .../BismNormalizer.Tests/Test1103.bsmn | 4 +- .../BismNormalizer.Tests/Test1200.bsmn | 4 +- .../BismNormalizer.Tests/TestPrep.ps1 | 2 +- .../BismNormalizer.Tests/app.config | 15 +++++ .../BismNormalizer/BismNormalizer.csproj | 48 ++++++++++--- .../BismNormalizer/Properties/AssemblyInfo.cs | 4 +- .../TabularCompare/ComparisonFactory.cs | 2 + .../TabularCompare/Telemetry.cs | 67 +++++++++++++++++++ BismNormalizer/BismNormalizer/packages.config | 9 ++- .../source.extension.vsixmanifest | 2 +- 15 files changed, 191 insertions(+), 25 deletions(-) create mode 100644 BismNormalizer/BismNormalizer.Tests/Settings.Designer.cs create mode 100644 BismNormalizer/BismNormalizer.Tests/Settings.settings create mode 100644 BismNormalizer/BismNormalizer.Tests/app.config create mode 100644 BismNormalizer/BismNormalizer/TabularCompare/Telemetry.cs diff --git a/BismNormalizer/BismNormalizer.CommandLine/Properties/AssemblyInfo.cs b/BismNormalizer/BismNormalizer.CommandLine/Properties/AssemblyInfo.cs index 91048c3..d9d4cf0 100644 --- a/BismNormalizer/BismNormalizer.CommandLine/Properties/AssemblyInfo.cs +++ b/BismNormalizer/BismNormalizer.CommandLine/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("4.0.0.29")] -[assembly: AssemblyFileVersion("4.0.0.29")] +[assembly: AssemblyVersion("4.0.0.30")] +[assembly: AssemblyFileVersion("4.0.0.30")] diff --git a/BismNormalizer/BismNormalizer.IconSetup/Properties/AssemblyInfo.cs b/BismNormalizer/BismNormalizer.IconSetup/Properties/AssemblyInfo.cs index 7501c11..1834d19 100644 --- a/BismNormalizer/BismNormalizer.IconSetup/Properties/AssemblyInfo.cs +++ b/BismNormalizer/BismNormalizer.IconSetup/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("4.0.0.29")] -[assembly: AssemblyFileVersion("4.0.0.29")] +[assembly: AssemblyVersion("4.0.0.30")] +[assembly: AssemblyFileVersion("4.0.0.30")] diff --git a/BismNormalizer/BismNormalizer.Tests/BismNormalizerTests.cs b/BismNormalizer/BismNormalizer.Tests/BismNormalizerTests.cs index edd1939..78bf64f 100644 --- a/BismNormalizer/BismNormalizer.Tests/BismNormalizerTests.cs +++ b/BismNormalizer/BismNormalizer.Tests/BismNormalizerTests.cs @@ -27,7 +27,7 @@ namespace BismNormalizer.Tests { using (Amo.Server server = new Amo.Server()) { - server.Connect("localhost"); + server.Connect("localhost\\tb"); Amo.Database db = server.Databases.FindByName("Test1103_Target"); Assert.IsNotNull(db); @@ -42,7 +42,7 @@ namespace BismNormalizer.Tests { using (Tom.Server server = new Tom.Server()) { - server.Connect("localhost"); + server.Connect("localhost\\tb"); Tom.Database db = server.Databases.FindByName("Test1200_Target"); Assert.IsNotNull(db); diff --git a/BismNormalizer/BismNormalizer.Tests/Settings.Designer.cs b/BismNormalizer/BismNormalizer.Tests/Settings.Designer.cs new file mode 100644 index 0000000..02ae5cf --- /dev/null +++ b/BismNormalizer/BismNormalizer.Tests/Settings.Designer.cs @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace BismNormalizer.Tests { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("localhost\\tb")] + public string TestServer { + get { + return ((string)(this["TestServer"])); + } + set { + this["TestServer"] = value; + } + } + } +} diff --git a/BismNormalizer/BismNormalizer.Tests/Settings.settings b/BismNormalizer/BismNormalizer.Tests/Settings.settings new file mode 100644 index 0000000..3cddbd3 --- /dev/null +++ b/BismNormalizer/BismNormalizer.Tests/Settings.settings @@ -0,0 +1,9 @@ + + + + + + localhost\tb + + + \ No newline at end of file diff --git a/BismNormalizer/BismNormalizer.Tests/Test1103.bsmn b/BismNormalizer/BismNormalizer.Tests/Test1103.bsmn index 9b199d4..1f01de5 100644 --- a/BismNormalizer/BismNormalizer.Tests/Test1103.bsmn +++ b/BismNormalizer/BismNormalizer.Tests/Test1103.bsmn @@ -2,12 +2,12 @@ false - localhost + localhost\tb Test1103_Source false - localhost + localhost\tb Test1103_Target diff --git a/BismNormalizer/BismNormalizer.Tests/Test1200.bsmn b/BismNormalizer/BismNormalizer.Tests/Test1200.bsmn index 72e11f1..37476b2 100644 --- a/BismNormalizer/BismNormalizer.Tests/Test1200.bsmn +++ b/BismNormalizer/BismNormalizer.Tests/Test1200.bsmn @@ -2,13 +2,13 @@ false - localhost + localhost\tb Test1200_Source Tabular1200 false - localhost + localhost\tb Test1200_Target diff --git a/BismNormalizer/BismNormalizer.Tests/TestPrep.ps1 b/BismNormalizer/BismNormalizer.Tests/TestPrep.ps1 index 65d5a0b..9f847f7 100644 --- a/BismNormalizer/BismNormalizer.Tests/TestPrep.ps1 +++ b/BismNormalizer/BismNormalizer.Tests/TestPrep.ps1 @@ -17,7 +17,7 @@ Function script:deletedb($databasename) [Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices") >$NULL $server = New-Object Microsoft.AnalysisServices.Server -$server.connect("localhost") +$server.connect("localhost\tb") deletedb "Test1103_Source" deletedb "Test1103_Target" diff --git a/BismNormalizer/BismNormalizer.Tests/app.config b/BismNormalizer/BismNormalizer.Tests/app.config new file mode 100644 index 0000000..e652fde --- /dev/null +++ b/BismNormalizer/BismNormalizer.Tests/app.config @@ -0,0 +1,15 @@ + + + + +
+ + + + + + localhost\tb + + + + \ No newline at end of file diff --git a/BismNormalizer/BismNormalizer/BismNormalizer.csproj b/BismNormalizer/BismNormalizer/BismNormalizer.csproj index 736ffb9..4560c38 100644 --- a/BismNormalizer/BismNormalizer/BismNormalizer.csproj +++ b/BismNormalizer/BismNormalizer/BismNormalizer.csproj @@ -79,20 +79,38 @@ False - - ..\packages\Microsoft.AnalysisServices.retail.amd64.15.0.2\lib\net45\Microsoft.AnalysisServices.dll + + ..\packages\Microsoft.ApplicationInsights.Agent.Intercept.2.4.0\lib\net45\Microsoft.AI.Agent.Intercept.dll - - ..\packages\Microsoft.AnalysisServices.retail.amd64.15.0.2\lib\net45\Microsoft.AnalysisServices.Core.dll + + ..\packages\Microsoft.ApplicationInsights.DependencyCollector.2.8.1\lib\net45\Microsoft.AI.DependencyCollector.dll - - ..\packages\Microsoft.AnalysisServices.retail.amd64.15.0.2\lib\net45\Microsoft.AnalysisServices.SPClient.Interfaces.dll + + ..\packages\Microsoft.ApplicationInsights.PerfCounterCollector.2.8.1\lib\net45\Microsoft.AI.PerfCounterCollector.dll - - ..\packages\Microsoft.AnalysisServices.retail.amd64.15.0.2\lib\net45\Microsoft.AnalysisServices.Tabular.dll + + ..\packages\Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.2.8.1\lib\net45\Microsoft.AI.ServerTelemetryChannel.dll - - ..\packages\Microsoft.AnalysisServices.retail.amd64.15.0.2\lib\net45\Microsoft.AnalysisServices.Tabular.Json.dll + + ..\packages\Microsoft.ApplicationInsights.WindowsServer.2.8.1\lib\net45\Microsoft.AI.WindowsServer.dll + + + ..\packages\Microsoft.AnalysisServices.retail.amd64.15.7.0.2\lib\net45\Microsoft.AnalysisServices.dll + + + ..\packages\Microsoft.AnalysisServices.retail.amd64.15.7.0.2\lib\net45\Microsoft.AnalysisServices.Core.dll + + + ..\packages\Microsoft.AnalysisServices.retail.amd64.15.7.0.2\lib\net45\Microsoft.AnalysisServices.SPClient.Interfaces.dll + + + ..\packages\Microsoft.AnalysisServices.retail.amd64.15.7.0.2\lib\net45\Microsoft.AnalysisServices.Tabular.dll + + + ..\packages\Microsoft.AnalysisServices.retail.amd64.15.7.0.2\lib\net45\Microsoft.AnalysisServices.Tabular.Json.dll + + + ..\packages\Microsoft.ApplicationInsights.2.8.1\lib\net46\Microsoft.ApplicationInsights.dll @@ -179,8 +197,14 @@ + + ..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + + @@ -200,6 +224,7 @@ + Form @@ -395,6 +420,9 @@ + + PreserveNewest + Designer diff --git a/BismNormalizer/BismNormalizer/Properties/AssemblyInfo.cs b/BismNormalizer/BismNormalizer/Properties/AssemblyInfo.cs index 6d5342a..c1529dd 100644 --- a/BismNormalizer/BismNormalizer/Properties/AssemblyInfo.cs +++ b/BismNormalizer/BismNormalizer/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("4.0.0.29")] -[assembly: AssemblyFileVersion("4.0.0.29")] +[assembly: AssemblyVersion("4.0.0.30")] +[assembly: AssemblyFileVersion("4.0.0.30")] diff --git a/BismNormalizer/BismNormalizer/TabularCompare/ComparisonFactory.cs b/BismNormalizer/BismNormalizer/TabularCompare/ComparisonFactory.cs index 709ea02..d4e8059 100644 --- a/BismNormalizer/BismNormalizer/TabularCompare/ComparisonFactory.cs +++ b/BismNormalizer/BismNormalizer/TabularCompare/ComparisonFactory.cs @@ -61,6 +61,8 @@ namespace BismNormalizer.TabularCompare private static Comparison CreateComparisonInitialized(ComparisonInfo comparisonInfo) { + Telemetry.TrackEvent("CreateComparisonInitialized", new Dictionary { { "App", "BismNormalizer" } }); + if (comparisonInfo.SourceCompatibilityLevel != comparisonInfo.TargetCompatibilityLevel && !(comparisonInfo.SourceCompatibilityLevel == 1200 && comparisonInfo.TargetCompatibilityLevel == 1400)) { throw new ConnectionException($"This combination of mixed compatibility levels is not supported.\nSource is {Convert.ToString(comparisonInfo.SourceCompatibilityLevel)} and target is {Convert.ToString(comparisonInfo.TargetCompatibilityLevel)}."); diff --git a/BismNormalizer/BismNormalizer/TabularCompare/Telemetry.cs b/BismNormalizer/BismNormalizer/TabularCompare/Telemetry.cs new file mode 100644 index 0000000..bcc5e62 --- /dev/null +++ b/BismNormalizer/BismNormalizer/TabularCompare/Telemetry.cs @@ -0,0 +1,67 @@ +using Microsoft.ApplicationInsights; +using Microsoft.ApplicationInsights.Extensibility; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace BismNormalizer.TabularCompare +{ + public static class Telemetry + { + private const string TelemetryKey = "f3a055c0-3210-42c0-b5d2-3c05dd4e9a96"; + + private static TelemetryClient _telemetry = GetAppInsightsClient(); + + public static bool Enabled { get; set; } = true; + + private static TelemetryClient GetAppInsightsClient() + { + var config = new TelemetryConfiguration(); + config.InstrumentationKey = TelemetryKey; + config.TelemetryChannel = new Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel(); + //config.TelemetryChannel = new Microsoft.ApplicationInsights.Channel.InMemoryChannel(); // Default channel + config.TelemetryChannel.DeveloperMode = Debugger.IsAttached; +#if DEBUG + config.TelemetryChannel.DeveloperMode = true; +#endif + TelemetryClient client = new TelemetryClient(config); + client.Context.Component.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + client.Context.Session.Id = Guid.NewGuid().ToString(); + client.Context.User.Id = (Environment.UserName + Environment.MachineName).GetHashCode().ToString(); + //client.Context.Device.OperatingSystem = Environment.OSVersion.ToString(); + return client; + } + + public static void SetUser(string user) + { + _telemetry.Context.User.AuthenticatedUserId = user; + } + + public static void TrackEvent(string key, IDictionary properties = null, IDictionary metrics = null) + { + if (Enabled) + { + _telemetry.TrackEvent(key, properties, metrics); + } + } + + public static void TrackException(Exception ex) + { + if (ex != null && Enabled) + { + var telex = new Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry(ex); + _telemetry.TrackException(telex); + Flush(); + } + } + + internal static void Flush() + { + _telemetry.Flush(); + } + } +} diff --git a/BismNormalizer/BismNormalizer/packages.config b/BismNormalizer/BismNormalizer/packages.config index abb22e4..cd6c0c2 100644 --- a/BismNormalizer/BismNormalizer/packages.config +++ b/BismNormalizer/BismNormalizer/packages.config @@ -1,6 +1,12 @@  - + + + + + + + @@ -19,4 +25,5 @@ + \ No newline at end of file diff --git a/BismNormalizer/BismNormalizer/source.extension.vsixmanifest b/BismNormalizer/BismNormalizer/source.extension.vsixmanifest index bdc4ef3..79d1523 100644 --- a/BismNormalizer/BismNormalizer/source.extension.vsixmanifest +++ b/BismNormalizer/BismNormalizer/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + BISM Normalizer BISM Normalizer manages Analysis Services tabular models http://bism-normalizer.com/