public void DefaultHeartbeatPropertyProviderSendsNoFieldWhenDisabled() { var mockHbeat = new HeartbeatProviderMock(); IHeartbeatDefaultPayloadProvider baseDefaultProvider = HeartbeatDefaultPayload.DefaultPayloadProviders.First(); var hbeatPayload = HeartbeatDefaultPayload.PopulateDefaultPayload(new string[] { }, new string[] { baseDefaultProvider.Name }, mockHbeat); hbeatPayload.GetAwaiter().GetResult(); // for each heartbeat property recorded into the heartbeat provider, none should be a registered keyword on // this base default heartbeat property provider. foreach (string payloadPropertyName in mockHbeat.HeartbeatProperties.Keys) { Assert.IsFalse(baseDefaultProvider.IsKeyword(payloadPropertyName)); } }
public void CanDisableHeartbeatPropertyProviderPriorToInitialize() { using (var initializedModule = new DiagnosticsTelemetryModule()) { // disable the heartbeat property provider 'Base' at construction time but before initialize // (this simulates the flow of disabling the heartbeat via config) IHeartbeatPropertyManager hbeat = initializedModule; IHeartbeatDefaultPayloadProvider hbeatPropProvider = HeartbeatDefaultPayload.DefaultPayloadProviders.First(); hbeat.ExcludedHeartbeatPropertyProviders.Add(hbeatPropProvider.Name); // dig into the heartbeat provider itself to ensure this is indeed disabled Assert.IsTrue(initializedModule.HeartbeatProvider.ExcludedHeartbeatPropertyProviders.Contains(hbeatPropProvider.Name)); // initialize the DiagnosticsTelemetryModule, and check that heartbeats are still disabled initializedModule.Initialize(new TelemetryConfiguration()); // ensure this heartbeat property provider is still disabled after init Assert.IsTrue(initializedModule.HeartbeatProvider.ExcludedHeartbeatPropertyProviders.Contains(hbeatPropProvider.Name)); } }