Skip to content

Commit

Permalink
Only add analytics if not None
Browse files Browse the repository at this point in the history
  • Loading branch information
carl-andersson committed Mar 5, 2025
1 parent 6b5ccb6 commit 9882112
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions fedn/network/combiner/combiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,19 +647,20 @@ def SendHeartbeat(self, heartbeat: fedn.Heartbeat, context):
self.__join_client(client)
self.clients[client.client_id]["last_seen"] = datetime.now()

success, msg = analytic_store.add(
{
"id": str(uuid.uuid4()),
"sender_id": client.client_id,
"sender_role": "client",
"cpu_utilisation": heartbeat.cpu_utilisation,
"memory_utilisation": heartbeat.memory_utilisation,
"committed_at": datetime.now(),
}
)
if heartbeat.cpu_utilisation is not None or heartbeat.memory_utilisation is not None:
success, msg = analytic_store.add(
{
"id": str(uuid.uuid4()),
"sender_id": client.client_id,
"sender_role": "client",
"cpu_utilisation": heartbeat.cpu_utilisation,
"memory_utilisation": heartbeat.memory_utilisation,
"committed_at": datetime.now(),
}
)

if not success:
logger.error(f"GRPC: SendHeartbeat error: {msg}")
if not success:
logger.error(f"GRPC: SendHeartbeat error: {msg}")

response = fedn.Response()
response.sender.name = heartbeat.sender.name
Expand Down

0 comments on commit 9882112

Please sign in to comment.