Skip to content

feat(sqlserverreceiver): Port v0.150.0 with passfile auth, gap metrics, and top applications - #618

Closed
Klarsen04 wants to merge 4 commits into
dbi-sqlserverfrom
larkirs/dbi-sqlserver
Closed

feat(sqlserverreceiver): Port v0.150.0 with passfile auth, gap metrics, and top applications#618
Klarsen04 wants to merge 4 commits into
dbi-sqlserverfrom
larkirs/dbi-sqlserver

Conversation

@Klarsen04

Copy link
Copy Markdown

Description of the issue

The CloudWatch Agent's SQL Server receiver (fork) needed several enhancements to support Database Insights (DBI): upstream v0.150.0 features (query sample collection, top query tracking via sys.dm_exec_query_stats), passfile-based authentication, and application name attribute for "Top Applications" dimension.

Description of changes

  1. Port upstream v0.150.0 — Brings in query sample collection from sys.dm_exec_requests and sys.dm_exec_sessions, top query collection from sys.dm_exec_query_stats, SQL and query plan obfuscation (DataDog obfuscate package), LRU caching for delta computation and query plan caching, priority queue for top-N query selection, direct-connect support for Linux SQL Server, and trace propagation support.

  2. Passfile support — Implements ADO connection string passfile authentication for SQL Server (the Go mssql driver has no native passfile support). Passfile contains one complete ADO connection string per line (server=host;user id=user;password=pass;port=1433), allowing secure credential storage.

  3. Top Applications support — Adds sqlserver.application.name attribute extracted from program_name in sys.dm_exec_sessions to enable "Top Applications" dimension. Includes self-filtering query (WHERE s.session_id != @@SPID) to exclude the monitoring session itself from query samples.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Unit tests ported and updated across all changes (scraper_test, factory_test, config_test, queries_test, passfile_test, obfuscate_test, priority_queue_test). Expected SQL/YAML fixtures added for query sample scraping, database I/O, wait stats, and performance counters. Integration tested end-to-end with CloudWatch Agent on EC2 Windows and Linux SQL Server.

… top query support

Port the SQL Server receiver from otel-bump-v0.150.0, adding:
- Query sample collection from sys.dm_exec_requests
- Top query collection from sys.dm_exec_query_stats
- SQL and query plan obfuscation with DataDog obfuscator
- LRU caching for delta computation and query plan caching
- Session status and wait type detection
- Independent collection intervals for top queries
- Priority queue implementation for query ranking
- Service instance ID generation
- Integration test scaffolding and testdata
- Logs builder for event emission
- Wait stats support and testdata

Manual metadata generation for v0.124.0 compatibility:
- Dependency adjustments to match aws-cwa-dev (v0.124.0/v1.30.0)
- Generated metadata files for new log events
- Config schema updates
Add passfile authentication (ADO connection string format):
- Password resolution from passfile matching server, port, and user ID
- Support for quoted values, semicolons in passwords, escaped quotes
- Key synonyms (pwd/password, uid/user id, data source/server)
- Permission validation (0600/0400 on Linux)
- Comprehensive test coverage for matching, synonyms, special chars
- Integration with config validation and factory connection building

Add DBI gap metrics for parity with MySQL/PostgreSQL:
- Gap 1: I/O queue metrics (sqlserver.database.io.stall_queued.read/write)
  - Resource governor read/write stall time from sys.dm_io_virtual_file_stats
- Gap 2: Session state metrics (sqlserver.session.count)
  - Active sessions by status and command type
  - Tracks running, sleeping, dormant states
  - Collects from sys.dm_exec_requests and sys.dm_exec_sessions

Query improvements for Database Insights:
- Add database_name to top query events (db.namespace attribute)
- Fix session_status constant usage in scraper
- Add wait_category_test.go for wait type categorization coverage
- Update test expectations and testdata for all query changes
Add sqlserver.application.name attribute to query samples to enable
'Top Applications' dimension, achieving full parity with RDS Performance
Insights.

Changes:
- Collect program_name from sys.dm_exec_sessions
- Add sqlserver.application.name attribute to metadata
- Extract and emit program_name in query sample events
- Update generated metadata code and tests
- Update test data files

This enables tracking which client applications generate the most
database load, improving troubleshooting and cost attribution.

Matches RDS Performance Insights dimensions:
- Top SQL, Top waits, Top hosts, Top users, Top applications, Top databases
@Klarsen04
Klarsen04 deleted the branch dbi-sqlserver August 3, 2026 16:02
@Klarsen04 Klarsen04 closed this Aug 3, 2026
@Klarsen04
Klarsen04 deleted the larkirs/dbi-sqlserver branch August 5, 2026 16:00
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.

1 participant