Skip to content

Commit c953158

Browse files
tnguyen7serikdarlingdatathithanhtuyennguyenclaude
authored
Fix CPU metrics mixed for different Azure SQL databases on same server (#680)
GetServerNameForStorage() used only the server hostname to generate storage keys, so multiple Azure SQL databases on the same logical server (e.g. myserver.database.windows.net) produced identical server_ids and their metrics were conflated. Include DatabaseName in the storage key when set, following the existing pattern used for ReadOnlyIntent connections. Fixes #677 Co-authored-by: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Co-authored-by: thithanhtuyennguyen <tuyen.nguyen@wwinc.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 119d8d2 commit c953158

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Lite/Services/RemoteCollectorService.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,12 +682,18 @@ protected static long GenerateCollectionId()
682682

683683
/// <summary>
684684
/// Gets the server name used for DuckDB storage and hashing.
685+
/// Appends the database name for Azure SQL Database connections so that
686+
/// different databases on the same logical server get distinct server_ids.
685687
/// Appends ":RO" for ReadOnlyIntent connections so they get a
686688
/// different server_id than read-write connections to the same host.
687689
/// </summary>
688690
internal static string GetServerNameForStorage(ServerConnection server)
689691
{
690-
return server.ReadOnlyIntent ? server.ServerName + ":RO" : server.ServerName;
692+
var name = string.IsNullOrWhiteSpace(server.DatabaseName)
693+
? server.ServerName
694+
: server.ServerName + ":" + server.DatabaseName;
695+
696+
return server.ReadOnlyIntent ? name + ":RO" : name;
691697
}
692698

693699
/// <summary>

0 commit comments

Comments
 (0)