Skip to content

Commit fc2eef0

Browse files
authored
[receiver/sqlserver] add new attribute to de-duplicate page.life_expectancy (#40359)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description When exporting data to elasticsearch, we got error say data are duplicated. And turns out the perf counter query could return two rows for page life expectancy, they could have identicial value but with different `object` name. Hence added one attribute to deduplicate the data. <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.-->
1 parent f9e0089 commit fc2eef0

File tree

10 files changed

+64
-6
lines changed

10 files changed

+64
-6
lines changed

.chloggen/fix-duplicate-data.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: sqlserverreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: add one attribute for performance_counter.object_name to deduplicate data
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [40359]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

receiver/sqlserverreceiver/documentation.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ Time a page will stay in the buffer pool.
9090
| ---- | ----------- | ---------- |
9191
| s | Gauge | Int |
9292
93+
#### Attributes
94+
95+
| Name | Description | Values |
96+
| ---- | ----------- | ------ |
97+
| performance_counter.object_name | Category to which this counter belongs | Any Str |
98+
9399
### sqlserver.page.operation.rate
94100
95101
Number of physical database page operations issued.

receiver/sqlserverreceiver/internal/metadata/generated_metrics.go

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/sqlserverreceiver/internal/metadata/generated_metrics_test.go

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/sqlserverreceiver/metadata.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ attributes:
4343
description: The page operation types.
4444
type: string
4545
enum: [read, write]
46+
performance_counter.object_name:
47+
description: Category to which this counter belongs
48+
type: string
4649
physical_filename:
4750
description: The physical filename of the file being monitored.
4851
type: string
@@ -333,6 +336,7 @@ metrics:
333336
unit: s
334337
gauge:
335338
value_type: int
339+
attributes: [performance_counter.object_name]
336340
sqlserver.page.split.rate:
337341
enabled: true
338342
description: Number of pages split as a result of overflowing index pages.

receiver/sqlserverreceiver/recorders.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ var perfCounterRecorders = []perfCounterRecorderConf{
7373
mb.RecordSqlserverPageLazyWriteRateDataPoint(ts, val)
7474
},
7575
"Page life expectancy": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
76-
mb.RecordSqlserverPageLifeExpectancyDataPoint(ts, int64(val))
76+
mb.RecordSqlserverPageLifeExpectancyDataPoint(ts, int64(val), "Buffer Manager")
7777
},
7878
"Page reads/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
7979
mb.RecordSqlserverPageOperationRateDataPoint(ts, val, metadata.AttributePageOperationsRead)

receiver/sqlserverreceiver/scraper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ func (s *sqlServerScraperHelper) recordDatabasePerfCounterMetrics(ctx context.Co
442442
err = fmt.Errorf("failed to parse valueKey for row %d: %w in %s", i, err, pageLifeExpectancy)
443443
errs = append(errs, err)
444444
} else {
445-
s.mb.RecordSqlserverPageLifeExpectancyDataPoint(now, val.(int64))
445+
s.mb.RecordSqlserverPageLifeExpectancyDataPoint(now, val.(int64), row["object"])
446446
}
447447
case pageLookupsPerSec:
448448
val, err := retrieveFloat(row, valueKey)

receiver/sqlserverreceiver/testdata/expectedPerfCounters.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ resourceMetrics:
168168
gauge:
169169
dataPoints:
170170
- asInt: "16771"
171+
attributes:
172+
- key: performance_counter.object_name
173+
value:
174+
stringValue: SQLServer:Buffer Manager
171175
startTimeUnixNano: "1000000"
172176
timeUnixNano: "2000000"
173177
name: sqlserver.page.life_expectancy
@@ -216,6 +220,10 @@ resourceMetrics:
216220
gauge:
217221
dataPoints:
218222
- asInt: "16771"
223+
attributes:
224+
- key: performance_counter.object_name
225+
value:
226+
stringValue: SQLServer:Buffer Node
219227
startTimeUnixNano: "1000000"
220228
timeUnixNano: "2000000"
221229
name: sqlserver.page.life_expectancy

receiver/sqlserverreceiver/testdata/golden_named_instance_scrape.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ resourceMetrics:
8080
gauge:
8181
dataPoints:
8282
- asInt: "3"
83+
attributes:
84+
- key: performance_counter.object_name
85+
value:
86+
stringValue: Buffer Manager
8387
startTimeUnixNano: "1679438452573063800"
8488
timeUnixNano: "1679438452575044500"
8589
name: sqlserver.page.life_expectancy

receiver/sqlserverreceiver/testdata/golden_scrape.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ resourceMetrics:
7474
gauge:
7575
dataPoints:
7676
- asInt: "3"
77+
attributes:
78+
- key: performance_counter.object_name
79+
value:
80+
stringValue: Buffer Manager
7781
startTimeUnixNano: "1679438452495397400"
7882
timeUnixNano: "1679438452496922500"
7983
name: sqlserver.page.life_expectancy

0 commit comments

Comments
 (0)