Ensure Heartbeat properties for App Services is included in AspNetCore#627
Ensure Heartbeat properties for App Services is included in AspNetCore#627
Conversation
|
Note that PR microsoft/ApplicationInsights-dotnet-server#873 must be submitted and available on myget before I will be able to successfully build this one. I've started this PR to facilitate code review prior to that condition being met.
|
| <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.0-beta2-build12842" /> | ||
| <PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.6.0-beta2-build12842" /> | ||
| <PackageReference Include="Microsoft.ApplicationInsights.WindowsServer" Version="2.6.0-beta2-build12842" /> | ||
| <PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" Version="2.6.0-beta2" /> |
There was a problem hiding this comment.
These changes will not be submitted. Once the PR in -dotnet-server completes I will update these references to the latest release there.
NuGet.config
Outdated
| <clear /> | ||
| <add key="NuGet" value="https://api.nuget.org/v3/index.json" /> | ||
| <add key="applicationinsights" value="https://www.myget.org/F/applicationinsights/api/v3/index.json" /> | ||
| <add key="Local" value="D:\dev\github\ai\bin\Debug\Nuget" /> |
There was a problem hiding this comment.
This change will not be submitted. Only here for local development work while I wait for -dotnet-server to get posted to myget.
There was a problem hiding this comment.
I've removed this now, and have updated the dependencies to a myget package representing a more valid candidate for the next beta release here.
|
@cijothomas if you could take a look at this and provide a review I'd be grateful. Would very much like this to hit 2.6.0-beta3 timeframe.
|
|
|
||
| services.AddSingleton<ITelemetryInitializer, AzureWebAppRoleEnvironmentTelemetryInitializer>(); | ||
| services.AddSingleton<ITelemetryInitializer, DomainNameRoleInstanceTelemetryInitializer>(); | ||
| services.AddSingleton<ITelemetryInitializer, ApplicationInsights.AspNetCore.TelemetryInitializers.AzureWebAppRoleEnvironmentTelemetryInitializer>(); |
There was a problem hiding this comment.
Can this be taken from the WindowsServer package? If not - aspnetcore and web might set different values for role name and role instance
There was a problem hiding this comment.
It most certainly can. I've added issue #624 to track this as a separate issue. There will need to be some work to consolidate the modules properly as the implementations have diverged.
EDIT: Updated to correct issue (I'd opened a duplicate)
| // Disable heartbeat if user sets it (by default it is on) | ||
| if (!this.applicationInsightsServiceOptions.EnableHeartbeat) | ||
| { | ||
| foreach (var module in TelemetryModules.Instance.Modules) |
There was a problem hiding this comment.
Will this singleton be initialized at all in aspnetcore case?
There was a problem hiding this comment.
Yes. I'm adding tests to prove that now.
There was a problem hiding this comment.
Unfortunately ,no from my experiments and this issue
#506
There was a problem hiding this comment.
Tests added. Singleton is there, DiagnosticsTelemetryModule is there, and that is the IHeartbeatPropertyManager implementation at present.
Let's talk about a better public API for heartbeat in 2.7 timeframe.
There was a problem hiding this comment.
Just lucky(?) that only modules added from base sdk is present. (DiagnosticsTelemetryModule is added by base sdk)
There was a problem hiding this comment.
Yes, this is just lucky and we are indeed relying on the implementation details in the base SDK here.
Tests that I added are failing outside of the Visual Studio environment, I'm investigating now.
CHANGELOG.md
Outdated
| # Changelog | ||
|
|
||
| ## Version 2.6.0-beta1 | ||
| - [Add support for Heartbeat properties in AspNetCore. Add App Services and Azure Instanace Metedata heartbeat provider modules by default, support disable of heartbeats.](https://github.com/Microsoft/ApplicationInsights-aspnetcore/pull/627) |
There was a problem hiding this comment.
Metadata - spellcheck.
Add support for Heartbeat properties - we already had this support right? So just mention about the ability to turn-off hearbeat.
| { | ||
| if (module is IHeartbeatPropertyManager hbeatMan) | ||
| { | ||
| hbeatMan.IsHeartbeatEnabled = false; |
There was a problem hiding this comment.
Setting IsHeartbeatEnabled to false will stop the HeartBeats collected/sent by the AppServicesHeartbeatTelemetryModule, AzureInstanceMetadataTelemetryModule modules as well - right?
There was a problem hiding this comment.
Yes, this is the intention. Setting IsHeartbeatEnabled to false should disable heartbeats altogether.
cijothomas
left a comment
There was a problem hiding this comment.
Blocking to prevent accidental merge.
Tests need to be addressed.
|
How do I debug my xUnit tests in .NET Core? I can see the tests failing on the command line I've instrumented a .NET Core web app and will see if the thing behaves as expected tomorrow. Is there any guidance that I can refer to on this matter? Multi-targeted framework solutions should probably be working in Visual Studio 2017... |
|
@d3r3kk What specific issue are you hitting with VS debugging? VS is not showing the tests in test runner/explorer? It shows the tets from the 1st target only. So if you are debugging net46, change the order so that net46 appears first. |
- only enable heartbeat collection for app services in this PR
- Using signed package based off of PR microsoft/ApplicationInsights-dotnet-server#873
- fix issues with static initialization in the unit test expectations in XUnit - we must sort this out in 2.7.0-betaX by ensuring we can initialize mutliple times during testing - (and ensure we can debug in VS during unit test passes)
9b326b6 to
491bcad
Compare
|
@cijothomas Please re-review this change. I think I understand why the tests are failing but have not been able to step through in the debugger. Not sure why we are having this trouble, but moving to vstest might be superior in the long run. |
Tests are passing now. Other comments are addressed.
|
We are in. @cijothomas and @MS-TimothyMothra to help sort out versioning and such... |
Extension of issue microsoft/ApplicationInsights-dotnet-server#868 "Enabling Heartbeat in App Services..." in .NET Core scenarios.
ApplicationInsightsServiceOptions, reviewed with @cijothomas