Skip to content

[receiver/sqlserver] Emit another metric for direct connection #39940

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

Merged
merged 4 commits into from
May 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .chloggen/sqlserver_page_life_expectancy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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: Enable `sqlserver.page.life_expectancy` metric for all configurations

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [39940]

# (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 was originally only available when running on Windows, but is
now available for all configuration options, including direct connection.
Since this metric is enabled by default, users who have direct connection
configured will now have this metric emitted 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: []
2 changes: 0 additions & 2 deletions receiver/sqlserverreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ This metric is only available when running on Windows.
Time a page will stay in the buffer pool.
This metric is only available when running on Windows.
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| s | Gauge | Int |
Expand Down
1 change: 0 additions & 1 deletion receiver/sqlserverreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ metrics:
unit: s
gauge:
value_type: int
extended_documentation: This metric is only available when running on Windows.
sqlserver.page.split.rate:
enabled: true
description: Number of pages split as a result of overflowing index pages.
Expand Down
9 changes: 9 additions & 0 deletions receiver/sqlserverreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ func (s *sqlServerScraperHelper) recordDatabasePerfCounterMetrics(ctx context.Co
const numberOfDeadlocksPerSec = "Number of Deadlocks/sec"
const mirrorWritesTransactionPerSec = "Mirrored Write Transactions/sec"
const memoryGrantsPending = "Memory Grants Pending"
const pageLifeExpectancy = "Page life expectancy"
const pageLookupsPerSec = "Page lookups/sec"
const processesBlocked = "Processes blocked"
const sqlCompilationRate = "SQL Compilations/sec"
Expand Down Expand Up @@ -435,6 +436,14 @@ func (s *sqlServerScraperHelper) recordDatabasePerfCounterMetrics(ctx context.Co
} else {
s.mb.RecordSqlserverDeadlockRateDataPoint(now, val.(float64))
}
case pageLifeExpectancy:
val, err := retrieveInt(row, valueKey)
if err != nil {
err = fmt.Errorf("failed to parse valueKey for row %d: %w in %s", i, err, pageLifeExpectancy)
errs = append(errs, err)
} else {
s.mb.RecordSqlserverPageLifeExpectancyDataPoint(now, val.(int64))
}
case pageLookupsPerSec:
val, err := retrieveFloat(row, valueKey)
if err != nil {
Expand Down
48 changes: 48 additions & 0 deletions receiver/sqlserverreceiver/testdata/expectedPerfCounters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,30 @@ resourceMetrics:
scope:
name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlserverreceiver
version: latest
- resource:
attributes:
- key: server.address
value:
stringValue: 0.0.0.0
- key: server.port
value:
intValue: "1433"
- key: sqlserver.instance.name
value:
stringValue: d26d40521426
scopeMetrics:
- metrics:
- description: Time a page will stay in the buffer pool.
gauge:
dataPoints:
- asInt: "16771"
startTimeUnixNano: "1000000"
timeUnixNano: "2000000"
name: sqlserver.page.life_expectancy
unit: s
scope:
name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlserverreceiver
version: latest
- resource:
attributes:
- key: server.address
Expand All @@ -175,6 +199,30 @@ resourceMetrics:
scope:
name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlserverreceiver
version: latest
- resource:
attributes:
- key: server.address
value:
stringValue: 0.0.0.0
- key: server.port
value:
intValue: "1433"
- key: sqlserver.instance.name
value:
stringValue: d26d40521426
scopeMetrics:
- metrics:
- description: Time a page will stay in the buffer pool.
gauge:
dataPoints:
- asInt: "16771"
startTimeUnixNano: "1000000"
timeUnixNano: "2000000"
name: sqlserver.page.life_expectancy
unit: s
scope:
name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlserverreceiver
version: latest
- resource:
attributes:
- key: server.address
Expand Down
Loading