From 88007a7f26a9aba817ccd5fb446c16c9780ec332 Mon Sep 17 00:00:00 2001 From: thithanhtuyennguyen Date: Tue, 24 Mar 2026 15:05:51 -0500 Subject: [PATCH] Fix CPU metrics mixed for different Azure SQL databases on same server 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: Claude Opus 4.6 (1M context) --- Lite/Services/RemoteCollectorService.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Lite/Services/RemoteCollectorService.cs b/Lite/Services/RemoteCollectorService.cs index e8f51c9..afbd489 100644 --- a/Lite/Services/RemoteCollectorService.cs +++ b/Lite/Services/RemoteCollectorService.cs @@ -682,12 +682,18 @@ protected static long GenerateCollectionId() /// /// Gets the server name used for DuckDB storage and hashing. + /// Appends the database name for Azure SQL Database connections so that + /// different databases on the same logical server get distinct server_ids. /// Appends ":RO" for ReadOnlyIntent connections so they get a /// different server_id than read-write connections to the same host. /// internal static string GetServerNameForStorage(ServerConnection server) { - return server.ReadOnlyIntent ? server.ServerName + ":RO" : server.ServerName; + var name = string.IsNullOrWhiteSpace(server.DatabaseName) + ? server.ServerName + : server.ServerName + ":" + server.DatabaseName; + + return server.ReadOnlyIntent ? name + ":RO" : name; } ///