Skip to content

Fix CPU metrics mixed for different Azure SQL databases on same server#680

Merged
erikdarlingdata merged 5 commits intoerikdarlingdata:devfrom
tnguyen7s:fix/azure-sql-cpu-metrics-mixed
Mar 24, 2026
Merged

Fix CPU metrics mixed for different Azure SQL databases on same server#680
erikdarlingdata merged 5 commits intoerikdarlingdata:devfrom
tnguyen7s:fix/azure-sql-cpu-metrics-mixed

Conversation

@tnguyen7s
Copy link

Summary

  • GetServerNameForStorage() used only the server hostname to generate storage keys, so multiple Azure SQL databases on the same logical server produced identical server_ids and their metrics were conflated
  • Include DatabaseName in the storage key when set, following the existing pattern used for :RO (ReadOnlyIntent) connections

Fixes #677

Test plan

  • Build compiles without warnings (there are 3 warnings, CS8602: Dereference of a possibly null reference, that appear to happen before the changes)
  • Connect two Azure SQL databases on the same logical server with different database names
  • Wait for initial collection (5 minutes)
  • Verify FinOps > Utilization shows separate CPU stats (Average, P95, Maximum) for each database
  • Code follows the style guidelines
  • No hardcoded paths or credentials
  • Changes are documented (comments, README if applicable)

erikdarlingdata and others added 5 commits March 11, 2026 20:29
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 erikdarlingdata#677

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@erikdarlingdata
Copy link
Owner

Great fix and thorough testing! We had independently landed on the same approach on our side (#679). One minor suggestion — would you mind switching the separator from : to / so the storage key reads server/database:RO instead of server:database:RO? Keeps the :RO suffix unambiguous. Either way, thanks for the contribution and the real-world Azure SQL DB validation!

@erikdarlingdata erikdarlingdata changed the base branch from main to dev March 24, 2026 21:45
@erikdarlingdata erikdarlingdata merged commit c953158 into erikdarlingdata:dev Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] CPU metrics mixed for different Azure SQL databases on the same logical server

2 participants