Skip to content

Conversation

@joelmarcotte
Copy link
Contributor

@joelmarcotte joelmarcotte commented May 20, 2025

This pull request introduces support for a new $full_server_name variable in the SQL Server integration for the template config key, which represents the full server name as returned by @@SERVERNAME. The changes include updates to constants, configuration templates, caching mechanisms, and tests to incorporate this new field.

Enhancements to SQL Server Integration:

Support for full_server_name:

  • Added STATIC_INFO_FULL_SERVERNAME as a new constant in sqlserver/datadog_checks/sqlserver/const.py to represent the full server name.
  • Updated the example configuration file (sqlserver/datadog_checks/sqlserver/data/conf.yaml.example) to include full_server_name as a new template option for identifying SQL Server instances.

Updates to Static Information Cache:

  • Modified load_static_information in sqlserver/datadog_checks/sqlserver/sqlserver.py to cache the full_server_name value.
  • Updated database_identifier in sqlserver/datadog_checks/sqlserver/sqlserver.py to use STATIC_INFO_FULL_SERVERNAME when applicable.
  • When a servername is present, make sure the instancename fallsback to '' if its value is None to avoid seeing None in the output.

Test Coverage:

  • Enhanced unit tests in sqlserver/tests/test_unit.py to validate full_server_name functionality, including its usage in templates and caching. [1] [2]

@joelmarcotte joelmarcotte requested review from a team as code owners May 20, 2025 20:21
@joelmarcotte joelmarcotte changed the title Add support as template variable to sqlserver template config key Add full_server_name support as template variable to sqlserver template config key May 20, 2025
@codecov
Copy link

codecov bot commented May 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.45%. Comparing base (824902a) to head (449dac0).
Report is 15 commits behind head on master.

Additional details and impacted files
Flag Coverage Δ
activemq ?
cassandra ?
confluent_platform ?
hive ?
hivemq ?
hudi ?
ignite ?
jboss_wildfly ?
kafka ?
presto ?
solr ?
sqlserver 91.14% <100.00%> (+4.49%) ⬆️
tomcat ?
weblogic ?

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines 110 to 112
# template: $env-$resolved_hostname:$port
# template: $full_server_name
Copy link
Contributor

Choose a reason for hiding this comment

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

This example exists to show how to use tags, why is it changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Many users will simply wonder what's the best variable to use to name their sqlserver instance. For sqlserver the default should be $full_server_name in my opinion (if users are willing to diverge from the actual default of $resolved_hostname).

# Keys of the static info cache, used to cache server info which does not change
STATIC_INFO_SERVERNAME = 'servername'
STATIC_INFO_INSTANCENAME = 'instancename'
STATIC_INFO_FULL_SERVERNAME = 'full_servername'
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: let's be consistent of if it's server_name or servername

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought I was being consistent here, since servername above is one word, yet its template variable is $server_name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the static variable is full_servername and the actual template variable is full_server_name

sethsamuel
sethsamuel previously approved these changes May 20, 2025
@temporal-github-worker-1 temporal-github-worker-1 bot dismissed sethsamuel’s stale review May 20, 2025 21:14

Review from sethsamuel is dismissed. Related teams and files:

  • database-monitoring-agent
    • sqlserver/assets/configuration/spec.yaml
    • sqlserver/datadog_checks/sqlserver/data/conf.yaml.example
@joelmarcotte joelmarcotte added this pull request to the merge queue May 23, 2025
Merged via the queue into master with commit d10b952 May 23, 2025
39 checks passed
@joelmarcotte joelmarcotte deleted the joel.marcotte/add-full_server_name-sqlserver branch May 23, 2025 12:41
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.

3 participants