-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[receiver/sqlserver] Add new metric: lock wait count #39930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: receiver/sqlserver | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Add new metric `sqlserver.lock.wait.count` | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [39892] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: This metric is disabled by default. | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,8 @@ END | |
DECLARE | ||
@SqlStatement AS nvarchar(max) | ||
,@MajorMinorVersion AS int = CAST(PARSENAME(CAST(SERVERPROPERTY('ProductVersion') AS nvarchar),4) AS int)*100 + CAST(PARSENAME(CAST(SERVERPROPERTY('ProductVersion') AS nvarchar),3) AS int) | ||
,@Columns AS nvarchar(MAX) = '' | ||
,@PivotColumns AS nvarchar(MAX) = '' | ||
|
||
DECLARE @PCounters TABLE | ||
( | ||
|
@@ -210,6 +212,36 @@ SELECT DISTINCT | |
|
||
INSERT INTO @PCounters SELECT * FROM PerfCounters; | ||
|
||
SET @SqlStatement = N' | ||
SELECT | ||
''SQLServer:Workload Group Stats'' AS [object] | ||
,[counter] | ||
,[instance] | ||
,CAST(vs.[value] AS BIGINT) AS [value] | ||
,1 | ||
FROM | ||
( | ||
SELECT | ||
rgwg.name AS instance | ||
,rgwg.total_request_count AS [Request Count] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Including extra selects here in case we want to add these metrics in the future. |
||
,rgwg.total_queued_request_count AS [Queued Request Count] | ||
,rgwg.total_cpu_limit_violation_count AS [CPU Limit Violation Count] | ||
,rgwg.total_cpu_usage_ms AS [CPU Usage (time)] | ||
,rgwg.total_lock_wait_count AS [Lock Wait Count] | ||
,rgwg.total_lock_wait_time_ms AS [Lock Wait Time] | ||
,rgwg.total_reduced_memgrant_count AS [Reduced Memory Grant Count] | ||
' + @Columns + N' | ||
FROM sys.[dm_resource_governor_workload_groups] AS rgwg | ||
INNER JOIN sys.[dm_resource_governor_resource_pools] AS rgrp | ||
ON rgwg.[pool_id] = rgrp.[pool_id] | ||
) AS rg | ||
UNPIVOT ( | ||
value FOR counter IN ( [Request Count], [Queued Request Count], [CPU Limit Violation Count], [CPU Usage (time)], [Lock Wait Count], [Lock Wait Time], [Reduced Memory Grant Count] ' + @PivotColumns + N') | ||
) AS vs' | ||
|
||
INSERT INTO @PCounters | ||
EXEC( @SqlStatement ) | ||
|
||
SELECT | ||
'sqlserver_performance' AS [measurement] | ||
,REPLACE(@@SERVERNAME,'\',':') AS [sql_instance] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,6 +218,7 @@ func (s *sqlServerScraperHelper) recordDatabasePerfCounterMetrics(ctx context.Co | |
const fullScansPerSec = "Full Scans/sec" | ||
const indexSearchesPerSec = "Index Searches/sec" | ||
const lockTimeoutsPerSec = "Lock Timeouts/sec" | ||
const lockWaitCount = "Lock Wait Count" | ||
const lockWaits = "Lock Waits/sec" | ||
const loginsPerSec = "Logins/sec" | ||
const logoutPerSec = "Logouts/sec" | ||
|
@@ -352,6 +353,14 @@ func (s *sqlServerScraperHelper) recordDatabasePerfCounterMetrics(ctx context.Co | |
} else { | ||
s.mb.RecordSqlserverLockTimeoutRateDataPoint(now, val.(float64)) | ||
} | ||
case lockWaitCount: | ||
val, err := retrieveInt(row, valueKey) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if err != nil { | ||
err = fmt.Errorf("failed to parse valueKey for row %d: %w in %s", i, err, lockWaitCount) | ||
errs = append(errs, err) | ||
} else { | ||
s.mb.RecordSqlserverLockWaitCountDataPoint(now, val.(int64)) | ||
} | ||
case lockWaits: | ||
val, err := retrieveFloat(row, valueKey) | ||
if err != nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd appreciate feedback on what the unit should be here, if anyone has any thoughts.