Skip to content

Track operation time for SQL Server database metric executors - #24954

Open
jasonmp85 wants to merge 4 commits into
masterfrom
jmp/sqlserver-3c-operation-time
Open

Track operation time for SQL Server database metric executors#24954
jasonmp85 wants to merge 4 commits into
masterfrom
jmp/sqlserver-3c-operation-time

Conversation

@jasonmp85

@jasonmp85 jasonmp85 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Passes track_operation_time through when constructing database metric executors, so each collector reports how long it took.

Measured effect

With this branch, a single check run against a 3,945-database bench instance attributes its own cost, which previously required a custom harness running each collector in isolation:

collector min_ms avg_ms batches samples
file stats 630.9 654.4 3 78,971
database stats 173.1 181.4 3 19,726
database backup 69.4 77.9 3 3,946
index usage 13.2 37.0 12 5
database files 13.5 22.8 12 30
tempdb file space 9.9 10.8 4 5
server state 8.8 9.1 3 7

That table is the entire point of the change: it identifies file stats as 69% of a 918.8 ms collection immediately, from telemetry alone. This measurement is what scoped the fix in #24952.

Motivation

There is currently no per-collector timing for database metrics, which makes it impossible to tell from telemetry alone which collector is responsible for a slow collection interval. Support cases involving slow SQL Server checks presently require reproducing the customer's schema locally to find out where the time goes.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Aug 21, 2026

Copy link
Copy Markdown

Tests  Code Coverage

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 88.76%

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: f671087 | Docs | View more details | Give us feedback!

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 21, 2026

Copy link
Copy Markdown

evalya-impact-summary

evalya impact analysis
Impact analysis: 0 selected, 0 skipped (of 0 test tasks)
Publish tasks:   1 (always emitted)
Diff (12 files):
  datadog_checks_base/changelog.d/24954.fixed
  datadog_checks_base/datadog_checks/base/utils/db/core.py
  datadog_checks_base/tests/base/utils/db/test_query_executor.py
  sqlserver/changelog.d/24954.fixed
  sqlserver/datadog_checks/sqlserver/database_metrics/base.py
  sqlserver/datadog_checks/sqlserver/database_metrics/database_files_metrics.py
  sqlserver/datadog_checks/sqlserver/database_metrics/db_fragmentation_metrics.py
  sqlserver/datadog_checks/sqlserver/database_metrics/index_usage_metrics.py
  sqlserver/datadog_checks/sqlserver/database_metrics/table_size_metrics.py
  sqlserver/datadog_checks/sqlserver/database_metrics/tempdb_file_space_usage_metrics.py
  sqlserver/datadog_checks/sqlserver/sqlserver.py
  sqlserver/tests/test_database_metrics.py

Debug a specific task: evalya plan impact --path <path> --task <task>

Learn more about CI impact filtering

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 32f43ccb35

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread sqlserver/datadog_checks/sqlserver/sqlserver.py
@jasonmp85
jasonmp85 force-pushed the jmp/sqlserver-3c-operation-time branch from 32f43cc to 6238bef Compare August 21, 2026 21:58
@dd-octo-sts

dd-octo-sts Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant