diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index e94f1faf51..e566ae89da 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -2,3 +2,18 @@ If you're interested in contributing, take a look at the general [contributer's guide](https://github.com/Microsoft/ApplicationInsights-Home/blob/master/CONTRIBUTING.md) first. +## Build and Unit Test + +To successfully build the sources on your machine, make sure you've installed the following prerequisites: +* Visual Studio 2017 Community or Enterprise +* .NET 4.6 + +Once you've installed the prerequisites execute either ```buildDebug.cmd``` or ```buildRelease.cmd``` script in the repository root to build the project locally.. +```buildRelease.cmd``` also runs StlyeCop checks, and is required before merging any pull requests. + +You can also open the solutions in Visual Studio and build directly from there. +The following solution contains the product code and unit tests + "\Microsoft.ApplicationInsights.sln" + + +Once built, all unit tests can be run from Visual Studio itself. diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000000..36d317e098 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,18 @@ +If you are reporting bug/issue, please provide detailed Repro instructions. + +## Repro Steps +1. +2. + +## Actual Behavior + + +## Expected Behavior + + +## Version Info +SDK Version : +.NET Version : +How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) : +OS : +Hosting Info (IIS/Azure WebApps/ etc) : \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6b379938de..a08a297885 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,8 +1,11 @@ -Fix # . +Fix Issue # . + +- [ ] I ran [Unit Tests](https://github.com/Microsoft/ApplicationInsights-dotnet/blob/develop/.github/CONTRIBUTING.md) locally. For significant contributions please make sure you have completed the following items: - [ ] Design discussion issue # - [ ] Changes in public surface reviewed -- [ ] CHANGELOG.md updated +- [ ] CHANGELOG.md updated with one line description of the fix, and a link to the original issue. +- [ ] The PR will trigger build, unit test, and functional tests automatically. If your PR was submitted from fork - mention one of committers to initiate the build for you. diff --git a/.gitignore b/.gitignore index a028eb5288..9091478e3a 100644 --- a/.gitignore +++ b/.gitignore @@ -167,4 +167,7 @@ $RECYCLE.BIN/ Web/PerformanceTests_Instrumented/ [Ss]tyle[Cc]op.* -coverage.xml \ No newline at end of file +coverage.xml + +bondcodegen.done +bonddefaultcodegen.in \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..c2be33bd51 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/Test/Microsoft.ApplicationInsights.Test/netcoreapp11/bin/Debug/netcoreapp1.1/Microsoft.ApplicationInsights.netcoreapp11.Tests.dll", + "args": [], + "cwd": "${workspaceFolder}/Test/Microsoft.ApplicationInsights.Test/netcoreapp11", + // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window + "console": "internalConsole", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000..30de5f0534 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "msbuild", + "args": [ + "${workspaceRoot}/Microsoft.ApplicationInsights.sln", + // Ask msbuild to generate full paths for file names. + "/property:GenerateFullPaths=true", + "/t:build" + ], + "group": "build", + "presentation": { + // Reveal the output only if unrecognized errors occur. + "reveal": "always" + }, + // Use the standard MS compiler pattern to detect errors, warnings and infos + "problemMatcher": "$msCompile" + }, + { + "label": "test", + "type": "shell", + "command": "dotnet", + "args": [ + "test", + "Test/ServerTelemetryChannel.Test/NetCore.Tests/TelemetryChannel.NetCore.Tests.csproj;Test/Microsoft.ApplicationInsights.Test/netcoreapp11/Microsoft.ApplicationInsights.netcoreapp11.Tests.csproj" + ], + "group": "test", + "presentation": { + // Reveal the output only if unrecognized errors occur. + "reveal": "always" + }, + // Use the standard MS compiler pattern to detect errors, warnings and infos + "problemMatcher": "$msCompile" + //dotnet test Test/ServerTelemetryChannel.Test/NetCore.Tests/TelemetryChannel.NetCore.Tests.csproj + } + ] +} \ No newline at end of file diff --git a/AddXmlLanguage.targets b/AddXmlLanguage.targets index fa1e969a12..94ad34e5ef 100644 --- a/AddXmlLanguage.targets +++ b/AddXmlLanguage.targets @@ -57,7 +57,7 @@ - + \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 165aa96760..e17f6439ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ This changelog will be used to generate documentation on [release notes page](http://azure.microsoft.com/en-us/documentation/articles/app-insights-release-notes-dotnet/). +## Version 2.5.0-beta2 +- Remove calculation of sampling-score based on Context.User.Id [Issue #625](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/625) +- New sdk-driven "heartbeat" functionality added which sends health status at pre-configured intervals. See [extending heartbeat properties doc for more information](./docs/ExtendingHeartbeatProperties.md) +- Fixes a bug in ServerTelemetryChannel which caused application to crash on non-windows platforms. + [Details on fix and workaround #654] (https://github.com/Microsoft/ApplicationInsights-dotnet/issues/654) + Original issue (https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/551) +- [Fixed a bug with the `AdaptiveSamplingTelemetryProcessor` that would cause starvation over time. Issue #756 (dotnet-server)](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/756) +- Updated solution to build on Mac! + ## Version 2.5.0-beta1 - Method `Sanitize` on classes implementing `ITelemetry` no longer modifies the `TelemetryContext` fields. Serialized event json and ETW event will still have context tags sanitized. - Application Insights SDK supports multiple telemetry sinks. You can configure more than one channel for telemetry now. diff --git a/Directory.Build.props b/Directory.Build.props index 6cfd72c66a..b510357e2a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -71,7 +71,7 @@ $([System.IO.Path]::GetFullPath( $(PackagesDir) )) - true + true $(BinRoot)\$(Configuration)\ETW\$(TargetFramework)\ diff --git a/GlobalStaticVersion.props b/GlobalStaticVersion.props index 147399ec9a..2687f5caa8 100644 --- a/GlobalStaticVersion.props +++ b/GlobalStaticVersion.props @@ -8,7 +8,7 @@ 2 5 0 - beta1 + beta2 - - - - - - - - - - - - - + \ No newline at end of file diff --git a/Package.targets b/Package.targets deleted file mode 100644 index d3544842ff..0000000000 --- a/Package.targets +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(MSBuildThisFileDirectory)\nuget.exe - @(VersionInfo->'%(FileMajorPart)').@(VersionInfo->'%(FileMinorPart)').@(VersionInfo->'%(FileBuildPart)') - $(PackageVersion)-$(PreReleaseMilestone) - $(PackageVersion)-build@(VersionInfo->'%(FilePrivatePart)') - @(VersionInfo->'%(CompanyName)') - http://appanacdn.blob.core.windows.net/cdn/icons/aic.png - @(VersionInfo->'%(LegalCopyright)') - $(NuGetCommand) pack "$(PackageSpecFile)" -Properties "version=$(PackageVersion);author=$(PackageAuthor);image=$(PackageImage);copyright=$(PackageCopyright);configuration=$(Configuration)" -BasePath "$(BinRoot)" -OutputDirectory "$(PackageOutputDir)" -Symbols - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net40/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net40/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..65343b5b84 --- /dev/null +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net40/PublicAPI.Unshipped.txt @@ -0,0 +1,15 @@ +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.AddHealthProperty(string propertyName, string propertyValue, bool isHealthy) -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.ExcludedHeartbeatProperties.get -> System.Collections.Generic.IList +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.HeartbeatInterval.get -> System.TimeSpan +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.HeartbeatInterval.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.IsHeartbeatEnabled.get -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.IsHeartbeatEnabled.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.SetHealthProperty(string propertyName, string propertyValue = null, bool? isHealthy = null) -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.AddHealthProperty(string propertyName, string propertyValue, bool isHealthy) -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.ExcludedHeartbeatProperties.get -> System.Collections.Generic.IList +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.HeartbeatInterval.get -> System.TimeSpan +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.HeartbeatInterval.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.IsHeartbeatEnabled.get -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.IsHeartbeatEnabled.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.SetHealthProperty(string propertyName, string propertyValue = null, bool? isHealthy = null) -> bool \ No newline at end of file diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt index e69de29bb2..65343b5b84 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt @@ -0,0 +1,15 @@ +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.AddHealthProperty(string propertyName, string propertyValue, bool isHealthy) -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.ExcludedHeartbeatProperties.get -> System.Collections.Generic.IList +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.HeartbeatInterval.get -> System.TimeSpan +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.HeartbeatInterval.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.IsHeartbeatEnabled.get -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.IsHeartbeatEnabled.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.SetHealthProperty(string propertyName, string propertyValue = null, bool? isHealthy = null) -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.AddHealthProperty(string propertyName, string propertyValue, bool isHealthy) -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.ExcludedHeartbeatProperties.get -> System.Collections.Generic.IList +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.HeartbeatInterval.get -> System.TimeSpan +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.HeartbeatInterval.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.IsHeartbeatEnabled.get -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.IsHeartbeatEnabled.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.SetHealthProperty(string propertyName, string propertyValue = null, bool? isHealthy = null) -> bool \ No newline at end of file diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt index e69de29bb2..65343b5b84 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt @@ -0,0 +1,15 @@ +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.AddHealthProperty(string propertyName, string propertyValue, bool isHealthy) -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.ExcludedHeartbeatProperties.get -> System.Collections.Generic.IList +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.HeartbeatInterval.get -> System.TimeSpan +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.HeartbeatInterval.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.IsHeartbeatEnabled.get -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.IsHeartbeatEnabled.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.SetHealthProperty(string propertyName, string propertyValue = null, bool? isHealthy = null) -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.AddHealthProperty(string propertyName, string propertyValue, bool isHealthy) -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.ExcludedHeartbeatProperties.get -> System.Collections.Generic.IList +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.HeartbeatInterval.get -> System.TimeSpan +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.HeartbeatInterval.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.IsHeartbeatEnabled.get -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.IsHeartbeatEnabled.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.SetHealthProperty(string propertyName, string propertyValue = null, bool? isHealthy = null) -> bool \ No newline at end of file diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt index e69de29bb2..65343b5b84 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt @@ -0,0 +1,15 @@ +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.AddHealthProperty(string propertyName, string propertyValue, bool isHealthy) -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.ExcludedHeartbeatProperties.get -> System.Collections.Generic.IList +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.HeartbeatInterval.get -> System.TimeSpan +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.HeartbeatInterval.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.IsHeartbeatEnabled.get -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.IsHeartbeatEnabled.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.SetHealthProperty(string propertyName, string propertyValue = null, bool? isHealthy = null) -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.AddHealthProperty(string propertyName, string propertyValue, bool isHealthy) -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.ExcludedHeartbeatProperties.get -> System.Collections.Generic.IList +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.HeartbeatInterval.get -> System.TimeSpan +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.HeartbeatInterval.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.IsHeartbeatEnabled.get -> bool +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.IsHeartbeatEnabled.set -> void +Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.IHeartbeatPropertyManager.SetHealthProperty(string propertyName, string propertyValue = null, bool? isHealthy = null) -> bool \ No newline at end of file diff --git a/Schema/generateSchema.ps1 b/Schema/generateSchema.ps1 index f4fae3f167..5904f4d14b 100644 --- a/Schema/generateSchema.ps1 +++ b/Schema/generateSchema.ps1 @@ -118,9 +118,9 @@ dir "$currentDir\obj\gbc" | ForEach-Object { ## COPY GENERATED FILES TO THE REPOSITORY ##################################################################### -del "$currentDir\..\src\Microsoft.ApplicationInsights\Managed\Shared\Extensibility\Implementation\External\*_types.cs" +del "$currentDir\..\src\Microsoft.ApplicationInsights\Shared\Extensibility\Implementation\External\*_types.cs" dir "$currentDir\obj\gbc\*_types.cs" | ForEach-Object { $fileName = $_ - copy $fileName "$currentDir\..\src\Microsoft.ApplicationInsights\Managed\Shared\Extensibility\Implementation\External\" + copy $fileName "$currentDir\..\src\Microsoft.ApplicationInsights\Shared\Extensibility\Implementation\External\" } diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/ApplicationInsightsTypes.csproj b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/ApplicationInsightsTypes.csproj index 8ff6a4284a..20cdaf1956 100644 --- a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/ApplicationInsightsTypes.csproj +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/ApplicationInsightsTypes.csproj @@ -11,25 +11,23 @@ false net45;netstandard1.3 + netstandard1.3 {4B0BC3B7-C7FC-4333-9E28-5790D9153F07} ApplicationInsightsTypes ApplicationInsightsTypes --collection-interfaces --using="DateTimeOffset=System.DateTimeOffset" --using="TimeSpan=System.TimeSpan" --using="Guid=System.Guid" + $(MSBuildThisFileDirectory)\Generated - - - All All - All build - + StackFrame.bond diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/AvailabilityData_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/AvailabilityData_types.cs new file mode 100644 index 0000000000..84aad0a495 --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/AvailabilityData_types.cs @@ -0,0 +1,100 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : AvailabilityData_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "Instances of AvailabilityData represent the result of executing an availability test.")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class AvailabilityData + : Domain + { + [global::Bond.Attribute("Description", "Schema version")] + [global::Bond.Id(10), global::Bond.Required] + public int ver { get; set; } + + [global::Bond.Attribute("MaxStringLength", "64")] + [global::Bond.Attribute("Description", "Identifier of a test run. Use it to correlate steps of test run and telemetry generated by the service.")] + [global::Bond.Attribute("ActAsRequired", "Renaming testRunId to id.")] + [global::Bond.Id(21), global::Bond.Required] + public string id { get; set; } + + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Attribute("Description", "Name of the test that these availability results represents.")] + [global::Bond.Attribute("ActAsRequired", "Renaming testName to name.")] + [global::Bond.Id(41), global::Bond.Required] + public string name { get; set; } + + [global::Bond.Attribute("Description", "Duration in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff")] + [global::Bond.Attribute("CSType", "TimeSpan")] + [global::Bond.Id(50), global::Bond.Required] + public string duration { get; set; } + + [global::Bond.Attribute("ActAsRequired", "Renaming result to success.")] + [global::Bond.Attribute("Description", "Success flag.")] + [global::Bond.Id(61), global::Bond.Required] + public bool success { get; set; } + + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Attribute("Description", "Name of the location where the test was run from.")] + [global::Bond.Id(70)] + public string runLocation { get; set; } + + [global::Bond.Attribute("MaxStringLength", "8192")] + [global::Bond.Attribute("Description", "Diagnostic message for the result.")] + [global::Bond.Id(80)] + public string message { get; set; } + + [global::Bond.Attribute("Description", "Collection of custom properties.")] + [global::Bond.Attribute("MaxKeyLength", "150")] + [global::Bond.Attribute("MaxValueLength", "8192")] + [global::Bond.Id(100), global::Bond.Type(typeof(Dictionary))] + public IDictionary properties { get; set; } + + [global::Bond.Attribute("Description", "Collection of custom measurements.")] + [global::Bond.Attribute("MaxKeyLength", "150")] + [global::Bond.Id(200), global::Bond.Type(typeof(Dictionary))] + public IDictionary measurements { get; set; } + + public AvailabilityData() + : this("AI.AvailabilityData", "AvailabilityData") + {} + + protected AvailabilityData(string fullName, string name) + { + ver = 2; + id = ""; + this.name = ""; + duration = ""; + runLocation = ""; + message = ""; + properties = new Dictionary(); + measurements = new Dictionary(); + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/Base_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/Base_types.cs new file mode 100644 index 0000000000..f323fc461f --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/Base_types.cs @@ -0,0 +1,50 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : Base_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "Data struct to contain only C section with custom fields.")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class Base + { + [global::Bond.Attribute("Name", "ItemTypeName")] + [global::Bond.Attribute("Description", "Name of item (B section) if any. If telemetry data is derived straight from this, this should be null.")] + [global::Bond.Id(10)] + public string baseType { get; set; } + + public Base() + : this("AI.Base", "Base") + {} + + protected Base(string fullName, string name) + { + baseType = ""; + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/ContextTagKeys_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/ContextTagKeys_types.cs new file mode 100644 index 0000000000..c5ec66202f --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/ContextTagKeys_types.cs @@ -0,0 +1,190 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : ContextTagKeys_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("ContextContract", "Emit")] + [global::Bond.Attribute("PseudoType", "JSMap")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class ContextTagKeys + { + [global::Bond.Attribute("Description", "Application version. Information in the application context fields is always about the application that is sending the telemetry.")] + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Id(10)] + public string ApplicationVersion { get; set; } + + [global::Bond.Attribute("Description", "Unique client device id. Computer name in most cases.")] + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Id(100)] + public string DeviceId { get; set; } + + [global::Bond.Attribute("Description", "Device locale using - pattern, following RFC 5646. Example 'en-US'.")] + [global::Bond.Attribute("MaxStringLength", "64")] + [global::Bond.Id(115)] + public string DeviceLocale { get; set; } + + [global::Bond.Attribute("Description", "Model of the device the end user of the application is using. Used for client scenarios. If this field is empty then it is derived from the user agent.")] + [global::Bond.Attribute("MaxStringLength", "256")] + [global::Bond.Id(120)] + public string DeviceModel { get; set; } + + [global::Bond.Attribute("Description", "Client device OEM name taken from the browser.")] + [global::Bond.Attribute("MaxStringLength", "256")] + [global::Bond.Id(130)] + public string DeviceOEMName { get; set; } + + [global::Bond.Attribute("Description", "Operating system name and version of the device the end user of the application is using. If this field is empty then it is derived from the user agent. Example 'Windows 10 Pro 10.0.10586.0'")] + [global::Bond.Attribute("MaxStringLength", "256")] + [global::Bond.Id(140)] + public string DeviceOSVersion { get; set; } + + [global::Bond.Attribute("Description", "The type of the device the end user of the application is using. Used primarily to distinguish JavaScript telemetry from server side telemetry. Examples: 'PC', 'Phone', 'Browser'. 'PC' is the default value.")] + [global::Bond.Attribute("MaxStringLength", "64")] + [global::Bond.Id(160)] + public string DeviceType { get; set; } + + [global::Bond.Attribute("Description", "The IP address of the client device. IPv4 and IPv6 is supported. Information in the location context fields is always about the end user. When telemetry is sent from a service, the location context is about the user that initiated the operation in the service.")] + [global::Bond.Attribute("MaxStringLength", "45")] + [global::Bond.Id(200)] + public string LocationIp { get; set; } + + [global::Bond.Attribute("Description", "A unique identifier for the operation instance. The operation.id is created by either a request or a page view. All other telemetry sets this to the value for the containing request or page view. Operation.id is used for finding all the telemetry items for a specific operation instance.")] + [global::Bond.Attribute("MaxStringLength", "128")] + [global::Bond.Id(300)] + public string OperationId { get; set; } + + [global::Bond.Attribute("Description", "The name (group) of the operation. The operation.name is created by either a request or a page view. All other telemetry items set this to the value for the containing request or page view. Operation.name is used for finding all the telemetry items for a group of operations (i.e. 'GET Home/Index').")] + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Id(305)] + public string OperationName { get; set; } + + [global::Bond.Attribute("Description", "The unique identifier of the telemetry item's immediate parent.")] + [global::Bond.Attribute("MaxStringLength", "128")] + [global::Bond.Id(310)] + public string OperationParentId { get; set; } + + [global::Bond.Attribute("Description", "Name of synthetic source. Some telemetry from the application may represent a synthetic traffic. It may be web crawler indexing the web site, site availability tests or traces from diagnostic libraries like Application Insights SDK itself.")] + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Id(320)] + public string OperationSyntheticSource { get; set; } + + [global::Bond.Attribute("Description", "The correlation vector is a light weight vector clock which can be used to identify and order related events across clients and services.")] + [global::Bond.Attribute("MaxStringLength", "64")] + [global::Bond.Id(330)] + public string OperationCorrelationVector { get; set; } + + [global::Bond.Attribute("Description", "Session ID - the instance of the user's interaction with the app. Information in the session context fields is always about the end user. When telemetry is sent from a service, the session context is about the user that initiated the operation in the service.")] + [global::Bond.Attribute("MaxStringLength", "64")] + [global::Bond.Id(400)] + public string SessionId { get; set; } + + [global::Bond.Attribute("Description", "Boolean value indicating whether the session identified by ai.session.id is first for the user or not.")] + [global::Bond.Attribute("MaxStringLength", "5")] + [global::Bond.Attribute("Question", "Should it be marked as JSType-bool for breeze?")] + [global::Bond.Id(405)] + public string SessionIsFirst { get; set; } + + [global::Bond.Attribute("Description", "In multi-tenant applications this is the account ID or name which the user is acting with. Examples may be subscription ID for Azure portal or blog name blogging platform.")] + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Id(505)] + public string UserAccountId { get; set; } + + [global::Bond.Attribute("Description", "The browser's user agent string as reported by the browser. This property will be used to extract information regarding the customer's browser but will not be stored. Use custom properties to store the original user agent.")] + [global::Bond.Attribute("MaxStringLength", "2048")] + [global::Bond.Id(510)] + public string UserAgent { get; set; } + + [global::Bond.Attribute("Description", "Anonymous user id. Represents the end user of the application. When telemetry is sent from a service, the user context is about the user that initiated the operation in the service.")] + [global::Bond.Attribute("MaxStringLength", "128")] + [global::Bond.Id(515)] + public string UserId { get; set; } + + [global::Bond.Attribute("Description", "Authenticated user id. The opposite of ai.user.id, this represents the user with a friendly name. Since it's PII information it is not collected by default by most SDKs.")] + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Id(525)] + public string UserAuthUserId { get; set; } + + [global::Bond.Attribute("Description", "Name of the role the application is a part of. Maps directly to the role name in azure.")] + [global::Bond.Attribute("MaxStringLength", "256")] + [global::Bond.Id(705)] + public string CloudRole { get; set; } + + [global::Bond.Attribute("Description", "Name of the instance where the application is running. Computer name for on-premises, instance name for Azure.")] + [global::Bond.Attribute("MaxStringLength", "256")] + [global::Bond.Id(715)] + public string CloudRoleInstance { get; set; } + + [global::Bond.Attribute("Description", "SDK version. See https://github.com/Microsoft/ApplicationInsights-Home/blob/master/SDK-AUTHORING.md#sdk-version-specification for information.")] + [global::Bond.Attribute("MaxStringLength", "64")] + [global::Bond.Id(1000)] + public string InternalSdkVersion { get; set; } + + [global::Bond.Attribute("Description", "Agent version. Used to indicate the version of StatusMonitor installed on the computer if it is used for data collection.")] + [global::Bond.Attribute("MaxStringLength", "64")] + [global::Bond.Id(1001)] + public string InternalAgentVersion { get; set; } + + [global::Bond.Attribute("Description", "This is the node name used for billing purposes. Use it to override the standard detection of nodes.")] + [global::Bond.Attribute("MaxStringLength", "256")] + [global::Bond.Id(1002)] + public string InternalNodeName { get; set; } + + public ContextTagKeys() + : this("AI.ContextTagKeys", "ContextTagKeys") + {} + + protected ContextTagKeys(string fullName, string name) + { + ApplicationVersion = "ai.application.ver"; + DeviceId = "ai.device.id"; + DeviceLocale = "ai.device.locale"; + DeviceModel = "ai.device.model"; + DeviceOEMName = "ai.device.oemName"; + DeviceOSVersion = "ai.device.osVersion"; + DeviceType = "ai.device.type"; + LocationIp = "ai.location.ip"; + OperationId = "ai.operation.id"; + OperationName = "ai.operation.name"; + OperationParentId = "ai.operation.parentId"; + OperationSyntheticSource = "ai.operation.syntheticSource"; + OperationCorrelationVector = "ai.operation.correlationVector"; + SessionId = "ai.session.id"; + SessionIsFirst = "ai.session.isFirst"; + UserAccountId = "ai.user.accountId"; + UserAgent = "ai.user.userAgent"; + UserId = "ai.user.id"; + UserAuthUserId = "ai.user.authUserId"; + CloudRole = "ai.cloud.role"; + CloudRoleInstance = "ai.cloud.roleInstance"; + InternalSdkVersion = "ai.internal.sdkVersion"; + InternalAgentVersion = "ai.internal.agentVersion"; + InternalNodeName = "ai.internal.nodeName"; + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/DataPointType_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/DataPointType_types.cs new file mode 100644 index 0000000000..1be56350ee --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/DataPointType_types.cs @@ -0,0 +1,38 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : DataPointType_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "Type of the metric data measurement.")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public enum DataPointType + { + Measurement, + Aggregation, + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/DataPoint_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/DataPoint_types.cs new file mode 100644 index 0000000000..8e5d94ff56 --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/DataPoint_types.cs @@ -0,0 +1,75 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : DataPoint_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "Metric data single measurement.")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class DataPoint + { + [global::Bond.Attribute("Description", "Name of the metric.")] + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Id(10), global::Bond.Required] + public string name { get; set; } + + [global::Bond.Attribute("Description", "Metric type.")] + [global::Bond.Id(20)] + public DataPointType kind { get; set; } + + [global::Bond.Attribute("Description", "Metric calculated value.")] + [global::Bond.Id(30), global::Bond.Required] + public double value { get; set; } + + [global::Bond.Attribute("Description", "Metric weight of the aggregated metric. Should not be set for a measurement.")] + [global::Bond.Id(40), global::Bond.Type(typeof(global::Bond.Tag.nullable))] + public int? count { get; set; } + + [global::Bond.Attribute("Description", "Minimum value of the aggregated metric. Should not be set for a measurement.")] + [global::Bond.Id(50), global::Bond.Type(typeof(global::Bond.Tag.nullable))] + public double? min { get; set; } + + [global::Bond.Attribute("Description", "Maximum value of the aggregated metric. Should not be set for a measurement.")] + [global::Bond.Id(60), global::Bond.Type(typeof(global::Bond.Tag.nullable))] + public double? max { get; set; } + + [global::Bond.Attribute("Description", "Standard deviation of the aggregated metric. Should not be set for a measurement.")] + [global::Bond.Id(70), global::Bond.Type(typeof(global::Bond.Tag.nullable))] + public double? stdDev { get; set; } + + public DataPoint() + : this("AI.DataPoint", "DataPoint") + {} + + protected DataPoint(string fullName, string name) + { + this.name = ""; + kind = DataPointType.Measurement; + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/Data_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/Data_types.cs new file mode 100644 index 0000000000..ee3ef8455a --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/Data_types.cs @@ -0,0 +1,51 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : Data_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "Data struct to contain both B and C sections.")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class Data + : Base + { + [global::Bond.Attribute("Name", "Item")] + [global::Bond.Attribute("Description", "Container for data item (B section).")] + [global::Bond.Id(20), global::Bond.Type(typeof(global::Bond.Tag.classT)), global::Bond.Required] + public TDomain baseData { get; set; } + + public Data() + : this("AI.Data", "Data") + {} + + protected Data(string fullName, string name) + { + baseData = global::Bond.GenericFactory.Create(); + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/Domain_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/Domain_types.cs new file mode 100644 index 0000000000..b1dcae09fa --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/Domain_types.cs @@ -0,0 +1,38 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : Domain_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "The abstract common base of all domains.")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class Domain + { + + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/Envelope_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/Envelope_types.cs new file mode 100644 index 0000000000..f8bf26230d --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/Envelope_types.cs @@ -0,0 +1,101 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : Envelope_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "System variables for a telemetry item.")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class Envelope + { + [global::Bond.Attribute("Description", "Envelope version. For internal use only. By assigning this the default, it will not be serialized within the payload unless changed to a value other than #1.")] + [global::Bond.Attribute("Name", "SchemaVersion")] + [global::Bond.Id(10)] + public int ver { get; set; } + + [global::Bond.Attribute("Description", "Type name of telemetry data item.")] + [global::Bond.Attribute("Name", "DataTypeName")] + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Id(20), global::Bond.Required] + public string name { get; set; } + + [global::Bond.Attribute("Description", "Event date time when telemetry item was created. This is the wall clock time on the client when the event was generated. There is no guarantee that the client's time is accurate. This field must be formatted in UTC ISO 8601 format, with a trailing 'Z' character, as described publicly on https://en.wikipedia.org/wiki/ISO_8601#UTC. Note: the number of decimal seconds digits provided are variable (and unspecified). Consumers should handle this, i.e. managed code consumers should not use format 'O' for parsing as it specifies a fixed length. Example: 2009-06-15T13:45:30.0000000Z.")] + [global::Bond.Attribute("Name", "DateTime")] + [global::Bond.Attribute("CSType", "DateTimeOffset")] + [global::Bond.Attribute("JSType", "Date")] + [global::Bond.Attribute("HockeyAppMinDateOffsetFromNow", "2592000000")] + [global::Bond.Attribute("MinDateOffsetFromNow", "172800000")] + [global::Bond.Attribute("MaxDateOffsetFromNow", "7200000")] + [global::Bond.Id(30), global::Bond.Required] + public string time { get; set; } + + [global::Bond.Attribute("Name", "SamplingRate")] + [global::Bond.Attribute("Description", "Sampling rate used in application. This telemetry item represents 1 / sampleRate actual telemetry items.")] + [global::Bond.Id(40)] + public double sampleRate { get; set; } + + [global::Bond.Attribute("Description", "Sequence field used to track absolute order of uploaded events.")] + [global::Bond.Attribute("Name", "SequenceNumber")] + [global::Bond.Attribute("MaxStringLength", "64")] + [global::Bond.Id(50)] + public string seq { get; set; } + + [global::Bond.Attribute("Description", "The application's instrumentation key.")] + [global::Bond.Attribute("Name", "InstrumentationKey")] + [global::Bond.Attribute("MaxStringLength", "40")] + [global::Bond.Id(60)] + public string iKey { get; set; } + + [global::Bond.Attribute("Name", "Tags")] + [global::Bond.Attribute("TypeAlias", "ContextTagKeys")] + [global::Bond.Attribute("Description", "Key/value collection of context properties. See ContextTagKeys for information on available properties.")] + [global::Bond.Id(500), global::Bond.Type(typeof(Dictionary))] + public IDictionary tags { get; set; } + + [global::Bond.Attribute("Name", "TelemetryData")] + [global::Bond.Attribute("Description", "Telemetry data item.")] + [global::Bond.Id(999)] + public Base data { get; set; } + + public Envelope() + : this("AI.Envelope", "Envelope") + {} + + protected Envelope(string fullName, string name) + { + ver = 1; + this.name = ""; + time = ""; + sampleRate = 100.0; + seq = ""; + iKey = ""; + tags = new Dictionary(); + data = new Base(); + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/EventData_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/EventData_types.cs new file mode 100644 index 0000000000..65468124bc --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/EventData_types.cs @@ -0,0 +1,70 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : EventData_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "Instances of Event represent structured event records that can be grouped and searched by their properties. Event data item also creates a metric of event count by name.")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class EventData + : Domain + { + [global::Bond.Attribute("Description", "Schema version")] + [global::Bond.Id(10), global::Bond.Required] + public int ver { get; set; } + + [global::Bond.Attribute("MaxStringLength", "512")] + [global::Bond.Attribute("Description", "Event name. Keep it low cardinality to allow proper grouping and useful metrics.")] + [global::Bond.Attribute("Question", "Why Custom Event name is shorter than Request name or dependency name?")] + [global::Bond.Id(20), global::Bond.Required] + public string name { get; set; } + + [global::Bond.Attribute("Description", "Collection of custom properties.")] + [global::Bond.Attribute("MaxKeyLength", "150")] + [global::Bond.Attribute("MaxValueLength", "8192")] + [global::Bond.Id(100), global::Bond.Type(typeof(Dictionary))] + public IDictionary properties { get; set; } + + [global::Bond.Attribute("Description", "Collection of custom measurements.")] + [global::Bond.Attribute("MaxKeyLength", "150")] + [global::Bond.Id(200), global::Bond.Type(typeof(Dictionary))] + public IDictionary measurements { get; set; } + + public EventData() + : this("AI.EventData", "EventData") + {} + + protected EventData(string fullName, string name) + { + ver = 2; + this.name = ""; + properties = new Dictionary(); + measurements = new Dictionary(); + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/ExceptionData_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/ExceptionData_types.cs new file mode 100644 index 0000000000..e469ddb138 --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/ExceptionData_types.cs @@ -0,0 +1,78 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : ExceptionData_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "An instance of Exception represents a handled or unhandled exception that occurred during execution of the monitored application.")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class ExceptionData + : Domain + { + [global::Bond.Attribute("Description", "Schema version")] + [global::Bond.Id(10), global::Bond.Required] + public int ver { get; set; } + + [global::Bond.Attribute("Description", "Exception chain - list of inner exceptions.")] + [global::Bond.Id(50), global::Bond.Type(typeof(List)), global::Bond.Required] + public IList exceptions { get; set; } + + [global::Bond.Attribute("Description", "Severity level. Mostly used to indicate exception severity level when it is reported by logging library.")] + [global::Bond.Id(60), global::Bond.Type(typeof(global::Bond.Tag.nullable))] + public SeverityLevel? severityLevel { get; set; } + + [global::Bond.Attribute("Description", "Identifier of where the exception was thrown in code. Used for exceptions grouping. Typically a combination of exception type and a function from the call stack.")] + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Id(80)] + public string problemId { get; set; } + + [global::Bond.Attribute("Description", "Collection of custom properties.")] + [global::Bond.Attribute("MaxKeyLength", "150")] + [global::Bond.Attribute("MaxValueLength", "8192")] + [global::Bond.Id(100), global::Bond.Type(typeof(Dictionary))] + public IDictionary properties { get; set; } + + [global::Bond.Attribute("Description", "Collection of custom measurements.")] + [global::Bond.Attribute("MaxKeyLength", "150")] + [global::Bond.Id(200), global::Bond.Type(typeof(Dictionary))] + public IDictionary measurements { get; set; } + + public ExceptionData() + : this("AI.ExceptionData", "ExceptionData") + {} + + protected ExceptionData(string fullName, string name) + { + ver = 2; + exceptions = new List(); + problemId = ""; + properties = new Dictionary(); + measurements = new Dictionary(); + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/ExceptionDetails_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/ExceptionDetails_types.cs new file mode 100644 index 0000000000..a6c1aa7824 --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/ExceptionDetails_types.cs @@ -0,0 +1,80 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : ExceptionDetails_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "Exception details of the exception in a chain.")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class ExceptionDetails + { + [global::Bond.Attribute("Description", "In case exception is nested (outer exception contains inner one), the id and outerId properties are used to represent the nesting.")] + [global::Bond.Id(10)] + public int id { get; set; } + + [global::Bond.Attribute("Description", "The value of outerId is a reference to an element in ExceptionDetails that represents the outer exception")] + [global::Bond.Id(20)] + public int outerId { get; set; } + + [global::Bond.Attribute("Description", "Exception type name.")] + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Id(30), global::Bond.Required] + public string typeName { get; set; } + + [global::Bond.Attribute("Description", "Exception message.")] + [global::Bond.Attribute("MaxStringLength", "32768")] + [global::Bond.Id(40), global::Bond.Required] + public string message { get; set; } + + [global::Bond.Attribute("Description", "Indicates if full exception stack is provided in the exception. The stack may be trimmed, such as in the case of a StackOverflow exception.")] + [global::Bond.Id(50)] + public bool hasFullStack { get; set; } + + [global::Bond.Attribute("Description", "Text describing the stack. Either stack or parsedStack should have a value.")] + [global::Bond.Attribute("MaxStringLength", "32768")] + [global::Bond.Id(60)] + public string stack { get; set; } + + [global::Bond.Attribute("Description", "List of stack frames. Either stack or parsedStack should have a value.")] + [global::Bond.Id(70), global::Bond.Type(typeof(List))] + public IList parsedStack { get; set; } + + public ExceptionDetails() + : this("AI.ExceptionDetails", "ExceptionDetails") + {} + + protected ExceptionDetails(string fullName, string name) + { + typeName = ""; + message = ""; + hasFullStack = true; + stack = ""; + parsedStack = new List(); + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/MessageData_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/MessageData_types.cs new file mode 100644 index 0000000000..89ba47ae2a --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/MessageData_types.cs @@ -0,0 +1,67 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : MessageData_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "Instances of Message represent printf-like trace statements that are text-searched. Log4Net, NLog and other text-based log file entries are translated into instances of this type. The message does not have measurements.")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class MessageData + : Domain + { + [global::Bond.Attribute("Description", "Schema version")] + [global::Bond.Id(10), global::Bond.Required] + public int ver { get; set; } + + [global::Bond.Attribute("MaxStringLength", "32768")] + [global::Bond.Attribute("Description", "Trace message")] + [global::Bond.Id(20), global::Bond.Required] + public string message { get; set; } + + [global::Bond.Attribute("Description", "Trace severity level.")] + [global::Bond.Id(30), global::Bond.Type(typeof(global::Bond.Tag.nullable))] + public SeverityLevel? severityLevel { get; set; } + + [global::Bond.Attribute("Description", "Collection of custom properties.")] + [global::Bond.Attribute("MaxKeyLength", "150")] + [global::Bond.Attribute("MaxValueLength", "8192")] + [global::Bond.Id(100), global::Bond.Type(typeof(Dictionary))] + public IDictionary properties { get; set; } + + public MessageData() + : this("AI.MessageData", "MessageData") + {} + + protected MessageData(string fullName, string name) + { + ver = 2; + message = ""; + properties = new Dictionary(); + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/MetricData_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/MetricData_types.cs new file mode 100644 index 0000000000..e4ea6a4ba3 --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/MetricData_types.cs @@ -0,0 +1,62 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : MetricData_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "An instance of the Metric item is a list of measurements (single data points) and/or aggregations.")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class MetricData + : Domain + { + [global::Bond.Attribute("Description", "Schema version")] + [global::Bond.Id(10), global::Bond.Required] + public int ver { get; set; } + + [global::Bond.Attribute("Description", "List of metrics.")] + [global::Bond.Id(20), global::Bond.Type(typeof(List)), global::Bond.Required] + public IList metrics { get; set; } + + [global::Bond.Attribute("Description", "Collection of custom properties.")] + [global::Bond.Attribute("MaxKeyLength", "150")] + [global::Bond.Attribute("MaxValueLength", "8192")] + [global::Bond.Id(100), global::Bond.Type(typeof(Dictionary))] + public IDictionary properties { get; set; } + + public MetricData() + : this("AI.MetricData", "MetricData") + {} + + protected MetricData(string fullName, string name) + { + ver = 2; + metrics = new List(); + properties = new Dictionary(); + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/PageViewData_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/PageViewData_types.cs new file mode 100644 index 0000000000..aea0032f35 --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/PageViewData_types.cs @@ -0,0 +1,58 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : PageViewData_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "An instance of PageView represents a generic action on a page like a button click. It is also the base type for PageView.")] + [global::Bond.Attribute("Alias", "PageviewData;PageEventData")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class PageViewData + : EventData + { + [global::Bond.Attribute("MaxStringLength", "2048")] + [global::Bond.Attribute("Description", "Request URL with all query string parameters")] + [global::Bond.Id(10)] + public string url { get; set; } + + [global::Bond.Attribute("CSType", "TimeSpan")] + [global::Bond.Attribute("Description", "Request duration in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff. For a page view (PageViewData), this is the duration. For a page view with performance information (PageViewPerfData), this is the page load time.")] + [global::Bond.Id(20)] + public string duration { get; set; } + + public PageViewData() + : this("AI.PageViewData", "PageViewData") + {} + + protected PageViewData(string fullName, string name) + { + url = ""; + duration = ""; + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/PageViewPerfData_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/PageViewPerfData_types.cs new file mode 100644 index 0000000000..7e840975b8 --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/PageViewPerfData_types.cs @@ -0,0 +1,76 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : PageViewPerfData_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "An instance of PageViewPerf represents: a page view with no performance data, a page view with performance data, or just the performance data of an earlier page request.")] + [global::Bond.Attribute("Alias", "PageViewPerformanceData;PageviewPerformanceData")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class PageViewPerfData + : PageViewData + { + [global::Bond.Attribute("Description", "Performance total in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff")] + [global::Bond.Attribute("CSType", "TimeSpan")] + [global::Bond.Id(10)] + public string perfTotal { get; set; } + + [global::Bond.Attribute("Description", "Network connection time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff")] + [global::Bond.Attribute("CSType", "TimeSpan")] + [global::Bond.Id(20)] + public string networkConnect { get; set; } + + [global::Bond.Attribute("Description", "Sent request time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff")] + [global::Bond.Attribute("CSType", "TimeSpan")] + [global::Bond.Id(30)] + public string sentRequest { get; set; } + + [global::Bond.Attribute("Description", "Received response time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff")] + [global::Bond.Attribute("CSType", "TimeSpan")] + [global::Bond.Id(40)] + public string receivedResponse { get; set; } + + [global::Bond.Attribute("Description", "DOM processing time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff")] + [global::Bond.Attribute("CSType", "TimeSpan")] + [global::Bond.Id(50)] + public string domProcessing { get; set; } + + public PageViewPerfData() + : this("AI.PageViewPerfData", "PageViewPerfData") + {} + + protected PageViewPerfData(string fullName, string name) + { + perfTotal = ""; + networkConnect = ""; + sentRequest = ""; + receivedResponse = ""; + domProcessing = ""; + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/RemoteDependencyData_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/RemoteDependencyData_types.cs new file mode 100644 index 0000000000..970b5781a4 --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/RemoteDependencyData_types.cs @@ -0,0 +1,111 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : RemoteDependencyData_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "An instance of Remote Dependency represents an interaction of the monitored component with a remote component/service like SQL or an HTTP endpoint.")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class RemoteDependencyData + : Domain + { + [global::Bond.Attribute("Description", "Schema version")] + [global::Bond.Id(10), global::Bond.Required] + public int ver { get; set; } + + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Attribute("Description", "Name of the command initiated with this dependency call. Low cardinality value. Examples are stored procedure name and URL path template.")] + [global::Bond.Id(20), global::Bond.Required] + public string name { get; set; } + + [global::Bond.Attribute("MaxStringLength", "128")] + [global::Bond.Attribute("Description", "Identifier of a dependency call instance. Used for correlation with the request telemetry item corresponding to this dependency call.")] + [global::Bond.Id(30)] + public string id { get; set; } + + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Attribute("Description", "Result code of a dependency call. Examples are SQL error code and HTTP status code.")] + [global::Bond.Id(40)] + public string resultCode { get; set; } + + [global::Bond.Attribute("CSType", "TimeSpan")] + [global::Bond.Attribute("Description", "Request duration in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff.")] + [global::Bond.Attribute("ActAsRequired", "Renaming value to duration.")] + [global::Bond.Id(61), global::Bond.Required] + public string duration { get; set; } + + [global::Bond.Attribute("Description", "Indication of successful or unsuccessful call.")] + [global::Bond.Id(120)] + public bool success { get; set; } + + [global::Bond.Attribute("MaxStringLength", "8192")] + [global::Bond.Attribute("Description", "Command initiated by this dependency call. Examples are SQL statement and HTTP URL's with all query parameters.")] + [global::Bond.Id(151)] + public string data { get; set; } + + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Attribute("Description", "Target site of a dependency call. Examples are server name, host address.")] + [global::Bond.Id(161)] + public string target { get; set; } + + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Attribute("Description", "Dependency type name. Very low cardinality value for logical grouping of dependencies and interpretation of other fields like commandName and resultCode. Examples are SQL, Azure table, and HTTP.")] + [global::Bond.Id(162)] + public string type { get; set; } + + [global::Bond.Attribute("Description", "Collection of custom properties.")] + [global::Bond.Attribute("MaxKeyLength", "150")] + [global::Bond.Attribute("MaxValueLength", "8192")] + [global::Bond.Id(200), global::Bond.Type(typeof(Dictionary))] + public IDictionary properties { get; set; } + + [global::Bond.Attribute("Description", "Collection of custom measurements.")] + [global::Bond.Attribute("MaxKeyLength", "150")] + [global::Bond.Id(300), global::Bond.Type(typeof(Dictionary))] + public IDictionary measurements { get; set; } + + public RemoteDependencyData() + : this("AI.RemoteDependencyData", "RemoteDependencyData") + {} + + protected RemoteDependencyData(string fullName, string name) + { + ver = 2; + this.name = ""; + id = ""; + resultCode = ""; + duration = ""; + success = true; + data = ""; + target = ""; + type = ""; + properties = new Dictionary(); + measurements = new Dictionary(); + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/RequestData_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/RequestData_types.cs new file mode 100644 index 0000000000..cde682829c --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/RequestData_types.cs @@ -0,0 +1,103 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : RequestData_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "An instance of Request represents completion of an external request to the application to do work and contains a summary of that request execution and the results.")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class RequestData + : Domain + { + [global::Bond.Attribute("Description", "Schema version")] + [global::Bond.Id(10), global::Bond.Required] + public int ver { get; set; } + + [global::Bond.Attribute("MaxStringLength", "128")] + [global::Bond.Attribute("Description", "Identifier of a request call instance. Used for correlation between request and other telemetry items.")] + [global::Bond.Id(20), global::Bond.Required] + public string id { get; set; } + + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Attribute("Description", "Source of the request. Examples are the instrumentation key of the caller or the ip address of the caller.")] + [global::Bond.Id(29)] + public string source { get; set; } + + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Attribute("Description", "Name of the request. Represents code path taken to process request. Low cardinality value to allow better grouping of requests. For HTTP requests it represents the HTTP method and URL path template like 'GET /values/{id}'.")] + [global::Bond.Id(30)] + public string name { get; set; } + + [global::Bond.Attribute("CSType", "TimeSpan")] + [global::Bond.Attribute("Description", "Request duration in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff.")] + [global::Bond.Id(50), global::Bond.Required] + public string duration { get; set; } + + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Attribute("Description", "Result of a request execution. HTTP status code for HTTP requests.")] + [global::Bond.Id(60), global::Bond.Required] + public string responseCode { get; set; } + + [global::Bond.Attribute("Description", "Indication of successful or unsuccessful call.")] + [global::Bond.Id(70), global::Bond.Required] + public bool success { get; set; } + + [global::Bond.Attribute("MaxStringLength", "2048")] + [global::Bond.Attribute("Description", "Request URL with all query string parameters.")] + [global::Bond.Id(90)] + public string url { get; set; } + + [global::Bond.Attribute("Description", "Collection of custom properties.")] + [global::Bond.Attribute("MaxKeyLength", "150")] + [global::Bond.Attribute("MaxValueLength", "8192")] + [global::Bond.Id(100), global::Bond.Type(typeof(Dictionary))] + public IDictionary properties { get; set; } + + [global::Bond.Attribute("Description", "Collection of custom measurements.")] + [global::Bond.Attribute("MaxKeyLength", "150")] + [global::Bond.Id(200), global::Bond.Type(typeof(Dictionary))] + public IDictionary measurements { get; set; } + + public RequestData() + : this("AI.RequestData", "RequestData") + {} + + protected RequestData(string fullName, string name) + { + ver = 2; + id = ""; + source = ""; + this.name = ""; + duration = ""; + responseCode = ""; + url = ""; + properties = new Dictionary(); + measurements = new Dictionary(); + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/SeverityLevel_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/SeverityLevel_types.cs new file mode 100644 index 0000000000..fca5e9bc4f --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/SeverityLevel_types.cs @@ -0,0 +1,41 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : SeverityLevel_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "Defines the level of severity for the event.")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public enum SeverityLevel + { + Verbose, + Information, + Warning, + Error, + Critical, + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/StackFrame_types.cs b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/StackFrame_types.cs new file mode 100644 index 0000000000..0faf908687 --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/ApplicationInsightsTypes/Generated/StackFrame_types.cs @@ -0,0 +1,70 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.10.0.0 +// File : StackFrame_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace AI +{ + using System.Collections.Generic; + + [global::Bond.Attribute("Description", "Stack frame information.")] + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.10.0.0")] + public partial class StackFrame + { + [global::Bond.Attribute("Description", "Level in the call stack. For the long stacks SDK may not report every function in a call stack.")] + [global::Bond.Id(10), global::Bond.Required] + public int level { get; set; } + + [global::Bond.Attribute("Description", "Method name.")] + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Id(20), global::Bond.Required] + public string method { get; set; } + + [global::Bond.Attribute("Description", "Name of the assembly (dll, jar, etc.) containing this function.")] + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Id(30)] + public string assembly { get; set; } + + [global::Bond.Attribute("Description", "File name or URL of the method implementation.")] + [global::Bond.Attribute("MaxStringLength", "1024")] + [global::Bond.Id(50)] + public string fileName { get; set; } + + [global::Bond.Attribute("Description", "Line number of the code implementation.")] + [global::Bond.Id(60)] + public int line { get; set; } + + public StackFrame() + : this("AI.StackFrame", "StackFrame") + {} + + protected StackFrame(string fullName, string name) + { + method = ""; + assembly = ""; + fileName = ""; + } + } +} // AI diff --git a/Test/Microsoft.ApplicationInsights.Test/Net45/Microsoft.ApplicationInsights.Net45.Tests.csproj b/Test/Microsoft.ApplicationInsights.Test/Net45/Microsoft.ApplicationInsights.Net45.Tests.csproj index c7c4951294..be34f12ddf 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Net45/Microsoft.ApplicationInsights.Net45.Tests.csproj +++ b/Test/Microsoft.ApplicationInsights.Test/Net45/Microsoft.ApplicationInsights.Net45.Tests.csproj @@ -15,27 +15,22 @@ true - - - {e9ecee96-dd50-42f6-9f33-0978cdfa15ed} - Microsoft.ApplicationInsights - - - {4b0bc3b7-c7fc-4333-9e28-5790d9153f07} - ApplicationInsightsTypes - - - - + + false + netstandard1.3 + + + + + - + - All All @@ -46,18 +41,16 @@ - - - + Extensibility\Implementation\Platform\PlatformReferencesTests.cs - + Extensibility\Implementation\RichPayloadEventSourceTest.cs - - + + diff --git a/Test/Microsoft.ApplicationInsights.Test/Net46/Microsoft.ApplicationInsights.Net46.Tests.csproj b/Test/Microsoft.ApplicationInsights.Test/Net46/Microsoft.ApplicationInsights.Net46.Tests.csproj index d2722bb0bd..2bc570b242 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Net46/Microsoft.ApplicationInsights.Net46.Tests.csproj +++ b/Test/Microsoft.ApplicationInsights.Test/Net46/Microsoft.ApplicationInsights.Net46.Tests.csproj @@ -15,27 +15,22 @@ true - - - {e9ecee96-dd50-42f6-9f33-0978cdfa15ed} - Microsoft.ApplicationInsights - - - {4b0bc3b7-c7fc-4333-9e28-5790d9153f07} - ApplicationInsightsTypes - - - - + + false + netstandard1.3 + + + + + - + - All All @@ -46,18 +41,14 @@ - - Extensibility\Implementation\Platform\PlatformReferencesTests.cs - - - - + + diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/AvailabilityTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/AvailabilityTelemetryTest.cs index fe78fa345d..7964de939f 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/AvailabilityTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/AvailabilityTelemetryTest.cs @@ -9,10 +9,7 @@ using Microsoft.ApplicationInsights.Extensibility.Implementation.External; using Microsoft.ApplicationInsights.TestFramework; using Microsoft.VisualStudio.TestTools.UnitTesting; - -#if !NETCOREAPP1_1 using KellermanSoftware.CompareNetObjects; -#endif [TestClass] public class AvailabilityTelemetryTest @@ -116,7 +113,6 @@ public void AssignmentWillCastSuccessToResult() Assert.AreEqual(telemetry.Data.success, false); } -#if !NETCOREAPP1_1 [TestMethod] public void AvailabilityTelemetryDeepCloneCopiesAllProperties() { @@ -129,7 +125,6 @@ public void AvailabilityTelemetryDeepCloneCopiesAllProperties() ComparisonResult result = deepComparator.Compare(telemetry, other); Assert.IsTrue(result.AreEqual, result.DifferencesString); } -#endif private AvailabilityTelemetry CreateAvailabilityTelemetry() { diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs index 69e9922f70..66b25229cd 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs @@ -1,16 +1,13 @@ namespace Microsoft.ApplicationInsights.DataContracts { using System; + using System.Collections.Generic; using System.Linq; + using KellermanSoftware.CompareNetObjects; using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Extensibility.Implementation; - using Microsoft.VisualStudio.TestTools.UnitTesting; - -#if !NETCOREAPP1_1 - using KellermanSoftware.CompareNetObjects; -#endif - using System.Collections.Generic; using Microsoft.ApplicationInsights.TestFramework; + using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] public class DependencyTelemetryTest diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/EventTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/EventTelemetryTest.cs index 83b23d1cb4..6bbff28d64 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/EventTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/EventTelemetryTest.cs @@ -5,12 +5,10 @@ using System.Reflection; using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Extensibility.Implementation; + using Microsoft.ApplicationInsights.TestFramework; using Microsoft.VisualStudio.TestTools.UnitTesting; - -#if !NETCOREAPP1_1 + using CompareLogic = KellermanSoftware.CompareNetObjects.CompareLogic; -#endif - using Microsoft.ApplicationInsights.TestFramework; [TestClass] public class EventTelemetryTest @@ -126,7 +124,6 @@ public void EventTelemetryImplementsISupportSamplingContract() Assert.IsNotNull(telemetry as ISupportSampling); } -#if !NETCOREAPP1_1 [TestMethod] public void EventTelemetryDeepCloneCopiesAllProperties() { @@ -141,7 +138,6 @@ public void EventTelemetryDeepCloneCopiesAllProperties() var result = deepComparator.Compare(eventTelemetry, other); Assert.IsTrue(result.AreEqual, result.DifferencesString); } -#endif [TestMethod] public void EventTelemetryHasCorrectValueOfSamplingPercentageAfterSerialization() diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs index e305ae9a76..556884d0f7 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs @@ -14,9 +14,7 @@ using Microsoft.ApplicationInsights.TestFramework; using Microsoft.VisualStudio.TestTools.UnitTesting; -#if !NETCOREAPP1_1 using CompareLogic = KellermanSoftware.CompareNetObjects.CompareLogic; -#endif [TestClass] public class ExceptionTelemetryTest @@ -456,7 +454,6 @@ public void ExceptionTelemetryHasCorrectValueOfSamplingPercentageAfterSerializat Assert.AreEqual(10, item.sampleRate); } -#if !NETCOREAPP1_1 [TestMethod] public void ExceptionTelemetryDeepCloneCopiesAllProperties() { @@ -468,7 +465,6 @@ public void ExceptionTelemetryDeepCloneCopiesAllProperties() var result = deepComparator.Compare(telemetry, other); Assert.IsTrue(result.AreEqual, result.DifferencesString); } -#endif private static Exception CreateExceptionWithStackTrace() { diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs index 1f0fe7a856..4d2b232e10 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs @@ -6,10 +6,7 @@ using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.VisualStudio.TestTools.UnitTesting; - -#if !NETCOREAPP1_1 using CompareLogic = KellermanSoftware.CompareNetObjects.CompareLogic; -#endif using System.Collections.Generic; using Microsoft.ApplicationInsights.TestFramework; @@ -276,7 +273,6 @@ public void CountPropertyGetterReturnsOneIfNoValueIsSet() Assert.AreEqual(1, telemetry.Count); } -#if !NETCOREAPP1_1 [TestMethod] public void MetricTelemetryDeepCloneCopiesAllProperties() { @@ -298,6 +294,5 @@ public void MetricTelemetryDeepCloneCopiesAllProperties() var comparisonResult = deepComparator.Compare(metric, other); Assert.IsTrue(comparisonResult.AreEqual, comparisonResult.DifferencesString); } -#endif } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs index eac2cc2df6..fb80ef3a62 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs @@ -11,10 +11,7 @@ using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.ApplicationInsights.TestFramework; using Microsoft.VisualStudio.TestTools.UnitTesting; - -#if !NETCOREAPP1_1 using CompareLogic = KellermanSoftware.CompareNetObjects.CompareLogic; -#endif [TestClass] @@ -137,7 +134,6 @@ public void PageViewTelemetryHasCorrectValueOfSamplingPercentageAfterSerializati Assert.AreEqual(10, item.sampleRate); } -#if !NETCOREAPP1_1 [TestMethod] public void PageViewTelemetryDeepCloneCopiesAllProperties() { @@ -153,6 +149,5 @@ public void PageViewTelemetryDeepCloneCopiesAllProperties() var result = deepComparator.Compare(pageView, other); Assert.IsTrue(result.AreEqual, result.DifferencesString); } -#endif } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PerformanceCounterTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PerformanceCounterTelemetryTest.cs index b23dff87c8..3090843237 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PerformanceCounterTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PerformanceCounterTelemetryTest.cs @@ -4,9 +4,7 @@ using Microsoft.ApplicationInsights.Channel; using Microsoft.VisualStudio.TestTools.UnitTesting; -#if !NETCOREAPP1_1 using CompareLogic = KellermanSoftware.CompareNetObjects.CompareLogic; -#endif [TestClass] public class PerformanceCounterTelemetryTest @@ -36,7 +34,6 @@ public void ContextPropertiesUsedAsTelemetryItemProperties() Assert.AreEqual("b", item.Properties["a"]); } -#if !NETCOREAPP1_1 [TestMethod] public void PerformanceCounterTelemetryDeepCloneCopiesAllProperties() { @@ -51,7 +48,6 @@ public void PerformanceCounterTelemetryDeepCloneCopiesAllProperties() var result = deepComparator.Compare(item, other); Assert.IsTrue(result.AreEqual, result.DifferencesString); } -#endif #pragma warning restore 618 } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/RequestTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/RequestTelemetryTest.cs index d2105a79d4..7d46b1a371 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/RequestTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/RequestTelemetryTest.cs @@ -11,9 +11,7 @@ using Microsoft.ApplicationInsights.TestFramework; using Microsoft.VisualStudio.TestTools.UnitTesting; -#if !NETCOREAPP1_1 using KellermanSoftware.CompareNetObjects; -#endif [TestClass] public class RequestTelemetryTest @@ -218,7 +216,6 @@ public void RequestTelemetryHasCorrectValueOfSamplingPercentageAfterSerializatio Assert.AreEqual(10, item.sampleRate); } -#if !NETCOREAPP1_1 [TestMethod] public void RequestTelemetryDeepCloneCopiesAllProperties() { @@ -232,7 +229,6 @@ public void RequestTelemetryDeepCloneCopiesAllProperties() var result = deepComparator.Compare(request, other); Assert.IsTrue(result.AreEqual, result.DifferencesString); } -#endif private RequestTelemetry CreateTestTelemetry() { diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/SessionStateTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/SessionStateTelemetryTest.cs index ea6d94bb41..0a903602d9 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/SessionStateTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/SessionStateTelemetryTest.cs @@ -4,9 +4,7 @@ using Microsoft.ApplicationInsights.Channel; using Microsoft.VisualStudio.TestTools.UnitTesting; -#if !NETCOREAPP1_1 using KellermanSoftware.CompareNetObjects; -#endif [TestClass] public class SessionStateTelemetryTest @@ -57,7 +55,6 @@ public void SerializeWritesStateAsExpectedByEndpoint() Assert.AreEqual(2, envelope.data.baseData.ver); } -#if !NETCOREAPP1_1 [TestMethod] public void SessionStateTelemetryDeepCloneCopiesAllProperties() { @@ -70,7 +67,6 @@ public void SessionStateTelemetryDeepCloneCopiesAllProperties() var result = deepComparator.Compare(telemetry, other); Assert.IsTrue(result.AreEqual, result.DifferencesString); } -#endif #pragma warning restore 618 } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TraceTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TraceTelemetryTest.cs index ac1209bd6a..9f2f589105 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TraceTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TraceTelemetryTest.cs @@ -7,9 +7,7 @@ using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.VisualStudio.TestTools.UnitTesting; -#if !NETCOREAPP1_1 using CompareLogic = KellermanSoftware.CompareNetObjects.CompareLogic; -#endif using System.Collections.Generic; using Microsoft.ApplicationInsights.TestFramework; @@ -148,7 +146,6 @@ public void TraceTelemetryHasCorrectValueOfSamplingPercentageAfterSerialization( Assert.AreEqual(10, item.sampleRate); } -#if !NETCOREAPP1_1 [TestMethod] public void TraceTelemetryDeepCloneCopiesAllProperties() { @@ -165,6 +162,5 @@ public void TraceTelemetryDeepCloneCopiesAllProperties() Assert.IsTrue(result.AreEqual, result.DifferencesString); } -#endif } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/Tracing/HeartbeatTests.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/Tracing/HeartbeatTests.cs new file mode 100644 index 0000000000..252098239c --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/Tracing/HeartbeatTests.cs @@ -0,0 +1,378 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Linq; + using Microsoft.ApplicationInsights.DataContracts; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class HealthHeartbeatTests + { + [TestMethod] + public void InitializeHealthHeartbeatDoesntThrow() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + } + } + + [TestMethod] + public void InitializeHealthHeartbeatTwiceDoesntFail() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + hbeat.Initialize(configuration: null); + } + } + + [TestMethod] + public void InitializeHealthHeartbeatDefaultsAreSetProperly() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + Assert.IsTrue(hbeat.ExcludedHeartbeatProperties == null || hbeat.ExcludedHeartbeatProperties.Count() == 0); + Assert.AreEqual(hbeat.HeartbeatInterval, HeartbeatProvider.DefaultHeartbeatInterval); + } + } + + [TestMethod] + public void InitializeHealthHeartbeatWithNonDefaultInterval() + { + TimeSpan userSetInterval = TimeSpan.FromMilliseconds(HeartbeatProvider.MinimumHeartbeatInterval.TotalMilliseconds + 7852.0); + + using (var initializedModule = new DiagnosticsTelemetryModule()) + { + // set the interval via the IHeartbeatPropertyManager interface + IHeartbeatPropertyManager hbeat = initializedModule; + Assert.AreNotEqual(userSetInterval, hbeat.HeartbeatInterval); + hbeat.HeartbeatInterval = userSetInterval; + + // initialize the DiagnosticsTelemetryModule, and check that the interval is stil intact + initializedModule.Initialize(new TelemetryConfiguration()); + Assert.AreEqual(userSetInterval, hbeat.HeartbeatInterval); + } + } + + [TestMethod] + public void InitializeHeartbeatWithZeroIntervalIsSetToMinimum() + { + using (var hbeat = new HeartbeatProvider() { HeartbeatInterval = TimeSpan.FromMilliseconds(0) }) + { + hbeat.Initialize(configuration: null); + Assert.AreEqual(hbeat.HeartbeatInterval, HeartbeatProvider.MinimumHeartbeatInterval); + } + } + + [TestMethod] + public void SetHeartbeatWithSmallerThanMinimumIntervalIsSetToMinimum() + { + var tooSmallInterval = TimeSpan.FromMilliseconds(HeartbeatProvider.MinimumHeartbeatInterval.TotalMilliseconds / 2); + using (var hbeat = new HeartbeatProvider() { HeartbeatInterval = tooSmallInterval }) + { + hbeat.Initialize(configuration: null); + Assert.AreEqual(hbeat.HeartbeatInterval, HeartbeatProvider.MinimumHeartbeatInterval); + } + } + + [TestMethod] + public void CanExtendHeartbeatPayload() + { + + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: new TelemetryConfiguration()); + + try + { + Assert.IsTrue(hbeat.AddHealthProperty("test01", "this is a value", true)); + } + catch (Exception e) + { + Assert.Fail(string.Format(CultureInfo.CurrentCulture, "Registration of a heartbeat payload provider throws exception '{0}", e.ToInvariantString())); + } + } + } + + [TestMethod] + public void IsHeartbeatEnabledByDefault() + { + using (var initializedModule = new DiagnosticsTelemetryModule()) + { + // test that the heartbeat is enabled by default + IHeartbeatPropertyManager hbeat = initializedModule; + Assert.IsTrue(hbeat.IsHeartbeatEnabled); + + // initialize the DiagnosticsTelemetryModule, and check that heartbeats are still enabled + initializedModule.Initialize(new TelemetryConfiguration()); + Assert.IsTrue(hbeat.IsHeartbeatEnabled); + } + } + + [TestMethod] + public void CanDisableHeartbeatPriorToInitialize() + { + using (var initializedModule = new DiagnosticsTelemetryModule()) + { + // disable the heartbeat at construction time but before initialize + // (this simulates the flow of disabling the heartbeat via config) + IHeartbeatPropertyManager hbeat = initializedModule; + hbeat.IsHeartbeatEnabled = false; + + // initialize the DiagnosticsTelemetryModule, and check that heartbeats are still disabled + initializedModule.Initialize(new TelemetryConfiguration()); + Assert.IsFalse(hbeat.IsHeartbeatEnabled); + + // dig into the heartbeat provider itself to ensure this is indeed disabled + Assert.IsFalse(initializedModule.HeartbeatProvider.IsHeartbeatEnabled); + } + } + + [TestMethod] + public void DiagnosticsTelemetryModuleCreatesHeartbeatModule() + { + using (var diagModule = new DiagnosticsTelemetryModule()) + { + diagModule.Initialize(new TelemetryConfiguration()); + Assert.IsNotNull(diagModule.HeartbeatProvider); + } + } + + [TestMethod] + public void HeartbeatPayloadContainsDataByDefault() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + var hbeatPayloadData = hbeat.GatherData(); + Assert.IsNotNull(hbeatPayloadData); + } + } + + [TestMethod] + public void HeartbeatPayloadContainsUserSpecifiedData() + { + using (var hbeat = new HeartbeatProvider()) + { + string testerKey = "tester123"; + Assert.IsTrue(hbeat.AddHealthProperty(testerKey, "test", true)); + hbeat.Initialize(configuration: null); + + MetricTelemetry payload = (MetricTelemetry)hbeat.GatherData(); + + Assert.IsTrue(payload.Properties.Any( + a => a.Key.Equals(testerKey, StringComparison.OrdinalIgnoreCase)), + "Provided custom payload provider to heartbeat but never received any messages with its content"); + } + } + + [TestMethod] + public void HeartbeatPayloadContainsOnlyAllowedDefaultPayloadFields() + { + using (var hbeat = new HeartbeatProvider()) + { + List disableHbProps = new List(); + + for (int i = 0; i < HeartbeatDefaultPayload.DefaultFields.Length; ++i) + { + if (i % 2 == 0) + { + disableHbProps.Add(HeartbeatDefaultPayload.DefaultFields[i]); + hbeat.ExcludedHeartbeatProperties.Add(HeartbeatDefaultPayload.DefaultFields[i]); + } + } + + hbeat.Initialize(configuration: null); + + var sentHeartBeat = (MetricTelemetry)hbeat.GatherData(); + + Assert.IsNotNull(sentHeartBeat); + + foreach (var kvp in sentHeartBeat.Properties) + { + Assert.IsFalse(disableHbProps.Contains(kvp.Key), + string.Format(CultureInfo.CurrentCulture, "Dissallowed field '{0}' found in payload", kvp.Key)); + } + } + } + + [TestMethod] + public void HeartbeatMetricIsZeroForNoFailureConditionPresent() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + var msg = (MetricTelemetry)hbeat.GatherData(); + Assert.IsFalse(msg.Sum > 0.0); + } + } + + [TestMethod] + public void HeartbeatMetricIsNonZeroWhenFailureConditionPresent() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + string testerKey = "tester123"; + hbeat.AddHealthProperty(testerKey, "test", false); + + var msg = (MetricTelemetry)hbeat.GatherData(); + Assert.IsTrue(msg.Sum >= 1.0); + } + } + + [TestMethod] + public void HeartbeatMetricCountAccountsForAllFailures() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + + var msg = (MetricTelemetry)hbeat.GatherData(); + Assert.IsTrue(msg.Sum == 0.0); + + hbeat.AddHealthProperty("tester01", "test failure 1", false); + hbeat.AddHealthProperty("tester02", "test failure 2", false); + msg = (MetricTelemetry)hbeat.GatherData(); + + Assert.IsTrue(msg.Sum == 2.0); + } + } + + [TestMethod] + public void SentHeartbeatContainsExpectedDefaultFields() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + + var msg = (MetricTelemetry)hbeat.GatherData(); + Assert.IsNotNull(msg); + + foreach (string field in HeartbeatDefaultPayload.DefaultFields) + { + try + { + var fieldPayload = msg.Properties.Single(a => string.Compare(a.Key, field) == 0); + Assert.IsNotNull(fieldPayload); + Assert.IsFalse(string.IsNullOrEmpty(fieldPayload.Value)); + } + catch (Exception) + { + Assert.Fail(string.Format(CultureInfo.CurrentCulture, "The default field '{0}' is not present exactly once in a sent message.", field)); + } + } + } + } + + [TestMethod] + public void HeartbeatProviderDoesNotAllowDuplicatePropertyName() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + + Assert.IsTrue(hbeat.AddHealthProperty("test01", "some test value", true)); + Assert.IsFalse(hbeat.AddHealthProperty("test01", "some other test value", true)); + } + } + + [TestMethod] + public void CannotSetPayloadExtensionWithoutAddingItFirst() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + + Assert.IsFalse(hbeat.SetHealthProperty("test01", "some other test value", true)); + Assert.IsTrue(hbeat.AddHealthProperty("test01", "some test value", true)); + Assert.IsTrue(hbeat.SetHealthProperty("test01", "some other test value", true)); + } + } + + [TestMethod] + public void CannotSetValueOfDefaultPayloadProperties() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + + foreach (string key in HeartbeatDefaultPayload.DefaultFields) + { + Assert.IsFalse(hbeat.SetHealthProperty(key, "test", true)); + } + } + } + + [TestMethod] + public void CannotAddPayloadItemNamedOfDefaultPayloadProperties() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + + foreach (string key in HeartbeatDefaultPayload.DefaultFields) + { + Assert.IsFalse(hbeat.AddHealthProperty(key, "test", true)); + } + } + } + + [TestMethod] + public void EnsureAllTargetFrameworksRepresented() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + + var msg = (MetricTelemetry)hbeat.GatherData(); + + Assert.IsTrue(msg.Properties.ContainsKey("baseSdkTargetFramework")); + Assert.IsFalse(msg.Properties["baseSdkTargetFramework"].Equals("undefined", StringComparison.OrdinalIgnoreCase)); + } + } + + [TestMethod] + public void CanSetHealthHeartbeatPayloadValueWithoutHealthyFlag() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + + string key = "setValueTest"; + + Assert.IsTrue(hbeat.AddHealthProperty(key, "value01", true)); + Assert.IsTrue(hbeat.SetHealthProperty(key, "value02")); + var msg = (MetricTelemetry)hbeat.GatherData(); + + Assert.IsNotNull(msg); + Assert.IsTrue(msg.Properties.ContainsKey(key)); + Assert.IsTrue(msg.Properties[key].Equals("value02", StringComparison.Ordinal)); + } + } + + [TestMethod] + public void CanSetHealthHeartbeatPayloadHealthIndicatorWithoutSettingValue() + { + using (var hbeat = new HeartbeatProvider()) + { + hbeat.Initialize(configuration: null); + + string key = "healthSettingTest"; + + Assert.IsTrue(hbeat.AddHealthProperty(key, "value01", true)); + Assert.IsTrue(hbeat.SetHealthProperty(key, null, false)); + var msg = (MetricTelemetry)hbeat.GatherData(); + + Assert.IsNotNull(msg); + Assert.IsTrue(msg.Properties.ContainsKey(key)); + Assert.IsTrue(msg.Properties[key].Equals("value01", StringComparison.Ordinal)); + Assert.IsTrue(msg.Sum == 1.0); // one false message in payload only + } + } + } +} diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Microsoft.ApplicationInsights.Shared.Tests.projitems b/Test/Microsoft.ApplicationInsights.Test/Shared/Microsoft.ApplicationInsights.Shared.Tests.projitems index b7ada9891f..16036f0b4a 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Microsoft.ApplicationInsights.Shared.Tests.projitems +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Microsoft.ApplicationInsights.Shared.Tests.projitems @@ -33,6 +33,7 @@ + diff --git a/Test/Microsoft.ApplicationInsights.Test/Standalone/Microsoft.ApplicationInsights.Isolated.Tests.csproj b/Test/Microsoft.ApplicationInsights.Test/Standalone/Microsoft.ApplicationInsights.Isolated.Tests.csproj index daa8bf52cc..4f29c18443 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Standalone/Microsoft.ApplicationInsights.Isolated.Tests.csproj +++ b/Test/Microsoft.ApplicationInsights.Test/Standalone/Microsoft.ApplicationInsights.Isolated.Tests.csproj @@ -15,18 +15,14 @@ true - - - {e9ecee96-dd50-42f6-9f33-0978cdfa15ed} - Microsoft.ApplicationInsights - - - {4b0bc3b7-c7fc-4333-9e28-5790d9153f07} - ApplicationInsightsTypes - - + + false + netstandard1.3 + - + + + @@ -60,14 +56,12 @@ - - All All diff --git a/Test/Microsoft.ApplicationInsights.Test/netcoreapp11/Microsoft.ApplicationInsights.netcoreapp11.Tests.csproj b/Test/Microsoft.ApplicationInsights.Test/netcoreapp11/Microsoft.ApplicationInsights.netcoreapp11.Tests.csproj index 731af6df76..0fe06278b2 100644 --- a/Test/Microsoft.ApplicationInsights.Test/netcoreapp11/Microsoft.ApplicationInsights.netcoreapp11.Tests.csproj +++ b/Test/Microsoft.ApplicationInsights.Test/netcoreapp11/Microsoft.ApplicationInsights.netcoreapp11.Tests.csproj @@ -15,30 +15,16 @@ - - {e9ecee96-dd50-42f6-9f33-0978cdfa15ed} - Microsoft.ApplicationInsights - - - {4b0bc3b7-c7fc-4333-9e28-5790d9153f07} - ApplicationInsightsTypes - - - - + + - + - All All diff --git a/Test/ServerTelemetryChannel.Test/Net45.Tests/TelemetryChannel.Net45.Tests.csproj b/Test/ServerTelemetryChannel.Test/Net45.Tests/TelemetryChannel.Net45.Tests.csproj index f9dfe72327..badc3e2bf1 100644 --- a/Test/ServerTelemetryChannel.Test/Net45.Tests/TelemetryChannel.Net45.Tests.csproj +++ b/Test/ServerTelemetryChannel.Test/Net45.Tests/TelemetryChannel.Net45.Tests.csproj @@ -17,27 +17,19 @@ true - - - {e9ecee96-dd50-42f6-9f33-0978cdfa15ed} - Microsoft.ApplicationInsights - - - {4b0bc3b7-c7fc-4333-9e28-5790d9153f07} - ApplicationInsightsTypes - - + + false + netstandard1.3 + - + + + - + @@ -46,15 +38,15 @@ All All - + {3273d899-d9b3-44fe-b3ab-578e18b2ef90} TelemetryChannel - - + + \ No newline at end of file diff --git a/Test/ServerTelemetryChannel.Test/NetCore.Tests/TelemetryChannel.NetCore.Tests.csproj b/Test/ServerTelemetryChannel.Test/NetCore.Tests/TelemetryChannel.NetCore.Tests.csproj index a6f1724f24..fbb89a1489 100644 --- a/Test/ServerTelemetryChannel.Test/NetCore.Tests/TelemetryChannel.NetCore.Tests.csproj +++ b/Test/ServerTelemetryChannel.Test/NetCore.Tests/TelemetryChannel.NetCore.Tests.csproj @@ -17,17 +17,8 @@ - - {e9ecee96-dd50-42f6-9f33-0978cdfa15ed} - Microsoft.ApplicationInsights - - - {4b0bc3b7-c7fc-4333-9e28-5790d9153f07} - ApplicationInsightsTypes - - - - + + @@ -41,23 +32,15 @@ - + - All All - - {3273d899-d9b3-44fe-b3ab-578e18b2ef90} - TelemetryChannel - + - + diff --git a/Test/ServerTelemetryChannel.Test/Shared.Tests/AdaptiveSamplingTelemetryProcessorTest.cs b/Test/ServerTelemetryChannel.Test/Shared.Tests/AdaptiveSamplingTelemetryProcessorTest.cs index c9e9a74670..3508ff2446 100644 --- a/Test/ServerTelemetryChannel.Test/Shared.Tests/AdaptiveSamplingTelemetryProcessorTest.cs +++ b/Test/ServerTelemetryChannel.Test/Shared.Tests/AdaptiveSamplingTelemetryProcessorTest.cs @@ -196,6 +196,81 @@ public void SamplingPercentageAdjustsForSpikyProductionRate() Assert.IsTrue(sentTelemetry.Count < targetItemCount + tolerance); } + private class AdaptiveTesterMessageSink : ITelemetryProcessor + { + public Queue requests = new Queue(); + public Queue events = new Queue(); + + public void Process(ITelemetry item) + { + if (item is RequestTelemetry req) + { + requests.Enqueue(req); + } + else if (item is EventTelemetry evt) + { + events.Enqueue(evt); + } + } + } + + [TestMethod] + public void SamplingRoutesExcludedTypes() + { + var unsampled = new AdaptiveTesterMessageSink(); + var sampled = new AdaptiveTesterMessageSink(); + SamplingTelemetryProcessor sampler = new SamplingTelemetryProcessor(unsampled,sampled); + + sampler.ExcludedTypes = "Request"; + sampler.SamplingPercentage = 100.0; + + sampler.Process(new RequestTelemetry()); + sampler.Process(new EventTelemetry()); + + Assert.IsNotNull(sampled.events.Dequeue()); + Assert.IsNotNull(unsampled.requests.Dequeue()); + } + + [TestMethod] + public void SamplingWontEarlyExitWhenUnsampledNextPresent() + { + var unsampled = new AdaptiveTesterMessageSink(); + var sampled = new AdaptiveTesterMessageSink(); + SamplingTelemetryProcessor sampler = new SamplingTelemetryProcessor(unsampled, sampled) + { + SamplingPercentage = 100.0 + }; + + sampler.Process(new RequestTelemetry()); + Assert.IsTrue(sampled.requests.Count == 1); + var sent = sampled.requests.Dequeue(); + Assert.IsNotNull(sent); + var sentSample = sent as ISupportSampling; + Assert.IsNotNull(sentSample); + Assert.IsTrue(sentSample.SamplingPercentage.HasValue); + } + + [TestMethod] + public void SamplingSkipsSampledTelemetryItemProperty() + { + var unsampled = new AdaptiveTesterMessageSink(); + var sampled = new AdaptiveTesterMessageSink(); + SamplingTelemetryProcessor sampler = new SamplingTelemetryProcessor(unsampled, sampled) + { + SamplingPercentage = 100.0 + }; + + var send = new RequestTelemetry(); + var sendSampled = (send as ISupportSampling); + Assert.IsNotNull(sendSampled); + sendSampled.SamplingPercentage = 25.0; + + sampler.Process(send); + + Assert.IsTrue(unsampled.requests.Count == 1); + Assert.IsTrue(sampled.requests.Count == 0); + } + [TestMethod] public void AdaptiveSamplingSetsExcludedTypesOnInternalSamplingProcessor() { diff --git a/Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/ApplicationFolderProviderTest.cs b/Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/ApplicationFolderProviderTest.cs index bbd34bb888..ef33b1bb2f 100644 --- a/Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/ApplicationFolderProviderTest.cs +++ b/Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/ApplicationFolderProviderTest.cs @@ -167,7 +167,7 @@ public void GetApplicationFolderReturnsSubfolderFromTempFolderIfLocalAppDataIsTo } [TestMethod] - public void GetApplicationFolderReturnsNullWhenNeitherLocalAppDataNorTempFolderIsAccessible() + public void GetApplicationFolderReturnsNullWhenNeitherLocalAppDataNorTempFoldersAreAccessible() { var environmentVariables = new Hashtable { @@ -181,6 +181,25 @@ public void GetApplicationFolderReturnsNullWhenNeitherLocalAppDataNorTempFolderI Assert.IsNull(applicationFolder); } + [TestMethod] + public void GetApplicationFolderReturnsNullWhenUnableToSetSecurityPolicyOnDirectory() + { + var environmentVariables = new Hashtable + { + { "LOCALAPPDATA", this.CreateTestDirectory(@"AppData\Local").FullName }, + { "TEMP", this.CreateTestDirectory("Temp").FullName }, + }; + + var provider = new ApplicationFolderProvider(environmentVariables); + + // Override to return false indicating applying security failed. + provider.OverrideApplySecurityToDirectory( (dirInfo) => { return false; } ); + + IPlatformFolder applicationFolder = provider.GetApplicationFolder(); + + Assert.IsNull(applicationFolder); + } + [TestMethod] public void GetApplicationFolderReturnsNullWhenFolderAlreadyExistsButDeniesRightToListDirectoryContents() { diff --git a/Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/SamplingScoreGeneratorTest.cs b/Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/SamplingScoreGeneratorTest.cs index 836d8b5479..bfdbc336c7 100644 --- a/Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/SamplingScoreGeneratorTest.cs +++ b/Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/SamplingScoreGeneratorTest.cs @@ -15,22 +15,30 @@ public class SamplingScoreGeneratorTest private static readonly Random Rand = new Random(); [TestMethod] - public void SamplingScoreGeneratedUsingUserIdIfPresent() + public void SamplingScoreIsntChangedByUserId() { - string userId = GenerateRandomUserId(); + string opId = GenerateRandomOperaitonId(); var eventTelemetry = new EventTelemetry(); - eventTelemetry.Context.User.Id = userId; - eventTelemetry.Context.Operation.Id = GenerateRandomOperaitonId(); + eventTelemetry.Context.Operation.Id = opId; + eventTelemetry.Context.User.Id = GenerateRandomUserId(); var requestTelemetry = new RequestTelemetry(); - requestTelemetry.Context.User.Id = userId; - requestTelemetry.Context.Operation.Id = GenerateRandomOperaitonId(); + requestTelemetry.Context.Operation.Id = opId; + requestTelemetry.Context.User.Id = GenerateRandomUserId(); - var eventTelemetrySamplingScore = SamplingScoreGenerator.GetSamplingScore(eventTelemetry); - var requestTelemetrySamplingScore = SamplingScoreGenerator.GetSamplingScore(requestTelemetry); + var eventTelemetrySamplingScoreNoUserId = SamplingScoreGenerator.GetSamplingScore(eventTelemetry); + var requestTelemetrySamplingScoreNoUserId = SamplingScoreGenerator.GetSamplingScore(requestTelemetry); - Assert.AreEqual(eventTelemetrySamplingScore, requestTelemetrySamplingScore, 12); + Assert.AreEqual(eventTelemetrySamplingScoreNoUserId, requestTelemetrySamplingScoreNoUserId, 12); + + eventTelemetry.Context.User.Id = string.Empty; + requestTelemetry.Context.User.Id = string.Empty; + var eventTelemetrySamplingScoreWithUserId = SamplingScoreGenerator.GetSamplingScore(eventTelemetry); + var requestTelemetrySamplingScoreWithUserId = SamplingScoreGenerator.GetSamplingScore(requestTelemetry); + + Assert.AreEqual(eventTelemetrySamplingScoreNoUserId, eventTelemetrySamplingScoreWithUserId); + Assert.AreEqual(requestTelemetrySamplingScoreNoUserId, requestTelemetrySamplingScoreWithUserId); } [TestMethod] diff --git a/Test/ServerTelemetryChannel.Test/Shared.Tests/SamplingTelemetryProcessorTest.cs b/Test/ServerTelemetryChannel.Test/Shared.Tests/SamplingTelemetryProcessorTest.cs index 69904c316d..e12ae6f92a 100644 --- a/Test/ServerTelemetryChannel.Test/Shared.Tests/SamplingTelemetryProcessorTest.cs +++ b/Test/ServerTelemetryChannel.Test/Shared.Tests/SamplingTelemetryProcessorTest.cs @@ -50,9 +50,9 @@ public void TelemetryItemHasSamplingPercentageSet() { var sentTelemetry = new List(); var processor = new SamplingTelemetryProcessor(new StubTelemetryProcessor(null) { OnProcess = t => sentTelemetry.Add(t) }) - { - SamplingPercentage = 20 - }; + { + SamplingPercentage = 20 + }; do { @@ -63,6 +63,20 @@ public void TelemetryItemHasSamplingPercentageSet() Assert.AreEqual(20, ((ISupportSampling)sentTelemetry[0]).SamplingPercentage); } + [TestMethod] + public void EarlyExitWhenProcessingAt100Percent() + { + var sentTelemetry = new List(); + var processor = new SamplingTelemetryProcessor(new StubTelemetryProcessor(null) { OnProcess = t => sentTelemetry.Add(t) }) + { + SamplingPercentage = 100.0 + }; + + processor.Process(new RequestTelemetry()); + + Assert.IsFalse(((ISupportSampling)sentTelemetry[0]).SamplingPercentage.HasValue); + } + [TestMethod] public void TelemetryItemSamplingIsSkippedWhenSetByUser() { diff --git a/Test/ServerTelemetryChannel.Test/TelemetryChannel.Nuget.Tests/TelemetryChannel.Nuget.Tests.csproj b/Test/ServerTelemetryChannel.Test/TelemetryChannel.Nuget.Tests/TelemetryChannel.Nuget.Tests.csproj index ef8cbf9c7a..5a0634ffb1 100644 --- a/Test/ServerTelemetryChannel.Test/TelemetryChannel.Nuget.Tests/TelemetryChannel.Nuget.Tests.csproj +++ b/Test/ServerTelemetryChannel.Test/TelemetryChannel.Nuget.Tests/TelemetryChannel.Nuget.Tests.csproj @@ -16,49 +16,35 @@ true - - - {e9ecee96-dd50-42f6-9f33-0978cdfa15ed} - Microsoft.ApplicationInsights - - - {4b0bc3b7-c7fc-4333-9e28-5790d9153f07} - ApplicationInsightsTypes - - + + false + netstandard1.3 + - + + + - + - All All - - {3273d899-d9b3-44fe-b3ab-578e18b2ef90} - TelemetryChannel - - - - + + Resources\ApplicationInsights.config.install.xdt - + Resources\ApplicationInsights.config.transform - + Resources\ApplicationInsights.config.uninstall.xdt diff --git a/dirs.proj b/dirs.proj index ac40bc5eec..7ed73ab6e8 100644 --- a/dirs.proj +++ b/dirs.proj @@ -5,7 +5,9 @@ - + + diff --git a/docs/ExtendingHeartbeatProperties.md b/docs/ExtendingHeartbeatProperties.md new file mode 100644 index 0000000000..81a4006e0a --- /dev/null +++ b/docs/ExtendingHeartbeatProperties.md @@ -0,0 +1,98 @@ +_This document was last updated 11/25/2016 and is applicable to SDK version 2.5.0-beta2._ + +# Extending Heartbeat Properties in Application Insights # + +The .NET Application Insights SDKs provide a new feature called Health Heartbeat. This feature +sends health related data as well as environment-specific information at pre-configured +intervals. The feature will allow you to extend the properties that will be sent every interval, +and will also allow you to set a flag denoting a healthy or unhealthy status for each property +you add to the heartbeat payload. + +## A General Code Example ## + +In order to add the extended properties of your choice to the Health Heartbeat as a developer +of an ITelemetryModule, you can follow the following pattern. Note that you must first add the +properties you want to include in the payload, and you can update (via set) the vaules and health +status of those properties for the duration of the application life cycle. + +To add the payload properties, aquire the IHeartbeatPropertyManager module using the internal +`TelemetryModules` singleton. One way in which you could do this is from inside your +`Initialize(TelemetryConfiguration telemetryConfig)` implementation method, and then iterate +through the available modules looking for an implementation of `IHeartbeatPropertyManager`: + + using Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing; + ... + // heartbeat property manager to add/update my health properties into: + private IHeartbeatPropertyManager heartbeatManager= null; + ... + public void Initialize(TelemetryConfiguration configuration) + { + ... + var modules = TelemetryModules.Instance; + foreach (var telemetryModule in modules.Modules) + { + if (telemetryModule is IHeartbeatPropertyManager) + { + this.heartbeatManager = telemetryModule as IHeartbeatPropertyManager; + break; + } + } + ... + +...now you will have a heartbeat property manager that you can work with (or not, remember to +test!). From here (but likely still within your `Initialize` method, you can Add the health +property fields that you want to see in the heartbeat payload for the duration of the +application's lifecycle. + + ... + this.heartbeatManager.AddHealthProperty(propertyName: "myHealthProperty", propertyValue: this.MyHealthProperty, isHealthy: true); + ... + +Outside of your `Initialize` method, you can update the values you've added by using the +`SetHealthProperty` method very simply. For instance, you can add a health property called +'myHealthProperty' in the initialize method as above, and then from within a property elsewhere +in your class, you can update the value in the heartbeat payload as follows: + + public string MyHealthProperty + { + get => this.myHealthPropertyValue; + + set + { + this.myHealthPropertyValue = value; + if (this.heartbeatManager != null) + { + bool myPropIsHealthy = this.SomeTestForHealthStatus(this.myHealthPropertyValue); + this.heartbeatManager.SetHealthProperty(propertyName: "myHealthProperty", propertyValue: value, isHealthy: myPropIsHealthy); + } + } + } + +Using the above example you can add and update properties in the Health Heartbeat for the +duration of your application's life. + +> **Note:** You may also set values for the `HeartbeatInterval` value. This is discouraged, as +your override of this value may adversely affect the consumer's ApplicationInsights.config +configuration in doing so. + +You can also set values into the `ExcludedHeartbeatProperties` list if you find it pertinent to +do so. Setting values into the `ExcludedHeartbeatProperties` is fine, as your module may provide +more detailed information about one of the many SDK-supplied default fields, and in these cases it +is better to remove the redundancy. + +## A Working Example of Extending Properties ## + +As of the writing of this document we have made the implementation of ITelemetryModule authors +with a way to extend the content of the heartbeat payload. An example of this has been +constructed in the Microsoft.ApplicationInsights.Web assembly, and can be reviewed here: + +https://github.com/Microsoft/ApplicationInsights-dotnet-server/tree/dekeeler/sample-heartbeat-extension + +...specifically, you can see how we've provided extra properties to the health heartbeat in the +FileDiagnosticsTelemetryModule here: + +https://github.com/Microsoft/ApplicationInsights-dotnet-server/blob/2089882ea10a32b88f8d4681eb4819f09a1471bd/Src/HostingStartup/HostingStartup.Net45/FileDiagnosticsTelemetryModule.cs#L134 + +> **NOTE:** This 'working example' requires that the ApplicationInsights.Web solution is updated to +the latest 'develop' nuget package for the base ApplicationInsights SDK. + diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/ActivityExtensions.cs b/src/Microsoft.ApplicationInsights/ActivityExtensions.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/ActivityExtensions.cs rename to src/Microsoft.ApplicationInsights/ActivityExtensions.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Channel/ITelemetry.cs b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Channel/ITelemetry.cs rename to src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Channel/ITelemetryChannel.cs b/src/Microsoft.ApplicationInsights/Channel/ITelemetryChannel.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Channel/ITelemetryChannel.cs rename to src/Microsoft.ApplicationInsights/Channel/ITelemetryChannel.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Channel/InMemoryChannel.cs b/src/Microsoft.ApplicationInsights/Channel/InMemoryChannel.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Channel/InMemoryChannel.cs rename to src/Microsoft.ApplicationInsights/Channel/InMemoryChannel.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Channel/InMemoryTransmitter.cs b/src/Microsoft.ApplicationInsights/Channel/InMemoryTransmitter.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Channel/InMemoryTransmitter.cs rename to src/Microsoft.ApplicationInsights/Channel/InMemoryTransmitter.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Channel/TelemetryBuffer.cs b/src/Microsoft.ApplicationInsights/Channel/TelemetryBuffer.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Channel/TelemetryBuffer.cs rename to src/Microsoft.ApplicationInsights/Channel/TelemetryBuffer.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Channel/Transmission.cs b/src/Microsoft.ApplicationInsights/Channel/Transmission.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Channel/Transmission.cs rename to src/Microsoft.ApplicationInsights/Channel/Transmission.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Constants.cs b/src/Microsoft.ApplicationInsights/Constants.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Constants.cs rename to src/Microsoft.ApplicationInsights/Constants.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/AvailabilityTelemetry.cs rename to src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/DependencyTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/DependencyTelemetry.cs rename to src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/EventTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/EventTelemetry.cs rename to src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/ExceptionHandledAt.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionHandledAt.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/ExceptionHandledAt.cs rename to src/Microsoft.ApplicationInsights/DataContracts/ExceptionHandledAt.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/ExceptionTelemetry.cs rename to src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/IJsonWriter.cs b/src/Microsoft.ApplicationInsights/DataContracts/IJsonWriter.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/IJsonWriter.cs rename to src/Microsoft.ApplicationInsights/DataContracts/IJsonWriter.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/ISupportMetrics.cs b/src/Microsoft.ApplicationInsights/DataContracts/ISupportMetrics.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/ISupportMetrics.cs rename to src/Microsoft.ApplicationInsights/DataContracts/ISupportMetrics.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/ISupportProperties.cs b/src/Microsoft.ApplicationInsights/DataContracts/ISupportProperties.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/ISupportProperties.cs rename to src/Microsoft.ApplicationInsights/DataContracts/ISupportProperties.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/ISupportSampling.cs b/src/Microsoft.ApplicationInsights/DataContracts/ISupportSampling.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/ISupportSampling.cs rename to src/Microsoft.ApplicationInsights/DataContracts/ISupportSampling.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/InnerExceptionCountExceededException.cs b/src/Microsoft.ApplicationInsights/DataContracts/InnerExceptionCountExceededException.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/InnerExceptionCountExceededException.cs rename to src/Microsoft.ApplicationInsights/DataContracts/InnerExceptionCountExceededException.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/MetricTelemetry.cs rename to src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/PageViewTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/PageViewTelemetry.cs rename to src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/PerformanceCounterTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/PerformanceCounterTelemetry.cs rename to src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/RequestTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/RequestTelemetry.cs rename to src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/SessionState.cs b/src/Microsoft.ApplicationInsights/DataContracts/SessionState.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/SessionState.cs rename to src/Microsoft.ApplicationInsights/DataContracts/SessionState.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/SessionStateTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/SessionStateTelemetry.cs rename to src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/SeverityLevel.cs b/src/Microsoft.ApplicationInsights/DataContracts/SeverityLevel.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/SeverityLevel.cs rename to src/Microsoft.ApplicationInsights/DataContracts/SeverityLevel.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/TelemetryContext.cs b/src/Microsoft.ApplicationInsights/DataContracts/TelemetryContext.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/TelemetryContext.cs rename to src/Microsoft.ApplicationInsights/DataContracts/TelemetryContext.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/TraceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/DataContracts/TraceTelemetry.cs rename to src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/AutocollectedMetricsExtractor.cs b/src/Microsoft.ApplicationInsights/Extensibility/AutocollectedMetricsExtractor.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/AutocollectedMetricsExtractor.cs rename to src/Microsoft.ApplicationInsights/Extensibility/AutocollectedMetricsExtractor.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/IDebugOutput.cs b/src/Microsoft.ApplicationInsights/Extensibility/IDebugOutput.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/IDebugOutput.cs rename to src/Microsoft.ApplicationInsights/Extensibility/IDebugOutput.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/IMetricProcessor.cs b/src/Microsoft.ApplicationInsights/Extensibility/IMetricProcessor.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/IMetricProcessor.cs rename to src/Microsoft.ApplicationInsights/Extensibility/IMetricProcessor.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/IOperationHolder.cs b/src/Microsoft.ApplicationInsights/Extensibility/IOperationHolder.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/IOperationHolder.cs rename to src/Microsoft.ApplicationInsights/Extensibility/IOperationHolder.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/ITelemetryInitializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/ITelemetryInitializer.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/ITelemetryInitializer.cs rename to src/Microsoft.ApplicationInsights/Extensibility/ITelemetryInitializer.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/ITelemetryModule.cs b/src/Microsoft.ApplicationInsights/Extensibility/ITelemetryModule.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/ITelemetryModule.cs rename to src/Microsoft.ApplicationInsights/Extensibility/ITelemetryModule.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/ITelemetryProcessor.cs b/src/Microsoft.ApplicationInsights/Extensibility/ITelemetryProcessor.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/ITelemetryProcessor.cs rename to src/Microsoft.ApplicationInsights/Extensibility/ITelemetryProcessor.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/BroadcastProcessor.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/BroadcastProcessor.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/BroadcastProcessor.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/BroadcastProcessor.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/CallContextHelpers.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/CallContextHelpers.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/CallContextHelpers.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/CallContextHelpers.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/CloudContext.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/CloudContext.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/CloudContext.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/CloudContext.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/ComponentContext.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/ComponentContext.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/ComponentContext.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/ComponentContext.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/DeviceContext.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/DeviceContext.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/DeviceContext.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/DeviceContext.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/ExceptionConverter.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/ExceptionConverter.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/ExceptionConverter.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/ExceptionConverter.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/AjaxCallData.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AjaxCallData.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/AjaxCallData.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AjaxCallData.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/AvailabilityData.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityData.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/AvailabilityData.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityData.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/AvailabilityData_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityData_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/AvailabilityData_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityData_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/Base_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/Base_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/Base_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/Base_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/ContextTagKeys.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ContextTagKeys.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/ContextTagKeys.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ContextTagKeys.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/ContextTagKeys_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ContextTagKeys_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/ContextTagKeys_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ContextTagKeys_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/DataPoint.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPoint.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/DataPoint.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPoint.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/DataPointType_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPointType_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/DataPointType_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPointType_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/DataPoint_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPoint_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/DataPoint_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPoint_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/Data_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/Data_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/Data_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/Data_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/Domain_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/Domain_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/Domain_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/Domain_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/Envelope_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/Envelope_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/Envelope_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/Envelope_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/EventData.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventData.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/EventData.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventData.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/EventData_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventData_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/EventData_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventData_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/ExceptionData.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionData.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/ExceptionData.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionData.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/ExceptionData_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionData_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/ExceptionData_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionData_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/ExceptionDetails.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetails.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/ExceptionDetails.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetails.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/ExceptionDetailsImplementation.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsImplementation.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/ExceptionDetailsImplementation.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsImplementation.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/ExceptionDetails_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetails_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/ExceptionDetails_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetails_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/MessageData.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageData.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/MessageData.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageData.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/MessageData_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageData_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/MessageData_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageData_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/MetricData.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricData.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/MetricData.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricData.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/MetricData_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricData_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/MetricData_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricData_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/PageViewData.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewData.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/PageViewData.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewData.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/PageViewData_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewData_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/PageViewData_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewData_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/PageViewPerfData.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfData.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/PageViewPerfData.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfData.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/PageViewPerfData_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfData_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/PageViewPerfData_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfData_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/PerformanceCounterData.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PerformanceCounterData.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/PerformanceCounterData.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PerformanceCounterData.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/RemoteDependencyData.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyData.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/RemoteDependencyData.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyData.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/RemoteDependencyData_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyData_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/RemoteDependencyData_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyData_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/RequestData.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestData.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/RequestData.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestData.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/RequestData_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestData_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/RequestData_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestData_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/SessionStateData.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/SessionStateData.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/SessionStateData.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/SessionStateData.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/SeverityLevel_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/SeverityLevel_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/SeverityLevel_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/SeverityLevel_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/StackFrame.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/StackFrame.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/StackFrame.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/StackFrame.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/StackFrame_types.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/StackFrame_types.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/StackFrame_types.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/StackFrame_types.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/Tags.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/Tags.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/External/Tags.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/Tags.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/HttpWebResponseWrapper.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/HttpWebResponseWrapper.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/HttpWebResponseWrapper.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/HttpWebResponseWrapper.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/IPlatform.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/IPlatform.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/IPlatform.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/IPlatform.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/IPlatformDispatcher.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/IPlatformDispatcher.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/IPlatformDispatcher.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/IPlatformDispatcher.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/IRandomNumberBatchGenerator.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/IRandomNumberBatchGenerator.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/IRandomNumberBatchGenerator.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/IRandomNumberBatchGenerator.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/InternalContext.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/InternalContext.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/InternalContext.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/InternalContext.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/JsonSerializer.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/JsonWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonWriter.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/JsonWriter.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonWriter.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/LocationContext.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/LocationContext.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/LocationContext.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/LocationContext.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Metrics/DependencyMetricsExtractor.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Metrics/DependencyMetricsExtractor.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Metrics/DependencyMetricsExtractor.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Metrics/DependencyMetricsExtractor.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Metrics/ISpecificAutocollectedMetricsExtractor.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Metrics/ISpecificAutocollectedMetricsExtractor.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Metrics/ISpecificAutocollectedMetricsExtractor.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Metrics/ISpecificAutocollectedMetricsExtractor.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Metrics/MetricTerms.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Metrics/MetricTerms.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Metrics/MetricTerms.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Metrics/MetricTerms.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Metrics/RequestMetricsExtractor.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Metrics/RequestMetricsExtractor.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Metrics/RequestMetricsExtractor.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Metrics/RequestMetricsExtractor.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Metrics/SimpleMetricStatisticsAggregator.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Metrics/SimpleMetricStatisticsAggregator.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Metrics/SimpleMetricStatisticsAggregator.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Metrics/SimpleMetricStatisticsAggregator.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/OperationContext.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationContext.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/OperationContext.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationContext.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/OperationContextForCallContext.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationContextForCallContext.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/OperationContextForCallContext.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationContextForCallContext.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/OperationHolder.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationHolder.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/OperationHolder.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationHolder.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/OperationTelemetry.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/OperationTelemetry.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/PassThroughProcessor.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/PassThroughProcessor.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/PassThroughProcessor.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/PassThroughProcessor.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Platform/PlatformImplementation.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Platform/PlatformImplementation.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Platform/PlatformImplementation.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Platform/PlatformImplementation.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Platform/PlatformSingleton.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Platform/PlatformSingleton.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Platform/PlatformSingleton.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Platform/PlatformSingleton.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Property.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Property.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Property.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Property.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/RichPayloadEventSource.Keywords.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.Keywords.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/RichPayloadEventSource.Keywords.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.Keywords.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/RichPayloadEventSource.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/RichPayloadEventSource.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/SdkVersionUtils.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/SdkVersionUtils.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/SdkVersionUtils.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/SdkVersionUtils.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/SessionContext.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/SessionContext.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/SessionContext.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/SessionContext.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/SeverityLevelExtensions.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/SeverityLevelExtensions.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/SeverityLevelExtensions.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/SeverityLevelExtensions.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/SnapshottingCollection.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/SnapshottingCollection.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/SnapshottingCollection.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/SnapshottingCollection.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/SnapshottingList.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/SnapshottingList.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/SnapshottingList.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/SnapshottingList.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TaskTimer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TaskTimer.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TaskTimer.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/TaskTimer.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TaskTimerInternal.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TaskTimerInternal.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TaskTimerInternal.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/TaskTimerInternal.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Telemetry.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Telemetry.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Telemetry.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Telemetry.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TelemetryConfigurationFactory.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryConfigurationFactory.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TelemetryConfigurationFactory.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryConfigurationFactory.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TelemetryContextExtensions.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryContextExtensions.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TelemetryContextExtensions.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryContextExtensions.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TelemetryDebugWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryDebugWriter.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TelemetryDebugWriter.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryDebugWriter.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TelemetryProcessorChain.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryProcessorChain.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TelemetryProcessorChain.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryProcessorChain.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TelemetryProcessorChainBuilder.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryProcessorChainBuilder.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TelemetryProcessorChainBuilder.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryProcessorChainBuilder.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/ApplicationNameProvider.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/ApplicationNameProvider.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/ApplicationNameProvider.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/ApplicationNameProvider.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/CoreEventSource.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/CoreEventSource.cs similarity index 85% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/CoreEventSource.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/CoreEventSource.cs index d1d938e813..980555b64d 100644 --- a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/CoreEventSource.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/CoreEventSource.cs @@ -421,6 +421,77 @@ public void ItemRejectedNoInstrumentationKey(string item, string appDomainName = this.WriteEvent(35, item ?? string.Empty, this.nameProvider.Name); } + [Event( + 36, + Message = "Failed to obtain a value for default heartbeat payload property '{0}': Exception {1}.", + Level = EventLevel.Warning)] + public void FailedToObtainDefaultHeartbeatProperty(string heartbeatProperty, string ex, string appDomainName = "Incorrect") + { + this.WriteEvent( + 36, + heartbeatProperty ?? string.Empty, + ex ?? string.Empty, + this.nameProvider.Name); + } + + [Event( + 37, + Message = "Could not add heartbeat payload property '{0}' = {1}. Exception: {2}.", + Level = EventLevel.Warning)] + public void FailedToAddHeartbeatProperty(string heartbeatProperty, string heartbeatPropertyValue, string ex = null, string appDomainName = "Incorrect") + { + this.WriteEvent( + 37, + heartbeatProperty ?? string.Empty, + heartbeatPropertyValue ?? string.Empty, + ex ?? string.Empty, + this.nameProvider.Name); + } + + [Event( + 38, + Message = "Cannot add heartbeat payload property without any property name. Value given was '{0}', isHealthy given was {1}.", + Level = EventLevel.Warning)] + public void HeartbeatPropertyAddedWithoutAnyName(string heartbeatPropertyValue, bool isHealthy, string appDomainName = "Incorrect") + { + this.WriteEvent( + 38, + heartbeatPropertyValue ?? string.Empty, + isHealthy, + this.nameProvider.Name); + } + + [Event( + 39, + Message = "Could not set heartbeat payload property '{0}' = {1}, isHealthy was set = {2}, isHealthy value = {3}. Exception: {4}.", + Level = EventLevel.Warning)] + public void FailedToSetHeartbeatProperty(string heartbeatProperty, string heartbeatPropertyValue, bool isHealthyHasValue, bool isHealthy, string ex = null, string appDomainName = "Incorrect") + { + this.WriteEvent( + 39, + heartbeatProperty ?? string.Empty, + heartbeatPropertyValue ?? string.Empty, + isHealthyHasValue, + isHealthy, + ex ?? string.Empty, + this.nameProvider.Name); + } + + [Event( + 40, + Message = "Cannot set heartbeat payload property without a propertyName, or cannot set one of the default SDK properties. Property name given:'{0}'. Property value: '{1}'. isHealthy was set = {2}, isHealthy = {3}.", + Level = EventLevel.Warning)] + public void CannotSetHeartbeatPropertyWithNoNameOrDefaultName(string heartbeatProperty, string heartbeatPropertyValue, bool isHealthyHasValue, bool isHealthy, string appDomainName = "Incorrect") + { + this.WriteEvent( + 40, + heartbeatProperty ?? string.Empty, + heartbeatPropertyValue ?? string.Empty, + isHealthyHasValue, + isHealthy, + this.nameProvider.Name); + } + /// /// Keywords for the PlatformEventSource. /// diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnoisticsEventCounters.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnoisticsEventCounters.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnoisticsEventCounters.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnoisticsEventCounters.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottling.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottling.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottling.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottling.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottlingDefaults.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottlingDefaults.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottlingDefaults.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottlingDefaults.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottlingManager.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottlingManager.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottlingManager.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottlingManager.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottlingScheduler.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottlingScheduler.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottlingScheduler.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnoisticsEventThrottlingScheduler.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnosticsEventListener.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnosticsEventListener.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnosticsEventListener.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnosticsEventListener.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnosticsListener.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnosticsListener.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnosticsListener.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnosticsListener.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnosticsTelemetryModule.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnosticsTelemetryModule.cs similarity index 53% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnosticsTelemetryModule.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnosticsTelemetryModule.cs index 3436981743..05ab9be62b 100644 --- a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/DiagnosticsTelemetryModule.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/DiagnosticsTelemetryModule.cs @@ -9,17 +9,17 @@ /// /// Use diagnostics telemetry module to report SDK internal problems to the portal and VS debug output window. /// - public sealed class DiagnosticsTelemetryModule : ITelemetryModule, IDisposable + public sealed class DiagnosticsTelemetryModule : ITelemetryModule, IHeartbeatPropertyManager, IDisposable { internal readonly IList Senders = new List(); internal readonly DiagnosticsListener EventListener; + internal readonly IHeartbeatProvider HeartbeatProvider = null; private readonly object lockObject = new object(); - private readonly IDiagnoisticsEventThrottlingScheduler throttlingScheduler = new DiagnoisticsEventThrottlingScheduler(); - private volatile bool disposed = false; + private TimeSpan heartbeatInterval; private string instrumentationKey; private bool isInitialized = false; @@ -32,6 +32,10 @@ public DiagnosticsTelemetryModule() this.Senders.Add(new PortalDiagnosticsQueueSender()); this.EventListener = new DiagnosticsListener(this.Senders); + + this.heartbeatInterval = Tracing.HeartbeatProvider.DefaultHeartbeatInterval; + + this.HeartbeatProvider = new HeartbeatProvider(); } /// @@ -42,6 +46,57 @@ public DiagnosticsTelemetryModule() this.Dispose(false); } + /// + /// Gets or sets a value indicating whether or not the Health Heartbeat feature is disabled. + /// + public bool IsHeartbeatEnabled + { + get + { + return this.HeartbeatProvider.IsHeartbeatEnabled; + } + + set + { + this.HeartbeatProvider.IsHeartbeatEnabled = value; + } + } + + /// + /// Gets or sets the delay interval between heartbeats. + /// + /// + /// Note that there is a minimum interval and if an + /// attempt to make the interval less than this minimum value is detected, the interval rate will be set to + /// the minimum. + /// Also note, if the interval is set to any value less than the current channel flush rate, the heartbeat may + /// not be emitted at expected times. (The heartbeat will still be sent, but after having been cached for a + /// time first). + /// + /// + public TimeSpan HeartbeatInterval + { + get => this.HeartbeatProvider.HeartbeatInterval; + set => this.HeartbeatProvider.HeartbeatInterval = value; + } + + /// + /// Gets a list of property names that are not to be sent with the health heartbeats. null/empty list means allow all default properties through. + /// + /// + /// Default properties supplied by the Application Insights SDK: + /// - runtimeFramework + /// - baseSdkTargetFramework + /// + /// + public IList ExcludedHeartbeatProperties + { + get + { + return this.HeartbeatProvider.ExcludedHeartbeatProperties; + } + } + /// /// Gets or sets diagnostics Telemetry Module LogLevel configuration setting. /// Possible values LogAlways, Critical, Error, Warning, Informational and Verbose. @@ -90,6 +145,8 @@ public string DiagnosticsInstrumentationKey { portalSender.DiagnosticsInstrumentationKey = this.instrumentationKey; } + + this.HeartbeatProvider.InstrumentationKey = this.instrumentationKey; } } } @@ -132,12 +189,61 @@ public void Initialize(TelemetryConfiguration configuration) portalSender.Send(traceEvent); } + // set up heartbeat + this.HeartbeatProvider.Initialize(configuration); + this.isInitialized = true; } } } } - + + /// + /// Add a new Health Heartbeat property to the payload sent with each heartbeat. + /// + /// To update the value of the property you are adding to the health heartbeat, + /// . + /// + /// Note that you cannot add a HealthHeartbeatProperty with a name that already exists in the HealthHeartbeat + /// payload, including (but not limited to) the name of SDK-default items. + /// + /// + /// Name of the health heartbeat value to add + /// Current value of the health heartbeat value to add + /// Flag indicating whether or not the property represents a healthy value + /// True if the new payload item is successfully added, false otherwise. + public bool AddHealthProperty(string propertyName, string propertyValue, bool isHealthy) + { + return this.HeartbeatProvider.AddHealthProperty(propertyName, propertyValue, isHealthy); + } + + /// + /// Set an updated value into an existing property of the health heartbeat. The propertyName must be non-null and non-empty + /// and at least one of the propertyValue and isHealthy parameters must be non-null. + /// + /// After the new HealthHeartbeatProperty has been added () to the + /// heartbeat payload, the value represented by that item can be updated using this method at any time. + /// + /// + /// Name of the health heartbeat payload item property to set the value and/or health status of. + /// Value of the health heartbeat payload item. If this is null, the current value in the item is left unchanged. + /// Health status of the health heartbeat payload item. If this is set to null the health status is left unchanged. + /// True if the payload provider was added, false if it hasn't been added yet + /// (). + public bool SetHealthProperty(string propertyName, string propertyValue = null, bool? isHealthy = null) + { + if (!string.IsNullOrEmpty(propertyName) && (propertyValue != null || isHealthy != null)) + { + return this.HeartbeatProvider.SetHealthProperty(propertyName, propertyValue, isHealthy); + } + else + { + CoreEventSource.Log.LogVerbose("Did not set a valid health property. Ensure you set a valid propertyName and one or both of the propertyValue and isHealthy parameters."); + } + + return false; + } + /// /// Disposes this object. /// @@ -161,6 +267,8 @@ private void Dispose(bool managed) disposableSender.Dispose(); } + this.HeartbeatProvider.Dispose(); + GC.SuppressFinalize(this); } diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/EventMetaData.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/EventMetaData.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/EventMetaData.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/EventMetaData.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/EventSourceKeywords.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/EventSourceKeywords.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/EventSourceKeywords.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/EventSourceKeywords.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/Extensions.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/Extensions.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/Extensions.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/Extensions.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/IDiagnoisticsEventThrottling.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/IDiagnoisticsEventThrottling.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/IDiagnoisticsEventThrottling.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/IDiagnoisticsEventThrottling.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/IDiagnoisticsEventThrottlingManager.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/IDiagnoisticsEventThrottlingManager.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/IDiagnoisticsEventThrottlingManager.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/IDiagnoisticsEventThrottlingManager.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/IDiagnoisticsEventThrottlingScheduler.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/IDiagnoisticsEventThrottlingScheduler.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/IDiagnoisticsEventThrottlingScheduler.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/IDiagnoisticsEventThrottlingScheduler.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/IDiagnosticsSender.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/IDiagnosticsSender.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/IDiagnosticsSender.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/IDiagnosticsSender.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/PortalDiagnosticsQueueSender.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/PortalDiagnosticsQueueSender.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/PortalDiagnosticsQueueSender.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/PortalDiagnosticsQueueSender.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/PortalDiagnosticsSender.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/PortalDiagnosticsSender.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/PortalDiagnosticsSender.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/PortalDiagnosticsSender.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/SpinWait.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/SpinWait.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/SpinWait.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/SpinWait.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/ThreadResourceLock.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/ThreadResourceLock.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/ThreadResourceLock.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/ThreadResourceLock.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/TraceEvent.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/TraceEvent.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/TraceEvent.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/TraceEvent.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TransmissionProcessor.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TransmissionProcessor.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TransmissionProcessor.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/TransmissionProcessor.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TypeExtensions.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TypeExtensions.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/TypeExtensions.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/TypeExtensions.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/UserContext.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/UserContext.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/UserContext.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/UserContext.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/WeakConcurrentRandom.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/WeakConcurrentRandom.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/WeakConcurrentRandom.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/WeakConcurrentRandom.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/XorshiftRandomBatchGenerator.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/XorshiftRandomBatchGenerator.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/XorshiftRandomBatchGenerator.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/XorshiftRandomBatchGenerator.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Metric.cs b/src/Microsoft.ApplicationInsights/Extensibility/Metric.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Metric.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Metric.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/MetricManager.cs b/src/Microsoft.ApplicationInsights/Extensibility/MetricManager.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/MetricManager.cs rename to src/Microsoft.ApplicationInsights/Extensibility/MetricManager.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/OperationCorrelationTelemetryInitializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/OperationCorrelationTelemetryInitializer.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/OperationCorrelationTelemetryInitializer.cs rename to src/Microsoft.ApplicationInsights/Extensibility/OperationCorrelationTelemetryInitializer.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/SdkInternalOperationsMonitor.cs b/src/Microsoft.ApplicationInsights/Extensibility/SdkInternalOperationsMonitor.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/SdkInternalOperationsMonitor.cs rename to src/Microsoft.ApplicationInsights/Extensibility/SdkInternalOperationsMonitor.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/SequencePropertyInitializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/SequencePropertyInitializer.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/SequencePropertyInitializer.cs rename to src/Microsoft.ApplicationInsights/Extensibility/SequencePropertyInitializer.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/TelemetryConfiguration.cs b/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/TelemetryConfiguration.cs rename to src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/TelemetryModules.cs b/src/Microsoft.ApplicationInsights/Extensibility/TelemetryModules.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/TelemetryModules.cs rename to src/Microsoft.ApplicationInsights/Extensibility/TelemetryModules.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/TelemetrySink.cs b/src/Microsoft.ApplicationInsights/Extensibility/TelemetrySink.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/TelemetrySink.cs rename to src/Microsoft.ApplicationInsights/Extensibility/TelemetrySink.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/TelemetrySinkCollection.cs b/src/Microsoft.ApplicationInsights/Extensibility/TelemetrySinkCollection.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/TelemetrySinkCollection.cs rename to src/Microsoft.ApplicationInsights/Extensibility/TelemetrySinkCollection.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/GlobalSuppressions.cs b/src/Microsoft.ApplicationInsights/GlobalSuppressions.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/GlobalSuppressions.cs rename to src/Microsoft.ApplicationInsights/GlobalSuppressions.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/HeartbeatDefaultPayload.cs b/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/HeartbeatDefaultPayload.cs new file mode 100644 index 0000000000..3a4a30bac9 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/HeartbeatDefaultPayload.cs @@ -0,0 +1,94 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Reflection; + + internal static class HeartbeatDefaultPayload + { + public static readonly string[] DefaultFields = + { + "runtimeFramework", + "baseSdkTargetFramework" + }; + + public static void PopulateDefaultPayload(IEnumerable disabledFields, IHeartbeatProvider provider) + { + var enabledProperties = RemoveDisabledDefaultFields(disabledFields); + + var payload = new Dictionary(); + foreach (string fieldName in enabledProperties) + { + try + { + switch (fieldName) + { + case "runtimeFramework": + provider.AddHealthProperty(fieldName, GetRuntimeFrameworkVer(), true); + break; + case "baseSdkTargetFramework": + provider.AddHealthProperty(fieldName, GetBaseSdkTargetFramework(), true); + break; + default: + provider.AddHealthProperty(fieldName, "UNDEFINED", false); + break; + } + } + catch (Exception ex) + { + CoreEventSource.Log.FailedToObtainDefaultHeartbeatProperty(fieldName, ex.ToString()); + } + } + } + + private static List RemoveDisabledDefaultFields(IEnumerable disabledFields) + { + List enabledProperties = new List(); + + if (disabledFields == null || disabledFields.Count() <= 0) + { + enabledProperties = DefaultFields.ToList(); + } + else + { + enabledProperties = new List(); + foreach (string fieldName in DefaultFields) + { + if (!disabledFields.Contains(fieldName, StringComparer.OrdinalIgnoreCase)) + { + enabledProperties.Add(fieldName); + } + } + } + + return enabledProperties; + } + + private static string GetBaseSdkTargetFramework() + { +#if NET45 + return "net45"; +#elif NET46 + return "net46"; +#elif NETSTANDARD1_3 + return "netstandard1.3"; +#else +#error Unrecognized framework + return "undefined"; +#endif + } + + private static string GetRuntimeFrameworkVer() + { + Assembly assembly = typeof(Object).GetTypeInfo().Assembly; + + AssemblyFileVersionAttribute objectAssemblyFileVer = + assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute)) + .Cast() + .FirstOrDefault(); + + return objectAssemblyFileVer != null ? objectAssemblyFileVer.Version : "undefined"; + } + } +} diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/HeartbeatPropertyPayload.cs b/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/HeartbeatPropertyPayload.cs new file mode 100644 index 0000000000..43837d8e3c --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/HeartbeatPropertyPayload.cs @@ -0,0 +1,47 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing +{ + /// + /// Payload stored and used to transmit Health Heartbeat properties with, allowing for user to push updates + /// as they deem necessary. + /// + internal class HeartbeatPropertyPayload + { + private string payloadValue = string.Empty; // the current value of this property, ready for transmission + private bool isHealthy = true; // is this a healthy value or not + + /// + /// Gets or sets the payload value at the time the property item was added, as a string + /// + public string PayloadValue + { + get => this.payloadValue; + set + { + string safeVal = value ?? string.Empty; // ensure we are setting a non-null value + if (!this.payloadValue.Equals(safeVal, System.StringComparison.Ordinal)) + { + this.IsUpdated = true; + this.payloadValue = safeVal; + } + } + } + + /// + /// Gets or sets a value indicating whether this property is currently in a healthy or unhealthy state + /// + public bool IsHealthy + { + get => this.isHealthy; + set + { + this.IsUpdated = this.isHealthy != value; + this.isHealthy = value; + } + } + + /// + /// Gets or sets a value indicating whether this property payload has been updated since the last time it was delivered in a heartbeat + /// + public bool IsUpdated { get; set; } + } +} diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/HeartbeatProvider.cs b/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/HeartbeatProvider.cs new file mode 100644 index 0000000000..0405510f0e --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/HeartbeatProvider.cs @@ -0,0 +1,312 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing +{ + using System; + using System.Collections.Concurrent; + using System.Collections.Generic; + using System.Globalization; + using System.Linq; + using System.Threading; + using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.DataContracts; + using Microsoft.ApplicationInsights.Extensibility; + + /// + /// Implementation of health heartbeat functionality. + /// + internal class HeartbeatProvider : IDisposable, IHeartbeatProvider + { + /// + /// The default interval between heartbeats if not specified by the user. Left public for use in unit tests. + /// + public static readonly TimeSpan DefaultHeartbeatInterval = TimeSpan.FromMinutes(15.0); + + /// + /// The minimum interval that can be set between heartbeats. + /// + public static readonly TimeSpan MinimumHeartbeatInterval = TimeSpan.FromSeconds(30.0); + + /// + /// The name of the health heartbeat metric item and operation context. + /// + private static string heartbeatSyntheticMetricName = "HealthState"; + + private readonly List disabledDefaultFields = new List(); // string containing fields that are not to be sent with the payload. Empty list means send everything available. + + private UInt64 heartbeatsSent; // counter of all heartbeats + + /// + /// The payload items to send out with each health heartbeat. + /// + private ConcurrentDictionary heartbeatProperties; + + private bool disposedValue = false; // To detect redundant calls to dispose + private TimeSpan interval; // time between heartbeats emitted + private TelemetryClient telemetryClient; // client to use in sending our heartbeat + private volatile bool isEnabled; // no need for locks or volatile here, we can skip/add a beat if the module is disabled between heartbeats + + public HeartbeatProvider() + { + this.interval = DefaultHeartbeatInterval; + this.heartbeatProperties = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); + this.heartbeatsSent = 0; // count up from construction time + this.isEnabled = true; + } + + /// + /// Gets or sets the currently defined interval between heartbeats + /// + public TimeSpan HeartbeatInterval + { + get => this.interval; + set + { + if (value == null) + { + this.interval = DefaultHeartbeatInterval; + } + else if (value <= MinimumHeartbeatInterval) + { + this.interval = MinimumHeartbeatInterval; + } + else + { + this.interval = value; + } + } + } + + /// + /// Gets or sets the currently defined instrumentation key to send heartbeat telemetry items to. + /// + /// Note that if the heartbeat provider has not been initialized yet, this key would get reset to + /// whatever the telemetry configuration the heartbeat provider is initialized with. + /// + public string InstrumentationKey + { + get => this.telemetryClient?.InstrumentationKey; + set + { + if (this.telemetryClient != null) + { + this.telemetryClient.InstrumentationKey = value; + } + } + } + + /// + /// Gets or sets a value indicating whether or not heartbeats are enabled + /// + public bool IsHeartbeatEnabled + { + get => this.isEnabled; + set + { + if (!this.isEnabled && value) + { + // we need to start calling the timer again + // if requested to disable, let the next HeartbeatPulse disable it for us (do nothing here) + this.HeartbeatTimer.Change(this.HeartbeatInterval, this.HeartbeatInterval); + } + + this.isEnabled = value; + } + } + + /// + /// Gets a list of default field names that should not be sent with each heartbeat. + /// + public IList ExcludedHeartbeatProperties + { + get => this.disabledDefaultFields; + } + + private Timer HeartbeatTimer { get; set; } // timer that will send each heartbeat in intervals + + public void Initialize(TelemetryConfiguration configuration) + { + if (this.telemetryClient == null) + { + this.telemetryClient = new TelemetryClient(configuration); + } + + HeartbeatDefaultPayload.PopulateDefaultPayload(this.ExcludedHeartbeatProperties, this); + + // Note: if this is a subsequent initialization, the interval between heartbeats will be updated in the next cycle so no .Change call necessary here + if (this.HeartbeatTimer == null) + { + int interval = this.IsHeartbeatEnabled ? (int)this.HeartbeatInterval.TotalMilliseconds : Timeout.Infinite; + this.HeartbeatTimer = new Timer(this.HeartbeatPulse, this, interval, interval); + } + } + + public bool AddHealthProperty(string healthPropertyName, string healthPropertyValue, bool isHealthy) + { + bool isAdded = false; + + if (!string.IsNullOrEmpty(healthPropertyName)) + { + try + { + var existingProp = this.heartbeatProperties.GetOrAdd(healthPropertyName, (key) => + { + isAdded = true; + return new HeartbeatPropertyPayload() + { + IsHealthy = isHealthy, + PayloadValue = healthPropertyValue + }; + }); + } + catch (Exception e) + { + CoreEventSource.Log.FailedToAddHeartbeatProperty(healthPropertyName, healthPropertyValue, e.ToString()); + } + } + else + { + CoreEventSource.Log.HeartbeatPropertyAddedWithoutAnyName(healthPropertyValue, isHealthy); + } + + return isAdded; + } + + public bool SetHealthProperty(string healthPropertyName, string healthPropertyValue = null, bool? isHealthy = null) + { + bool setResult = false; + if (!string.IsNullOrEmpty(healthPropertyName) + && !HeartbeatDefaultPayload.DefaultFields.Contains(healthPropertyName)) + { + try + { + this.heartbeatProperties.AddOrUpdate(healthPropertyName, (key) => + { + throw new Exception("Cannot set a health property without adding it first."); + }, + (key, property) => + { + if (isHealthy != null) + { + property.IsHealthy = isHealthy.Value; + } + if (healthPropertyValue != null) + { + property.PayloadValue = healthPropertyValue; + } + + return property; + }); + setResult = true; + } + catch (Exception e) + { + CoreEventSource.Log.FailedToSetHeartbeatProperty(healthPropertyName, healthPropertyValue, isHealthy.HasValue, isHealthy.GetValueOrDefault(false), e.ToString()); + } + } + else + { + CoreEventSource.Log.CannotSetHeartbeatPropertyWithNoNameOrDefaultName(healthPropertyName, healthPropertyValue, isHealthy.HasValue, isHealthy.GetValueOrDefault(false)); + } + + return setResult; + } + + #region IDisposable Support + + public void Dispose() + { + this.Dispose(true); + } + + /// + /// Get the metric telemetry item that will be sent. + /// + /// Note: exposed to internal to allow inspection for testing. + /// + /// A MetricTelemtry item that contains the currently defined payload for a heartbeat 'pulse'. + internal ITelemetry GatherData() + { + var hbeat = new MetricTelemetry(heartbeatSyntheticMetricName, 0.0); + + foreach (var payloadItem in this.heartbeatProperties) + { + hbeat.Properties.Add(payloadItem.Key, payloadItem.Value.PayloadValue); + hbeat.Sum += payloadItem.Value.IsHealthy ? 0 : 1; + } + + hbeat.Sequence = string.Format(CultureInfo.CurrentCulture, "{0}", this.heartbeatsSent++); + + return hbeat; + } + + protected void Dispose(bool disposing) + { + if (!this.disposedValue) + { + if (disposing) + { + if (this.HeartbeatTimer != null) + { + this.isEnabled = false; + + try + { + this.HeartbeatTimer.Dispose(); + } + catch (Exception) + { + CoreEventSource.Log.LogError("Error occured when disposing heartbeat timer within HeartbeatProvider"); + } + } + } + + this.disposedValue = true; + } + } + + #endregion + + private void Send() + { + if (this.telemetryClient.TelemetryConfiguration.TelemetryChannel == null) + { + return; + } + + var eventData = (MetricTelemetry)this.GatherData(); + + eventData.Context.Operation.SyntheticSource = heartbeatSyntheticMetricName; + + this.telemetryClient.TrackMetric(eventData); + } + + private void HeartbeatPulse(object state) + { + if (state is HeartbeatProvider hp && hp.IsHeartbeatEnabled) + { + // we will be prone to overlap if any extension payload provider takes a longer time to process than our timer + // interval. Best that we reset the timer each time round. + try + { + this.HeartbeatTimer.Change(Timeout.Infinite, Timeout.Infinite); + hp.Send(); + } + catch (ObjectDisposedException) + { + // swallow this exception but log it just the same. + CoreEventSource.Log.LogError("Heartbeat timer change during dispose occured."); + } + finally + { + if (this.IsHeartbeatEnabled) + { + this.HeartbeatTimer.Change(this.HeartbeatInterval, this.HeartbeatInterval); + } + } + } + else + { + CoreEventSource.Log.LogError("Heartbeat pulse being sent without valid instance of HealthHeartbeatProvider as its state"); + } + } + } +} diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/IHeartbeatPropertyManager.cs b/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/IHeartbeatPropertyManager.cs new file mode 100644 index 0000000000..daf40a1ed3 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/IHeartbeatPropertyManager.cs @@ -0,0 +1,38 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing +{ + using System; + using System.Collections.Generic; + + /// + /// Defines an implementation for management of the health heartbeat feature of the + /// Application Insights SDK. Add/Set properties, disable/enable the heartbeat, and set + /// the interval between heartbeat pulses with classes that implement this interface. + /// + public interface IHeartbeatPropertyManager + { + /// + /// Gets or sets a value indicating whether or not the Health Heartbeat feature is disabled. + /// + bool IsHeartbeatEnabled { get; set; } + + /// + /// Gets or sets the delay between heartbeats. + /// + TimeSpan HeartbeatInterval { get; set; } + + /// + /// Gets a list of property names that are not to be sent with the health heartbeats. + /// + IList ExcludedHeartbeatProperties { get; } + + /// + /// Add a new Health Heartbeat property to the payload sent with each heartbeat. + /// + bool AddHealthProperty(string propertyName, string propertyValue, bool isHealthy); + + /// + /// Set an updated value into an existing property of the health heartbeat. + /// + bool SetHealthProperty(string propertyName, string propertyValue = null, bool? isHealthy = null); + } +} diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/IHeartbeatProvider.cs b/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/IHeartbeatProvider.cs new file mode 100644 index 0000000000..7e062d9641 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/IHeartbeatProvider.cs @@ -0,0 +1,13 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing +{ + using System; + using System.Collections.Generic; + using Microsoft.ApplicationInsights.Extensibility; + + internal interface IHeartbeatProvider : IHeartbeatPropertyManager, IDisposable + { + string InstrumentationKey { get; set; } + + void Initialize(TelemetryConfiguration configuration); + } +} diff --git a/src/Microsoft.ApplicationInsights/Managed/Microsoft.ApplicationInsights.csproj b/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj similarity index 82% rename from src/Microsoft.ApplicationInsights/Managed/Microsoft.ApplicationInsights.csproj rename to src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj index 730fcbca32..06036ace9d 100644 --- a/src/Microsoft.ApplicationInsights/Managed/Microsoft.ApplicationInsights.csproj +++ b/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj @@ -1,4 +1,4 @@ - + @@ -12,7 +12,7 @@ false net45;net46;netstandard1.3 - false + netstandard1.3 True @@ -42,13 +42,6 @@ content - - - - - - - All @@ -57,14 +50,12 @@ All - All All All - - All + All @@ -76,10 +67,10 @@ - + PublicAPI.Shipped.txt - + PublicAPI.Unshipped.txt diff --git a/src/Microsoft.ApplicationInsights/Managed/Net45/Extensibility/Implementation/RichPayloadEventSource.TelemetryHandler.cs b/src/Microsoft.ApplicationInsights/Net45/Extensibility/Implementation/RichPayloadEventSource.TelemetryHandler.cs similarity index 99% rename from src/Microsoft.ApplicationInsights/Managed/Net45/Extensibility/Implementation/RichPayloadEventSource.TelemetryHandler.cs rename to src/Microsoft.ApplicationInsights/Net45/Extensibility/Implementation/RichPayloadEventSource.TelemetryHandler.cs index c7cf0c668b..c2c213764e 100644 --- a/src/Microsoft.ApplicationInsights/Managed/Net45/Extensibility/Implementation/RichPayloadEventSource.TelemetryHandler.cs +++ b/src/Microsoft.ApplicationInsights/Net45/Extensibility/Implementation/RichPayloadEventSource.TelemetryHandler.cs @@ -1,4 +1,5 @@ -namespace Microsoft.ApplicationInsights.Extensibility.Implementation +#if NET45 +namespace Microsoft.ApplicationInsights.Extensibility.Implementation { using System; using System.Collections.Generic; @@ -748,3 +749,4 @@ private Action CreateHandlerForSessionStateTelemetry(EventSource eve } } } +#endif \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Managed/Net45/Extensibility/Implementation/RichPayloadEventSource.cs b/src/Microsoft.ApplicationInsights/Net45/Extensibility/Implementation/RichPayloadEventSource.cs similarity index 98% rename from src/Microsoft.ApplicationInsights/Managed/Net45/Extensibility/Implementation/RichPayloadEventSource.cs rename to src/Microsoft.ApplicationInsights/Net45/Extensibility/Implementation/RichPayloadEventSource.cs index 3f3a352e1a..686970a660 100644 --- a/src/Microsoft.ApplicationInsights/Managed/Net45/Extensibility/Implementation/RichPayloadEventSource.cs +++ b/src/Microsoft.ApplicationInsights/Net45/Extensibility/Implementation/RichPayloadEventSource.cs @@ -1,4 +1,5 @@ -namespace Microsoft.ApplicationInsights.Extensibility.Implementation +#if NET45 +namespace Microsoft.ApplicationInsights.Extensibility.Implementation { using System; using System.Collections.Generic; @@ -140,4 +141,5 @@ private void Dispose(bool disposing) } } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/OperationTelemetryExtensions.cs b/src/Microsoft.ApplicationInsights/OperationTelemetryExtensions.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/OperationTelemetryExtensions.cs rename to src/Microsoft.ApplicationInsights/OperationTelemetryExtensions.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Properties/AssemblyInfo.cs b/src/Microsoft.ApplicationInsights/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Properties/AssemblyInfo.cs rename to src/Microsoft.ApplicationInsights/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/TelemetryClient.cs b/src/Microsoft.ApplicationInsights/TelemetryClient.cs similarity index 99% rename from src/Microsoft.ApplicationInsights/Managed/Shared/TelemetryClient.cs rename to src/Microsoft.ApplicationInsights/TelemetryClient.cs index 4cde9871c0..fd2892c6ec 100644 --- a/src/Microsoft.ApplicationInsights/Managed/Shared/TelemetryClient.cs +++ b/src/Microsoft.ApplicationInsights/TelemetryClient.cs @@ -212,7 +212,7 @@ public void TrackTrace(TraceTelemetry telemetry) } /// - /// Obsolete - use to send metrics. + /// Send a for aggregation in Metric Explorer. /// /// Metric name. /// Metric value. @@ -232,7 +232,6 @@ public void TrackMetric(string name, double value, IDictionary p /// /// Send a that represents aggregated metric data. /// Create a separate instance for each call to . - /// Consider using to send metrics with reduced bandwidth. /// /// /// Learn more diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/TelemetryClientExtensions.cs b/src/Microsoft.ApplicationInsights/TelemetryClientExtensions.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/TelemetryClientExtensions.cs rename to src/Microsoft.ApplicationInsights/TelemetryClientExtensions.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/Shared/Utils.cs b/src/Microsoft.ApplicationInsights/Utils.cs similarity index 100% rename from src/Microsoft.ApplicationInsights/Managed/Shared/Utils.cs rename to src/Microsoft.ApplicationInsights/Utils.cs diff --git a/src/Microsoft.ApplicationInsights/Managed/netstandard1.3/Extensibility/Implementation/Platform/PlatformImplementation.cs b/src/Microsoft.ApplicationInsights/netstandard1.3/Extensibility/Implementation/Platform/PlatformImplementation.cs similarity index 93% rename from src/Microsoft.ApplicationInsights/Managed/netstandard1.3/Extensibility/Implementation/Platform/PlatformImplementation.cs rename to src/Microsoft.ApplicationInsights/netstandard1.3/Extensibility/Implementation/Platform/PlatformImplementation.cs index a7903e0f14..90327c99e6 100644 --- a/src/Microsoft.ApplicationInsights/Managed/netstandard1.3/Extensibility/Implementation/Platform/PlatformImplementation.cs +++ b/src/Microsoft.ApplicationInsights/netstandard1.3/Extensibility/Implementation/Platform/PlatformImplementation.cs @@ -1,4 +1,5 @@ -namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Platform +#if NETSTANDARD1_3 +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Platform { using System; using System.Collections.Generic; @@ -51,3 +52,4 @@ public string GetMachineName() } } } +#endif \ No newline at end of file diff --git a/src/ServerTelemetryChannel/Managed/Shared/AdaptiveSamplingTelemetryProcessor.cs b/src/ServerTelemetryChannel/AdaptiveSamplingTelemetryProcessor.cs similarity index 99% rename from src/ServerTelemetryChannel/Managed/Shared/AdaptiveSamplingTelemetryProcessor.cs rename to src/ServerTelemetryChannel/AdaptiveSamplingTelemetryProcessor.cs index a6b6a70096..298fe5606b 100644 --- a/src/ServerTelemetryChannel/Managed/Shared/AdaptiveSamplingTelemetryProcessor.cs +++ b/src/ServerTelemetryChannel/AdaptiveSamplingTelemetryProcessor.cs @@ -56,7 +56,7 @@ public AdaptiveSamplingTelemetryProcessor( // make estimator telemetry processor work after sampling was done this.estimatorProcessor = new SamplingPercentageEstimatorTelemetryProcessor(settings, this.SamplingPercentageChanged, next); - this.samplingProcessor = new SamplingTelemetryProcessor(this.estimatorProcessor); + this.samplingProcessor = new SamplingTelemetryProcessor(next, this.estimatorProcessor); } /// diff --git a/src/ServerTelemetryChannel/Managed/ApplicationInsights.config.install.xdt b/src/ServerTelemetryChannel/ApplicationInsights.config.install.xdt similarity index 100% rename from src/ServerTelemetryChannel/Managed/ApplicationInsights.config.install.xdt rename to src/ServerTelemetryChannel/ApplicationInsights.config.install.xdt diff --git a/src/ServerTelemetryChannel/Managed/ApplicationInsights.config.transform b/src/ServerTelemetryChannel/ApplicationInsights.config.transform similarity index 100% rename from src/ServerTelemetryChannel/Managed/ApplicationInsights.config.transform rename to src/ServerTelemetryChannel/ApplicationInsights.config.transform diff --git a/src/ServerTelemetryChannel/Managed/ApplicationInsights.config.uninstall.xdt b/src/ServerTelemetryChannel/ApplicationInsights.config.uninstall.xdt similarity index 100% rename from src/ServerTelemetryChannel/Managed/ApplicationInsights.config.uninstall.xdt rename to src/ServerTelemetryChannel/ApplicationInsights.config.uninstall.xdt diff --git a/src/ServerTelemetryChannel/Managed/Shared/AssemblyInfo.cs b/src/ServerTelemetryChannel/AssemblyInfo.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/AssemblyInfo.cs rename to src/ServerTelemetryChannel/AssemblyInfo.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/ApplicationFolderProvider.cs b/src/ServerTelemetryChannel/Implementation/ApplicationFolderProvider.cs similarity index 62% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/ApplicationFolderProvider.cs rename to src/ServerTelemetryChannel/Implementation/ApplicationFolderProvider.cs index a9186e93c4..b485b297a8 100644 --- a/src/ServerTelemetryChannel/Managed/Shared/Implementation/ApplicationFolderProvider.cs +++ b/src/ServerTelemetryChannel/Implementation/ApplicationFolderProvider.cs @@ -11,12 +11,15 @@ using System.Security.Cryptography; using System.Security.Principal; using System.Text; + using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Shared.Implementation; internal class ApplicationFolderProvider : IApplicationFolderProvider { + internal Func ApplySecurityToDirectory; + private readonly IDictionary environment; private readonly string customFolderName; - private readonly WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent(); + private readonly IIdentityProvider identityProvider; public ApplicationFolderProvider(string folderName = null) : this(Environment.GetEnvironmentVariables(), folderName) @@ -30,12 +33,26 @@ internal ApplicationFolderProvider(IDictionary environment, string folderName = throw new ArgumentNullException("environment"); } + try + { + // In NETSTANDARD 1.3 Most reliable way to know if WindowsIdentityProvider can be used + // is to check if it throws exception. + WindowsIdentity.GetCurrent(); + this.identityProvider = new WindowsIdentityProvider(); + this.ApplySecurityToDirectory = this.SetSecurityPermissionsToAdminAndCurrentUserWindows; + } + catch (Exception) + { + this.identityProvider = new NonWindowsIdentityProvider(environment); + this.ApplySecurityToDirectory = this.SetSecurityPermissionsToAdminAndCurrentUserNonWindows; + } + this.environment = environment; this.customFolderName = folderName; } public IPlatformFolder GetApplicationFolder() - { + { var errors = new List(this.environment.Count + 1); var result = this.CreateAndValidateApplicationFolder(this.customFolderName, createSubFolder: false, errors: errors); @@ -60,12 +77,21 @@ public IPlatformFolder GetApplicationFolder() if (result == null) { - TelemetryChannelEventSource.Log.TransmissionStorageAccessDeniedError(string.Join(Environment.NewLine, errors), this.currentIdentity.Name); + TelemetryChannelEventSource.Log.TransmissionStorageAccessDeniedError(string.Join(Environment.NewLine, errors), this.identityProvider.GetName(), this.customFolderName); } return result; } + /// + /// Test hook to allow testing of non-windows scenario. + /// + /// The method to be invoked to set directory access. + internal void OverrideApplySecurityToDirectory(Func applySecurityToDirectory) + { + this.ApplySecurityToDirectory = applySecurityToDirectory; + } + private static string GetPathAccessFailureErrorMessage(Exception exp, string path) { return "Path: " + path + "; Error: " + exp.Message + Environment.NewLine; @@ -128,6 +154,10 @@ private IPlatformFolder CreateAndValidateApplicationFolder(string rootPath, bool if (createSubFolder) { telemetryDirectory = this.CreateTelemetrySubdirectory(telemetryDirectory); + if (!this.ApplySecurityToDirectory(telemetryDirectory)) + { + throw new SecurityException("Unable to apply security restrictions to the storage directory."); + } } CheckAccessPermissions(telemetryDirectory); @@ -139,31 +169,31 @@ private IPlatformFolder CreateAndValidateApplicationFolder(string rootPath, bool catch (UnauthorizedAccessException exp) { errorMessage = GetPathAccessFailureErrorMessage(exp, rootPath); - TelemetryChannelEventSource.Log.TransmissionStorageAccessDeniedWarning(errorMessage, this.currentIdentity.Name); + TelemetryChannelEventSource.Log.TransmissionStorageIssuesWarning(errorMessage, this.identityProvider.GetName()); } catch (ArgumentException exp) { // Path does not specify a valid file path or contains invalid DirectoryInfo characters. errorMessage = GetPathAccessFailureErrorMessage(exp, rootPath); - TelemetryChannelEventSource.Log.TransmissionStorageAccessDeniedWarning(errorMessage, this.currentIdentity.Name); + TelemetryChannelEventSource.Log.TransmissionStorageIssuesWarning(errorMessage, this.identityProvider.GetName()); } catch (DirectoryNotFoundException exp) { // The specified path is invalid, such as being on an unmapped drive. errorMessage = GetPathAccessFailureErrorMessage(exp, rootPath); - TelemetryChannelEventSource.Log.TransmissionStorageAccessDeniedWarning(errorMessage, this.currentIdentity.Name); + TelemetryChannelEventSource.Log.TransmissionStorageIssuesWarning(errorMessage, this.identityProvider.GetName()); } catch (IOException exp) { // The subdirectory cannot be created. -or- A file or directory already has the name specified by path. -or- The specified path, file name, or both exceed the system-defined maximum length. . errorMessage = GetPathAccessFailureErrorMessage(exp, rootPath); - TelemetryChannelEventSource.Log.TransmissionStorageAccessDeniedWarning(errorMessage, this.currentIdentity.Name); + TelemetryChannelEventSource.Log.TransmissionStorageIssuesWarning(errorMessage, this.identityProvider.GetName()); } catch (SecurityException exp) { // The caller does not have code access permission to create the directory. errorMessage = GetPathAccessFailureErrorMessage(exp, rootPath); - TelemetryChannelEventSource.Log.TransmissionStorageAccessDeniedWarning(errorMessage, this.currentIdentity.Name); + TelemetryChannelEventSource.Log.TransmissionStorageIssuesWarning(errorMessage, this.identityProvider.GetName()); } if (!string.IsNullOrEmpty(errorMessage)) @@ -184,37 +214,57 @@ private DirectoryInfo CreateTelemetrySubdirectory(DirectoryInfo root) baseDirectory = AppContext.BaseDirectory; #endif - string appIdentity = this.currentIdentity.Name + "@" + Path.Combine(baseDirectory, Process.GetCurrentProcess().ProcessName); + string appIdentity = this.identityProvider.GetName() + "@" + Path.Combine(baseDirectory, Process.GetCurrentProcess().ProcessName); string subdirectoryName = GetSHA256Hash(appIdentity); - string subdirectoryPath = Path.Combine(@"Microsoft\ApplicationInsights", subdirectoryName); + string subdirectoryPath = Path.Combine("Microsoft", "ApplicationInsights", subdirectoryName); DirectoryInfo subdirectory = root.CreateSubdirectory(subdirectoryPath); + + return subdirectory; + } - var directorySecurity = subdirectory.GetAccessControl(); - - // Grant access only to admins and current user - var adminitrators = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null); - directorySecurity.AddAccessRule( - new FileSystemAccessRule( - adminitrators, - FileSystemRights.FullControl, - InheritanceFlags.None, - PropagationFlags.NoPropagateInherit, - AccessControlType.Allow)); - - directorySecurity.AddAccessRule( - new FileSystemAccessRule( - this.currentIdentity.Name, - FileSystemRights.FullControl, - InheritanceFlags.None, - PropagationFlags.NoPropagateInherit, - AccessControlType.Allow)); - - // Do not inherit from parent folder - directorySecurity.SetAccessRuleProtection(isProtected: true, preserveInheritance: false); - - subdirectory.SetAccessControl(directorySecurity); + private bool SetSecurityPermissionsToAdminAndCurrentUserNonWindows(DirectoryInfo subdirectory) + { + // For non-windows simply return false to indicate that security policy is not applied. + // This is until .net core exposes an Api to do this. + return false; + } - return subdirectory; + private bool SetSecurityPermissionsToAdminAndCurrentUserWindows(DirectoryInfo subdirectory) + { + try + { + var directorySecurity = subdirectory.GetAccessControl(); + + // Grant access only to admins and current user + var adminitrators = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null); + directorySecurity.AddAccessRule( + new FileSystemAccessRule( + adminitrators, + FileSystemRights.FullControl, + InheritanceFlags.None, + PropagationFlags.NoPropagateInherit, + AccessControlType.Allow)); + + directorySecurity.AddAccessRule( + new FileSystemAccessRule( + this.identityProvider.GetName(), + FileSystemRights.FullControl, + InheritanceFlags.None, + PropagationFlags.NoPropagateInherit, + AccessControlType.Allow)); + + // Do not inherit from parent folder + directorySecurity.SetAccessRuleProtection(isProtected: true, preserveInheritance: false); + + subdirectory.SetAccessControl(directorySecurity); + + return true; + } + catch (Exception ex) + { + TelemetryChannelEventSource.Log.FailedToSetSecurityPermissionStorageDirectory(subdirectory.FullName, ex.Message); + return false; + } } } } diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/ApplicationLifecycleTransmissionPolicy.cs b/src/ServerTelemetryChannel/Implementation/ApplicationLifecycleTransmissionPolicy.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/ApplicationLifecycleTransmissionPolicy.cs rename to src/ServerTelemetryChannel/Implementation/ApplicationLifecycleTransmissionPolicy.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/ApplicationStoppingEventArgs.cs b/src/ServerTelemetryChannel/Implementation/ApplicationStoppingEventArgs.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/ApplicationStoppingEventArgs.cs rename to src/ServerTelemetryChannel/Implementation/ApplicationStoppingEventArgs.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/BackendResponse.cs b/src/ServerTelemetryChannel/Implementation/BackendResponse.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/BackendResponse.cs rename to src/ServerTelemetryChannel/Implementation/BackendResponse.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/BackoffLogicManager.cs b/src/ServerTelemetryChannel/Implementation/BackoffLogicManager.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/BackoffLogicManager.cs rename to src/ServerTelemetryChannel/Implementation/BackoffLogicManager.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/CurrentThreadTaskScheduler.cs b/src/ServerTelemetryChannel/Implementation/CurrentThreadTaskScheduler.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/CurrentThreadTaskScheduler.cs rename to src/ServerTelemetryChannel/Implementation/CurrentThreadTaskScheduler.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/ErrorHandlingTransmissionPolicy.cs b/src/ServerTelemetryChannel/Implementation/ErrorHandlingTransmissionPolicy.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/ErrorHandlingTransmissionPolicy.cs rename to src/ServerTelemetryChannel/Implementation/ErrorHandlingTransmissionPolicy.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/ExceptionHandler.cs b/src/ServerTelemetryChannel/Implementation/ExceptionHandler.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/ExceptionHandler.cs rename to src/ServerTelemetryChannel/Implementation/ExceptionHandler.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/ExponentialMovingAverageCounter.cs b/src/ServerTelemetryChannel/Implementation/ExponentialMovingAverageCounter.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/ExponentialMovingAverageCounter.cs rename to src/ServerTelemetryChannel/Implementation/ExponentialMovingAverageCounter.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/IApplicationFolderProvider.cs b/src/ServerTelemetryChannel/Implementation/IApplicationFolderProvider.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/IApplicationFolderProvider.cs rename to src/ServerTelemetryChannel/Implementation/IApplicationFolderProvider.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/IApplicationLifecycle.cs b/src/ServerTelemetryChannel/Implementation/IApplicationLifecycle.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/IApplicationLifecycle.cs rename to src/ServerTelemetryChannel/Implementation/IApplicationLifecycle.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/INetwork.cs b/src/ServerTelemetryChannel/Implementation/INetwork.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/INetwork.cs rename to src/ServerTelemetryChannel/Implementation/INetwork.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/IPlatformFile.cs b/src/ServerTelemetryChannel/Implementation/IPlatformFile.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/IPlatformFile.cs rename to src/ServerTelemetryChannel/Implementation/IPlatformFile.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/IPlatformFolder.cs b/src/ServerTelemetryChannel/Implementation/IPlatformFolder.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/IPlatformFolder.cs rename to src/ServerTelemetryChannel/Implementation/IPlatformFolder.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/IRandomNumberBatchGenerator.cs b/src/ServerTelemetryChannel/Implementation/IRandomNumberBatchGenerator.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/IRandomNumberBatchGenerator.cs rename to src/ServerTelemetryChannel/Implementation/IRandomNumberBatchGenerator.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/Network.cs b/src/ServerTelemetryChannel/Implementation/Network.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/Network.cs rename to src/ServerTelemetryChannel/Implementation/Network.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/NetworkAvailabilityTransmissionPolicy.cs b/src/ServerTelemetryChannel/Implementation/NetworkAvailabilityTransmissionPolicy.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/NetworkAvailabilityTransmissionPolicy.cs rename to src/ServerTelemetryChannel/Implementation/NetworkAvailabilityTransmissionPolicy.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/PartialSuccessTransmissionPolicy.cs b/src/ServerTelemetryChannel/Implementation/PartialSuccessTransmissionPolicy.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/PartialSuccessTransmissionPolicy.cs rename to src/ServerTelemetryChannel/Implementation/PartialSuccessTransmissionPolicy.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/PlatformFile.cs b/src/ServerTelemetryChannel/Implementation/PlatformFile.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/PlatformFile.cs rename to src/ServerTelemetryChannel/Implementation/PlatformFile.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/PlatformFolder.cs b/src/ServerTelemetryChannel/Implementation/PlatformFolder.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/PlatformFolder.cs rename to src/ServerTelemetryChannel/Implementation/PlatformFolder.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/ResponseStatusCodes.cs b/src/ServerTelemetryChannel/Implementation/ResponseStatusCodes.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/ResponseStatusCodes.cs rename to src/ServerTelemetryChannel/Implementation/ResponseStatusCodes.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/SamplingPercentageEstimatorSettings.cs b/src/ServerTelemetryChannel/Implementation/SamplingPercentageEstimatorSettings.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/SamplingPercentageEstimatorSettings.cs rename to src/ServerTelemetryChannel/Implementation/SamplingPercentageEstimatorSettings.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/SamplingPercentageEstimatorTelemetryProcessor.cs b/src/ServerTelemetryChannel/Implementation/SamplingPercentageEstimatorTelemetryProcessor.cs similarity index 99% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/SamplingPercentageEstimatorTelemetryProcessor.cs rename to src/ServerTelemetryChannel/Implementation/SamplingPercentageEstimatorTelemetryProcessor.cs index 796c72714d..d220f98be2 100644 --- a/src/ServerTelemetryChannel/Managed/Shared/Implementation/SamplingPercentageEstimatorTelemetryProcessor.cs +++ b/src/ServerTelemetryChannel/Implementation/SamplingPercentageEstimatorTelemetryProcessor.cs @@ -5,7 +5,6 @@ using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Extensibility; - using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation; /// /// Represents a method that is invoked every time sampling percentage is evaluated diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/SamplingScoreGenerator.cs b/src/ServerTelemetryChannel/Implementation/SamplingScoreGenerator.cs similarity index 84% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/SamplingScoreGenerator.cs rename to src/ServerTelemetryChannel/Implementation/SamplingScoreGenerator.cs index d913adc0df..9ec618d9f6 100644 --- a/src/ServerTelemetryChannel/Managed/Shared/Implementation/SamplingScoreGenerator.cs +++ b/src/ServerTelemetryChannel/Implementation/SamplingScoreGenerator.cs @@ -18,11 +18,7 @@ public static double GetSamplingScore(ITelemetry telemetry) { double samplingScore = 0; - if (telemetry.Context.User.Id != null) - { - samplingScore = (double)telemetry.Context.User.Id.GetSamplingHashCode() / int.MaxValue; - } - else if (telemetry.Context.Operation.Id != null) + if (telemetry.Context.Operation.Id != null) { samplingScore = (double)telemetry.Context.Operation.Id.GetSamplingHashCode() / int.MaxValue; } @@ -36,7 +32,7 @@ public static double GetSamplingScore(ITelemetry telemetry) internal static int GetSamplingHashCode(this string input) { - if (input == null) + if (string.IsNullOrEmpty(input)) { return 0; } diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/TaskTimerInternal.cs b/src/ServerTelemetryChannel/Implementation/TaskTimerInternal.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/TaskTimerInternal.cs rename to src/ServerTelemetryChannel/Implementation/TaskTimerInternal.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/TelemetryBuffer.cs b/src/ServerTelemetryChannel/Implementation/TelemetryBuffer.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/TelemetryBuffer.cs rename to src/ServerTelemetryChannel/Implementation/TelemetryBuffer.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/TelemetryChannelEventSource.cs b/src/ServerTelemetryChannel/Implementation/TelemetryChannelEventSource.cs similarity index 94% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/TelemetryChannelEventSource.cs rename to src/ServerTelemetryChannel/Implementation/TelemetryChannelEventSource.cs index 705eb451a9..47c536cd91 100644 --- a/src/ServerTelemetryChannel/Managed/Shared/Implementation/TelemetryChannelEventSource.cs +++ b/src/ServerTelemetryChannel/Implementation/TelemetryChannelEventSource.cs @@ -92,7 +92,7 @@ public void ItemSampledOut(string telemetryType, string appDomainName = "Incorre this.WriteEvent(10, telemetryType ?? string.Empty, this.ApplicationName); } - [Event(11, Message = "Storage folder: {0}.", Level = EventLevel.Verbose)] + [Event(11, Message = "Storage folder: {0} successfully validated.", Level = EventLevel.Informational)] public void StorageFolder(string folder, string appDomainName = "Incorrect") { this.WriteEvent(11, folder ?? string.Empty, this.ApplicationName); @@ -369,22 +369,23 @@ public void TransmissionSendingFailedWarning(string transmissionId, string excep [Event( 55, Keywords = Keywords.UserActionable, - Message = "Access to the local storage was denied (User: {1}). If you want Application Insights SDK to store telemetry locally on disk in case of transient network issues please give the process access either to %LOCALAPPDATA% or to %TEMP% folder. After you gave access to the folder you need to restart the process. Currently monitoring will continue but if telemetry cannot be sent it will be dropped. Error message: {0}.", + Message = "Local storage access has resulted in an error (User: {1}) (CustomFolder: {2}). If you want Application Insights SDK to store telemetry locally on disk in case of transient network issues please give the process access to %LOCALAPPDATA% or %TEMP% folder. If application is running in non-windows platform, create StorageFolder yourself, and set ServerTelemetryChannel.StorageFolder to the custom folder name. After you gave access to the folder you need to restart the process. Currently monitoring will continue but if telemetry cannot be sent it will be dropped. Error message: {0}.", Level = EventLevel.Error)] - public void TransmissionStorageAccessDeniedError(string error, string user, string appDomainName = "Incorrect") + public void TransmissionStorageAccessDeniedError(string error, string user, string customFolder, string appDomainName = "Incorrect") { this.WriteEvent( 55, error ?? string.Empty, user ?? string.Empty, + customFolder ?? string.Empty, this.ApplicationName); } [Event( 56, - Message = "Access to the local storage was denied. Error: {0}. User: {1}.", + Message = "Local storage access has resulted in an error. Error Info: {0}. User: {1}.", Level = EventLevel.Warning)] - public void TransmissionStorageAccessDeniedWarning(string error, string user, string appDomainName = "Incorrect") + public void TransmissionStorageIssuesWarning(string error, string user, string appDomainName = "Incorrect") { this.WriteEvent( 56, @@ -481,6 +482,12 @@ public void ItemRejectedNoInstrumentationKey(string item, string appDomainName = this.WriteEvent(67, item ?? string.Empty, this.ApplicationName); } + [Event(68, Message = "Failed to set access permissions on storage directory {0}. Error : {1}.", Level = EventLevel.Warning)] + public void FailedToSetSecurityPermissionStorageDirectory(string directory, string error, string appDomainName = "Incorrect") + { + this.WriteEvent(68, directory, error, this.ApplicationName); + } + private string GetApplicationName() { //// We want to add application name to all events BUT diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/TelemetrySerializer.cs b/src/ServerTelemetryChannel/Implementation/TelemetrySerializer.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/TelemetrySerializer.cs rename to src/ServerTelemetryChannel/Implementation/TelemetrySerializer.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/ThrottlingTransmissionPolicy.cs b/src/ServerTelemetryChannel/Implementation/ThrottlingTransmissionPolicy.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/ThrottlingTransmissionPolicy.cs rename to src/ServerTelemetryChannel/Implementation/ThrottlingTransmissionPolicy.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/TransmissionBuffer.cs b/src/ServerTelemetryChannel/Implementation/TransmissionBuffer.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/TransmissionBuffer.cs rename to src/ServerTelemetryChannel/Implementation/TransmissionBuffer.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/TransmissionExtensions.cs b/src/ServerTelemetryChannel/Implementation/TransmissionExtensions.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/TransmissionExtensions.cs rename to src/ServerTelemetryChannel/Implementation/TransmissionExtensions.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/TransmissionPolicy.cs b/src/ServerTelemetryChannel/Implementation/TransmissionPolicy.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/TransmissionPolicy.cs rename to src/ServerTelemetryChannel/Implementation/TransmissionPolicy.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/TransmissionProcessedEventArgs.cs b/src/ServerTelemetryChannel/Implementation/TransmissionProcessedEventArgs.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/TransmissionProcessedEventArgs.cs rename to src/ServerTelemetryChannel/Implementation/TransmissionProcessedEventArgs.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/TransmissionSender.cs b/src/ServerTelemetryChannel/Implementation/TransmissionSender.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/TransmissionSender.cs rename to src/ServerTelemetryChannel/Implementation/TransmissionSender.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/TransmissionStorage.cs b/src/ServerTelemetryChannel/Implementation/TransmissionStorage.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/TransmissionStorage.cs rename to src/ServerTelemetryChannel/Implementation/TransmissionStorage.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/Transmitter.cs b/src/ServerTelemetryChannel/Implementation/Transmitter.cs similarity index 99% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/Transmitter.cs rename to src/ServerTelemetryChannel/Implementation/Transmitter.cs index 127f398449..73feb017ad 100644 --- a/src/ServerTelemetryChannel/Managed/Shared/Implementation/Transmitter.cs +++ b/src/ServerTelemetryChannel/Implementation/Transmitter.cs @@ -55,7 +55,7 @@ internal Transmitter( public event EventHandler TransmissionSent; - public string StorageFolder { get; set; } + public string StorageFolder { get; set; } public int MaxBufferCapacity { diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/WeakConcurrentRandom.cs b/src/ServerTelemetryChannel/Implementation/WeakConcurrentRandom.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/WeakConcurrentRandom.cs rename to src/ServerTelemetryChannel/Implementation/WeakConcurrentRandom.cs diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/WebApplicationLifecycle.cs b/src/ServerTelemetryChannel/Implementation/WebApplicationLifecycle.cs similarity index 96% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/WebApplicationLifecycle.cs rename to src/ServerTelemetryChannel/Implementation/WebApplicationLifecycle.cs index a88a6b147a..783f460f14 100644 --- a/src/ServerTelemetryChannel/Managed/Shared/Implementation/WebApplicationLifecycle.cs +++ b/src/ServerTelemetryChannel/Implementation/WebApplicationLifecycle.cs @@ -1,4 +1,5 @@ -namespace Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation +#if !NETSTANDARD1_3 +namespace Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation { using System; using System.Threading; @@ -82,4 +83,5 @@ private Task RunOnCurrentThread(Func asyncMethod) return Task.Factory.StartNew(_ => asyncMethod().Wait(), null, CancellationToken.None, TaskCreationOptions.None, CurrentThreadTaskScheduler.Instance); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/XorshiftRandomBatchGenerator.cs b/src/ServerTelemetryChannel/Implementation/XorshiftRandomBatchGenerator.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/Implementation/XorshiftRandomBatchGenerator.cs rename to src/ServerTelemetryChannel/Implementation/XorshiftRandomBatchGenerator.cs diff --git a/src/ServerTelemetryChannel/Managed/Net45/packages.config b/src/ServerTelemetryChannel/Managed/Net45/packages.config deleted file mode 100644 index 375bfb7a13..0000000000 --- a/src/ServerTelemetryChannel/Managed/Net45/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/IIdentityProvider.cs b/src/ServerTelemetryChannel/Managed/Shared/Implementation/IIdentityProvider.cs new file mode 100644 index 0000000000..8ebcfb9806 --- /dev/null +++ b/src/ServerTelemetryChannel/Managed/Shared/Implementation/IIdentityProvider.cs @@ -0,0 +1,13 @@ +namespace Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Shared.Implementation +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using System.Threading.Tasks; + + internal interface IIdentityProvider + { + string GetName(); + } +} diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/NonWindowsIdentityProvider.cs b/src/ServerTelemetryChannel/Managed/Shared/Implementation/NonWindowsIdentityProvider.cs new file mode 100644 index 0000000000..9e5a7750d9 --- /dev/null +++ b/src/ServerTelemetryChannel/Managed/Shared/Implementation/NonWindowsIdentityProvider.cs @@ -0,0 +1,32 @@ +namespace Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Shared.Implementation +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using System.Threading.Tasks; + + internal class NonWindowsIdentityProvider : IIdentityProvider + { + private IDictionary environment; + + public NonWindowsIdentityProvider(IDictionary environment) + { + this.environment = environment; + } + + string IIdentityProvider.GetName() + { + // This variable is not guaranteed to be present. eg: in Docker containers. + if (this.environment["USER"] != null) + { + return this.environment["USER"].ToString(); + } + else + { + return string.Empty; + } + } + } +} diff --git a/src/ServerTelemetryChannel/Managed/Shared/Implementation/WindowsIdentityProvider.cs b/src/ServerTelemetryChannel/Managed/Shared/Implementation/WindowsIdentityProvider.cs new file mode 100644 index 0000000000..412e8b4ae6 --- /dev/null +++ b/src/ServerTelemetryChannel/Managed/Shared/Implementation/WindowsIdentityProvider.cs @@ -0,0 +1,17 @@ +namespace Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Shared.Implementation +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Security.Principal; + using System.Text; + using System.Threading.Tasks; + + internal class WindowsIdentityProvider : IIdentityProvider + { + string IIdentityProvider.GetName() + { + return WindowsIdentity.GetCurrent().Name; + } + } +} diff --git a/src/ServerTelemetryChannel/Managed/Shared/SamplingTelemetryProcessor.cs b/src/ServerTelemetryChannel/SamplingTelemetryProcessor.cs similarity index 84% rename from src/ServerTelemetryChannel/Managed/Shared/SamplingTelemetryProcessor.cs rename to src/ServerTelemetryChannel/SamplingTelemetryProcessor.cs index 5459e9c1f0..8a0ebbae49 100644 --- a/src/ServerTelemetryChannel/Managed/Shared/SamplingTelemetryProcessor.cs +++ b/src/ServerTelemetryChannel/SamplingTelemetryProcessor.cs @@ -2,7 +2,6 @@ { using System; using System.Collections.Generic; - using System.Globalization; using System.Threading; using Microsoft.ApplicationInsights.Channel; @@ -44,7 +43,9 @@ public SamplingTelemetryProcessor(ITelemetryProcessor next) } this.SamplingPercentage = 100.0; - this.Next = next; + this.SampledNext = next; + this.UnsampledNext = next; + this.excludedTypesHashSet = new HashSet(); this.includedTypesHashSet = new HashSet(); this.allowedTypes = new Dictionary(6, StringComparer.OrdinalIgnoreCase) @@ -58,6 +59,16 @@ public SamplingTelemetryProcessor(ITelemetryProcessor next) }; } + internal SamplingTelemetryProcessor(ITelemetryProcessor unsampledNext, ITelemetryProcessor sampledNext) : this(sampledNext) + { + if (unsampledNext == null) + { + throw new ArgumentNullException("unsampledNext"); + } + + this.UnsampledNext = unsampledNext; + } + /// /// Gets or sets a semicolon separated list of telemetry types that should not be sampled. /// Allowed type names: Dependency, Event, Exception, PageView, Request, Trace. @@ -135,9 +146,16 @@ public string IncludedTypes public double SamplingPercentage { get; set; } /// - /// Gets or sets the next TelemetryProcessor in call chain. + /// Gets or sets the next TelemetryProcessor in call chain to send evaluated (sampled) telemetry items to. + /// + private ITelemetryProcessor SampledNext { get; set; } + + /// + /// Gets or sets the next TelemetryProcessor to call in the chain if the ITelemetry item passed in is not sampled. Note that + /// for the public instances of this class (those created by naming the module in ApplicationInsights.config) this property + /// will be equal to the property. /// - private ITelemetryProcessor Next { get; set; } + private ITelemetryProcessor UnsampledNext { get; set; } /// /// Process a collected telemetry item. @@ -147,20 +165,20 @@ public void Process(ITelemetry item) { double samplingPercentage = this.SamplingPercentage; - //// If sampling rate is 100%, there is nothing to do: - if (samplingPercentage >= 100.0 - 1.0E-12) + //// If sampling rate is 100% and we aren't distinguishing between evaluated/unevaluated items, there is nothing to do: + if (this.SampledNext.Equals(this.UnsampledNext) && samplingPercentage >= 100.0 - 1.0E-12) { - this.Next.Process(item); + this.SampledNext.Process(item); return; } - //// So sampling rate is not 100%. + //// So sampling rate is not 100%, or we must evaluate further //// If null was passed in as item or if sampling not supported in general, do nothing: var samplingSupportingTelemetry = item as ISupportSampling; if (samplingSupportingTelemetry == null) { - this.Next.Process(item); + this.UnsampledNext.Process(item); return; } @@ -172,7 +190,7 @@ public void Process(ITelemetry item) TelemetryChannelEventSource.Log.SamplingSkippedByType(item.ToString()); } - this.Next.Process(item); + this.UnsampledNext.Process(item); return; } @@ -180,7 +198,7 @@ public void Process(ITelemetry item) bool itemAlreadySampled = samplingSupportingTelemetry.SamplingPercentage.HasValue; if (itemAlreadySampled) { - this.Next.Process(item); + this.UnsampledNext.Process(item); return; } @@ -191,7 +209,7 @@ public void Process(ITelemetry item) if (isSampledIn) { - this.Next.Process(item); + this.SampledNext.Process(item); } else { diff --git a/src/ServerTelemetryChannel/Managed/Shared/ServerTelemetryChannel.cs b/src/ServerTelemetryChannel/ServerTelemetryChannel.cs similarity index 96% rename from src/ServerTelemetryChannel/Managed/Shared/ServerTelemetryChannel.cs rename to src/ServerTelemetryChannel/ServerTelemetryChannel.cs index e9bf39d84c..fdfda5b528 100644 --- a/src/ServerTelemetryChannel/Managed/Shared/ServerTelemetryChannel.cs +++ b/src/ServerTelemetryChannel/ServerTelemetryChannel.cs @@ -181,7 +181,10 @@ public long MaxTransmissionStorageCapacity /// /// Gets or sets the folder to be used as a temporary storage for events that were not sent because of temporary connectivity issues. - /// If folder was not provided or inaccessible. %LocalAppData% or %Temp% folder will be used. + /// It is the user's responsibility to put appropriate security permissions to this folder. + /// If folder was not provided or inaccessible. %LocalAppData% or %Temp% folder will be used in Windows systems. + /// For Non-Windows systems, providing this folder with write access to the process is required. If not provided or not accessible, + /// telemetry items will be dropped if there are temporary network issues. /// public string StorageFolder { diff --git a/src/ServerTelemetryChannel/Managed/TelemetryChannel.csproj b/src/ServerTelemetryChannel/TelemetryChannel.csproj similarity index 84% rename from src/ServerTelemetryChannel/Managed/TelemetryChannel.csproj rename to src/ServerTelemetryChannel/TelemetryChannel.csproj index 9393ad74b4..03a9e48319 100644 --- a/src/ServerTelemetryChannel/Managed/TelemetryChannel.csproj +++ b/src/ServerTelemetryChannel/TelemetryChannel.csproj @@ -12,7 +12,7 @@ false net45;netstandard1.3 - false + netstandard1.3 True @@ -44,21 +44,14 @@ TRACE;DEBUG;NET45 - - - - - All - All - All All @@ -67,17 +60,13 @@ - - {e9ecee96-dd50-42f6-9f33-0978cdfa15ed} - Microsoft.ApplicationInsights - + - All All @@ -90,18 +79,16 @@ - + PublicAPI.Shipped.txt - + PublicAPI.Unshipped.txt - - 4.3.0 - + diff --git a/src/ServerTelemetryChannel/Managed/Shared/TelemetryProcessorChainBuilderExtensions.cs b/src/ServerTelemetryChannel/TelemetryProcessorChainBuilderExtensions.cs similarity index 100% rename from src/ServerTelemetryChannel/Managed/Shared/TelemetryProcessorChainBuilderExtensions.cs rename to src/ServerTelemetryChannel/TelemetryProcessorChainBuilderExtensions.cs