Skip to content

Conversation

@sv-splunk
Copy link
Contributor

@sv-splunk sv-splunk commented Jan 5, 2026

Description

SQLServer metrics reporting is improved by reducing the warm-up delay and providing accurate insights sooner.
In the existing implementation, only the totalElapsedTime metric is cached during the first collection, while all other metrics are skipped and cached only in the second collection. As a result, delta calculations are not possible at that point and can only be performed starting from the third collection.

This PR fixes the issue by caching all metrics starting from the first collection onwards.

Also to get the total of all cumulative metrics records from sys.dm_exec_query_stats, we should move the time period filter from inner query to outer. With that being within the inner query, we were considering only records created within the collection window, resulting in calculation of a wrong total of cumulative records.

Link to tracking issue

Fixes #45228

Testing

Unit tests added. Also ran in internal environment for extended testing.

@sv-splunk sv-splunk changed the title Improve PostgreSQL metrics accuracy by reducing the warm-up delay Improve SQLServer metrics accuracy by reducing the warm-up delay Jan 5, 2026
// We just send down the metrics corresponding to that single execution as it is.
// If execution count in DB is not 1 then we send down the delta values.
execCountInDB := executionCountVal.(int64)
if execCountInDB != 1 {
Copy link
Member

@XSAM XSAM Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why treating 1 as a special case. If a query only runs for once, will this change report this query each time the collector restarts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@XSAM I have details in the PR description, please check and let me know if you need more info.

@sv-splunk sv-splunk changed the title Improve SQLServer metrics accuracy by reducing the warm-up delay [WIP] Improve SQLServer metrics accuracy by reducing the warm-up delay Jan 7, 2026
@sv-splunk sv-splunk changed the title [WIP] Improve SQLServer metrics accuracy by reducing the warm-up delay [WIP] Improve SQLServer metrics accuracy by reducing the warm-up delay and including all available cumulative records from DB Jan 7, 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.

[receiver/sqlserver] Improve SQLServer metrics accuracy by reducing the warm-up delay and including all available cumulative records from DB

2 participants