Skip to content

Commit 851dc0f

Browse files
committed
Removed IsNotSendingHeartbeats it was giving false positives at startup
1 parent c090fb4 commit 851dc0f

File tree

5 files changed

+9
-12
lines changed

5 files changed

+9
-12
lines changed

src/ServiceControl.Persistence/EndpointsView.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace ServiceControl.Persistence
22
{
33
using System;
4-
using System.Text.Json.Serialization;
54

65
public class EndpointsView
76
{
@@ -12,6 +11,5 @@ public class EndpointsView
1211
public bool MonitorHeartbeat { get; set; }
1312
public HeartbeatInformation HeartbeatInformation { get; set; }
1413
public bool IsSendingHeartbeats { get; set; }
15-
[JsonIgnore] public bool IsNotSendingHeartbeats { get; set; }
1614
}
1715
}

src/ServiceControl.UnitTests/Monitoring/HeartbeatEndpointSettingsSyncHostedServiceTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ public async Task
138138
var mockMonitoringDataStore = new MockMonitoringDataStore(
139139
[new KnownEndpoint { EndpointDetails = new EndpointDetails { Name = endpointName1 } }]);
140140
var mockEndpointInstanceMonitoring = new MockEndpointInstanceMonitoring([
141-
new EndpointsView { IsNotSendingHeartbeats = true, Name = endpointName1, Id = instanceA },
142-
new EndpointsView { IsNotSendingHeartbeats = true, Name = endpointName1, Id = instanceB },
143-
new EndpointsView { IsNotSendingHeartbeats = true, Name = endpointName1, Id = instanceC },
141+
new EndpointsView { IsSendingHeartbeats = false, Name = endpointName1, Id = instanceA },
142+
new EndpointsView { IsSendingHeartbeats = false, Name = endpointName1, Id = instanceB },
143+
new EndpointsView { IsSendingHeartbeats = false, Name = endpointName1, Id = instanceC },
144144
new EndpointsView
145145
{
146-
IsNotSendingHeartbeats = false,
146+
IsSendingHeartbeats = true,
147147
Name = endpointName1,
148148
Id = DeterministicGuid.MakeId(endpointName1, "D")
149149
}
@@ -179,10 +179,10 @@ public async Task
179179
var mockMonitoringDataStore = new MockMonitoringDataStore(
180180
[new KnownEndpoint { EndpointDetails = new EndpointDetails { Name = endpointName1 } }]);
181181
var mockEndpointInstanceMonitoring = new MockEndpointInstanceMonitoring([
182-
new EndpointsView { IsNotSendingHeartbeats = true, Name = endpointName1, Id = instanceA },
182+
new EndpointsView { IsSendingHeartbeats = false, Name = endpointName1, Id = instanceA },
183183
new EndpointsView
184184
{
185-
IsNotSendingHeartbeats = false,
185+
IsSendingHeartbeats = true,
186186
Name = endpointName1,
187187
Id = DeterministicGuid.MakeId(endpointName1, "B")
188188
}

src/ServiceControl/Monitoring/EndpointInstanceMonitoring.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ public EndpointsView[] GetEndpoints()
120120
{
121121
var view = endpoint.GetView();
122122
view.IsSendingHeartbeats = heartbeatLookup[endpoint.Id].Any(x => x.IsSendingHeartbeats());
123-
view.IsNotSendingHeartbeats = heartbeatLookup[endpoint.Id].Any(x => x.IsNotSendingHeartbeats());
124123
list.Add(view);
125124
}
126125

src/ServiceControl/Monitoring/HeartbeatEndpointSettingsSyncHostedService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ async Task PerformSync(CancellationToken cancellationToken)
6363

6464
async Task PurgeMonitoringDataThatDoesNotNeedToBeTracked(CancellationToken cancellationToken)
6565
{
66-
ILookup<string, Guid> monitorEndpointsLookup = endpointInstanceMonitoring.GetEndpoints()
67-
.Where(view => view.IsNotSendingHeartbeats)
66+
EndpointsView[] endpointsViews = endpointInstanceMonitoring.GetEndpoints();
67+
ILookup<string, Guid> monitorEndpointsLookup = endpointsViews
68+
.Where(view => !view.IsSendingHeartbeats)
6869
.ToLookup(view => view.Name, view => view.Id);
6970
await foreach (EndpointSettings endpointSetting in endpointSettingsStore.GetAllEndpointSettings()
7071
.WithCancellation(cancellationToken))

src/ServiceControl/Monitoring/HeartbeatMonitor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public RecordedHeartbeat MarkDeadIfOlderThan(DateTime cutoff)
4747
}
4848

4949
public bool IsSendingHeartbeats() => heartbeat?.Status == HeartbeatStatus.Alive;
50-
public bool IsNotSendingHeartbeats() => heartbeat?.Status == HeartbeatStatus.Dead;
5150
volatile RecordedHeartbeat heartbeat = new RecordedHeartbeat(HeartbeatStatus.Unknown, null);
5251
}
5352
}

0 commit comments

Comments
 (0)