/// <summary> /// Reports health of all the Azure roleinstances corresponding to the Windows Fabric nodes /// to the Windows Fabric health store. /// </summary> /// <param name="validityPeriod">Serves as an indication to the watchdog as to how long the reported health is valid for.</param> public void ReportHealth(TimeSpan validityPeriod) { // start with an initial assumption that health is okay. const HealthState InputHealthState = HealthState.Ok; try { IList <RoleInstance> roleInstances = GetRoleInstances(); HealthState serviceHealthState = roleInstances == null ? HealthState.Warning : GetRoleInstanceHealth(roleInstances, InputHealthState, healthPolicyManager); string description = GetServiceHealthDescription(roleInstances, serviceHealthState); // Specify a time to live. In case infrastructure service is down, the health report shows up as warning (or error) var hi = new HealthInformation( HealthConstants.HealthReportSourceId, HealthConstants.HealthReportReplicaHealthWatchdogStatus, serviceHealthState) { Description = description, TimeToLive = validityPeriod != TimeSpan.Zero ? validityPeriod : TimeSpan.MaxValue, RemoveWhenExpired = true }; // Construct this name ourselves since there is currently a bug where the service Uri which // could have been passed in all the way from ServiceFactory's CreateReplica is an empty string. var serviceUri = new Uri(ServiceNamePrefix + coordinator.ConfigSectionName); // We'll roll up the health to the service level bypassing the replica and partition health. // Since only 1 replica is actively doing something and there is only a single partition of // this service, rolling up health higher is preferred since it can catch the user's eyes a // little bit faster. var healthReport = new ServiceHealthReport(serviceUri, hi); healthClient.ReportHealth(healthReport); } catch (Exception ex) { Trace.WriteWarning( HealthConstants.TraceType, "Unable to report health from role instance health watchdog. Error(s): {0}", ex.GetMessage()); } }
/// <inheritdoc/> public void ReportHealth(HealthReport healthReport, HealthReportSendOptions sendOptions) { _healthClient.ReportHealth(healthReport, sendOptions); }
public void ReportHealth(HealthReport healthReport) { healthReport.Validate("healthReport"); healthClient.ReportHealth(healthReport); }