-
Notifications
You must be signed in to change notification settings - Fork 5
chore: added latency tooltips on workspaces #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
c77369b
b05f081
419dcb2
d1b2c7d
8fbbff0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
using System.Collections.ObjectModel; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Security.Principal; | ||
using System.Threading.Tasks; | ||
using Coder.Desktop.App.Models; | ||
using Coder.Desktop.App.Services; | ||
|
@@ -29,6 +30,7 @@ | |
{ | ||
private const int MaxAgents = 5; | ||
private const string DefaultDashboardUrl = "https://coder.com"; | ||
private readonly TimeSpan HealthyPingThreshold = TimeSpan.FromMilliseconds(150); | ||
|
||
private readonly IServiceProvider _services; | ||
private readonly IRpcController _rpcController; | ||
|
@@ -222,12 +224,26 @@ | |
if (string.IsNullOrWhiteSpace(fqdn)) | ||
continue; | ||
|
||
|
||
var lastHandshakeAgo = DateTime.UtcNow.Subtract(agent.LastHandshake.ToDateTime()); | ||
Check warning on line 228 in App/ViewModels/TrayWindowViewModel.cs
|
||
var connectionStatus = lastHandshakeAgo < TimeSpan.FromMinutes(5) | ||
? AgentConnectionStatus.Green | ||
: AgentConnectionStatus.Yellow; | ||
|
||
// For compatibility with older deployments, we assume that if the | ||
// last ping is null, the agent is healthy. | ||
var isLatencyAcceptable = agent.LastPing != null ? agent.LastPing.Latency.ToTimeSpan() < HealthyPingThreshold : true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you check that the behavior of the C# protobuf library does this? They usually just use a zero value when it's not set to be consistent with other protobuf implementations There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, for reference types it will be null. |
||
var connectionStatus = AgentConnectionStatus.Healthy; | ||
if (lastHandshakeAgo > TimeSpan.FromMinutes(5)) | ||
{ | ||
connectionStatus = AgentConnectionStatus.NoRecentHandshake; | ||
} | ||
else if (!isLatencyAcceptable) | ||
{ | ||
connectionStatus = AgentConnectionStatus.Unhealthy; | ||
} | ||
|
||
|
||
workspacesWithAgents.Add(agent.WorkspaceId); | ||
var workspace = rpcModel.Workspaces.FirstOrDefault(w => w.Id == agent.WorkspaceId); | ||
System.Diagnostics.Debug.WriteLine($"Agent {uuid} LastHandshakeAgo: {lastHandshakeAgo} ConnectionStatus: {connectionStatus} FQDN: {fqdn} Last ping: {agent.LastPing} Last handshake: {agent.LastHandshake}"); | ||
|
||
agents.Add(_agentViewModelFactory.Create( | ||
this, | ||
|
@@ -236,7 +252,12 @@ | |
_hostnameSuffixGetter.GetCachedSuffix(), | ||
connectionStatus, | ||
credentialModel.CoderUrl, | ||
workspace?.Name)); | ||
workspace?.Name, | ||
agent.LastPing?.DidP2P, | ||
agent.LastPing?.PreferredDerp, | ||
agent.LastPing?.Latency?.ToTimeSpan(), | ||
agent.LastPing?.PreferredDerpLatency?.ToTimeSpan(), | ||
agent.LastHandshake?.ToDateTime())); | ||
} | ||
|
||
// For every stopped workspace that doesn't have any agents, add a | ||
|
@@ -253,7 +274,7 @@ | |
// conflict with any agent IDs. | ||
uuid, | ||
_hostnameSuffixGetter.GetCachedSuffix(), | ||
AgentConnectionStatus.Gray, | ||
AgentConnectionStatus.Offline, | ||
credentialModel.CoderUrl, | ||
workspace.Name)); | ||
} | ||
|
@@ -268,7 +289,7 @@ | |
|
||
if (Agents.Count < MaxAgents) ShowAllAgents = false; | ||
|
||
var firstOnlineAgent = agents.FirstOrDefault(a => a.ConnectionStatus != AgentConnectionStatus.Gray); | ||
var firstOnlineAgent = agents.FirstOrDefault(a => a.ConnectionStatus != AgentConnectionStatus.Offline); | ||
if (firstOnlineAgent is null) | ||
_hasExpandedAgent = false; | ||
if (!_hasExpandedAgent && firstOnlineAgent is not null) | ||
|
@@ -433,7 +454,7 @@ | |
case Workspace.Types.Status.Stopping: | ||
case Workspace.Types.Status.Stopped: | ||
return true; | ||
// TODO: should we include and show a different color than Gray for workspaces that are | ||
// TODO: should we include and show a different color than Offline for workspaces that are | ||
// failed, canceled or deleting? | ||
default: | ||
return false; | ||
|
Uh oh!
There was an error while loading. Please reload this page.