Skip to content

[receiver/sqlserver] add new attribute to de-duplicate page.life_expectancy #40359

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 12 commits into from
Jun 2, 2025
27 changes: 27 additions & 0 deletions .chloggen/fix-duplicate-data.yaml
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: sqlserverreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: add one attribute for performance_counter.object_name to deduplicate data

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

# (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:

# 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: [user]
6 changes: 6 additions & 0 deletions receiver/sqlserverreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ Time a page will stay in the buffer pool.
| ---- | ----------- | ---------- |
| s | Gauge | Int |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| performance_counter.object_name | Category to which this counter belongs | Any Str |

### sqlserver.page.operation.rate

Number of physical database page operations issued.
Expand Down

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.

4 changes: 4 additions & 0 deletions receiver/sqlserverreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ attributes:
description: The page operation types.
type: string
enum: [read, write]
performance_counter.object_name:
description: Category to which this counter belongs
type: string
physical_filename:
description: The physical filename of the file being monitored.
type: string
Expand Down Expand Up @@ -333,6 +336,7 @@ metrics:
unit: s
gauge:
value_type: int
attributes: [performance_counter.object_name]
sqlserver.page.split.rate:
enabled: true
description: Number of pages split as a result of overflowing index pages.
Expand Down
2 changes: 1 addition & 1 deletion receiver/sqlserverreceiver/recorders.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var perfCounterRecorders = []perfCounterRecorderConf{
mb.RecordSqlserverPageLazyWriteRateDataPoint(ts, val)
},
"Page life expectancy": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverPageLifeExpectancyDataPoint(ts, int64(val))
mb.RecordSqlserverPageLifeExpectancyDataPoint(ts, int64(val), "Buffer Manager")
},
"Page reads/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverPageOperationRateDataPoint(ts, val, metadata.AttributePageOperationsRead)
Expand Down
2 changes: 1 addition & 1 deletion receiver/sqlserverreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func (s *sqlServerScraperHelper) recordDatabasePerfCounterMetrics(ctx context.Co
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))
s.mb.RecordSqlserverPageLifeExpectancyDataPoint(now, val.(int64), row["object"])
}
case pageLookupsPerSec:
val, err := retrieveFloat(row, valueKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ resourceMetrics:
gauge:
dataPoints:
- asInt: "16771"
attributes:
- key: performance_counter.object_name
value:
stringValue: SQLServer:Buffer Manager
startTimeUnixNano: "1000000"
timeUnixNano: "2000000"
name: sqlserver.page.life_expectancy
Expand Down Expand Up @@ -216,6 +220,10 @@ resourceMetrics:
gauge:
dataPoints:
- asInt: "16771"
attributes:
- key: performance_counter.object_name
value:
stringValue: SQLServer:Buffer Node
startTimeUnixNano: "1000000"
timeUnixNano: "2000000"
name: sqlserver.page.life_expectancy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ resourceMetrics:
gauge:
dataPoints:
- asInt: "3"
attributes:
- key: performance_counter.object_name
value:
stringValue: Buffer Manager
startTimeUnixNano: "1679438452573063800"
timeUnixNano: "1679438452575044500"
name: sqlserver.page.life_expectancy
Expand Down
4 changes: 4 additions & 0 deletions receiver/sqlserverreceiver/testdata/golden_scrape.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ resourceMetrics:
gauge:
dataPoints:
- asInt: "3"
attributes:
- key: performance_counter.object_name
value:
stringValue: Buffer Manager
startTimeUnixNano: "1679438452495397400"
timeUnixNano: "1679438452496922500"
name: sqlserver.page.life_expectancy
Expand Down