Commit f7fef01
authored
[receiver/oracledb] Add transaction, lock, and recovery metrics (#49067)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
The Oracle DB receiver scrapes `v$sysstat` with `SELECT * FROM
v$sysstat`, which returns all system-statistics rows. However, the
scraper only processes a subset of those rows in its `switch` block and
silently discards the rest — including the transaction-rollback,
lock-contention, and recovery statistics. This change surfaces **7
discarded `v$sysstat` statistics** as **5 new opt-in metrics**, giving
operators visibility into commit/rollback churn, enqueue/lock pressure,
instance- and transaction-recovery activity, and RAC cache-fusion
latency — core Oracle durability and availability diagnostics.
This change adds 5 new opt-in metrics (disabled by default, stability:
development):
* `oracledb.transaction.rollbacks` — Number of transactions rolled back.
No attributes. Covers `v$sysstat`: `transaction rollbacks`. Distinct
from the existing `oracledb.user_rollbacks` (which counts only
user-issued `ROLLBACK` statements); this counts all transaction
rollbacks, including internal/recursive ones.
* `oracledb.lock.time` — Cumulative time, in seconds, spent on
transaction lock activity. Attribute: `oracledb.session.type`
(background|foreground). Covers `v$sysstat`: `transaction lock
background get time`, `transaction lock foreground wait time` (the raw
centisecond value is divided by 100 in the scraper).
* `oracledb.recovery.blocks` — Number of blocks read during instance or
media recovery. No attributes. Covers `v$sysstat`: `recovery blocks
read`.
* `oracledb.smon.posts` — Number of times SMON was posted to perform
recovery. Attribute: `oracledb.smon.type` (instance|transaction). Covers
`v$sysstat`: `SMON posted for instance recovery` (`instance`), `SMON
posted for txn recovery for other instances` (`transaction`, RAC
cross-instance).
* `oracledb.gc.current_block.time` — Cumulative time, in seconds, spent
transferring current blocks between instances over Oracle RAC cache
fusion. Attribute: `network.io.direction` (receive). Covers `v$sysstat`:
`gc current block receive time` (cs ÷ 100). Here "gc" denotes Oracle's
global cache (Cache Fusion), not JVM garbage collection; the value is 0
on a single-instance (non-RAC) database.
`oracledb.lock.time` and `oracledb.gc.current_block.time` are emitted as
a `Sum` with `aggregation_temporality: cumulative`, `monotonic: true`,
value type `double`, unit `s`. The remaining three are emitted as `Sum`
with `aggregation_temporality: cumulative`, `monotonic: true`, value
type `int`. Per-metric units: `s` (`oracledb.lock.time`,
`oracledb.gc.current_block.time`); `{rollback}`
(`oracledb.transaction.rollbacks`); `{block}`
(`oracledb.recovery.blocks`); `{post}` (`oracledb.smon.posts`).
The two time metrics report seconds (`s`) rather than the raw `cs`
(centisecond) units that Oracle exposes via `v$sysstat`; the scraper
divides the raw value by 100 before recording, matching the conversion
already in place for the existing `oracledb.cpu_time` metric.
> **Note (change since the initial submission):** an earlier revision
included `oracledb.lock.wait.time` mapped to a `v$sysstat` statistic
named `Total Lock Time`. That statistic does not exist in `v$sysstat` on
any supported Oracle version (verified against `v$statname` on Oracle
19c — it returns no such row), so the metric would never emit. It has
been removed. Background/foreground lock timing is already captured by
`oracledb.lock.time`.
These metrics can be enabled in the collector configuration:
```yaml
receivers:
oracledb:
datasource: "oracle://user:password@host:1521/service"
metrics:
oracledb.transaction.rollbacks:
enabled: true
oracledb.lock.time:
enabled: true
oracledb.recovery.blocks:
enabled: true
oracledb.smon.posts:
enabled: true
oracledb.gc.current_block.time:
enabled: true
```
<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes #49064
<!--Describe what testing was performed and which tests were added.-->
#### Testing
Unit tests added in `scraper_test.go`:
- `TestScraper_ScrapeTransactionLockRecoveryMetrics` exercises all 5 new
metrics end-to-end through the scraper using the existing fake DB
client, asserting one expected value per data point (2
`oracledb.lock.time` data points — one per `oracledb.session.type` —
plus 2 `oracledb.smon.posts` data points — one per `oracledb.smon.type`
— plus 3 standalone data points = 7 data points per scrape across the 5
metrics).
- The shared `queryResponses[statsSQL]` fixture is extended with 7 new
fake `v$sysstat` rows (one per covered NAME), so `TestScraper_Scrape`,
`TestScraper_ScrapeOperationalMetrics`, and
`TestScraper_ScrapeIOPerformanceMetrics` continue to pass unchanged.
- The test explicitly verifies the centiseconds → seconds conversion:
raw 350/1200 cs from `transaction lock background get time` /
`transaction lock foreground wait time` produce 3.5/12.0 s on the
background/foreground data points; 640 cs from `gc current block receive
time` produces 6.4 s.
- Auto-generated tests in `internal/metadata/generated_metrics_test.go`
and `generated_config_test.go` are regenerated by `make generate` and
cover the new metric configs / metric builders.
<!--Describe the documentation added.-->
#### Documentation
Auto-generated `documentation.md` updated with descriptions and metadata
for the 5 new metrics, the new `oracledb.smon.type` attribute, the
reused `network.io.direction` attribute (on
`oracledb.gc.current_block.time`), and the extended
`oracledb.session.type` attribute (now `background`/`foreground`).
`internal/metadata/generated_*.go` and
`internal/metadata/testdata/config.yaml` regenerated via `make
generate`. `internal/metadata/config.schema.yaml` was updated for the 5
new metric stanzas, as that file is not produced by `make generate`.
<!--Authorship attestation. See AGENTS.md for details. AI agents must
not check this box on behalf
of the user; the human author must check it themselves before the PR is
ready for review.-->
#### Authorship
- [X] I, a human, wrote this pull request description myself.
<!--Please delete paragraphs that you did not use before submitting.-->1 parent 5445b8e commit f7fef01
11 files changed
Lines changed: 1338 additions & 34 deletions
File tree
- .chloggen
- receiver/oracledbreceiver
- internal/metadata
- testdata
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
412 | | - | |
| 412 | + | |
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
| |||
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
466 | 480 | | |
467 | 481 | | |
468 | 482 | | |
| |||
509 | 523 | | |
510 | 524 | | |
511 | 525 | | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
512 | 540 | | |
513 | 541 | | |
514 | 542 | | |
| |||
697 | 725 | | |
698 | 726 | | |
699 | 727 | | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
700 | 736 | | |
701 | 737 | | |
702 | 738 | | |
| |||
858 | 894 | | |
859 | 895 | | |
860 | 896 | | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
861 | 911 | | |
862 | 912 | | |
863 | 913 | | |
| |||
914 | 964 | | |
915 | 965 | | |
916 | 966 | | |
917 | | - | |
| 967 | + | |
918 | 968 | | |
919 | 969 | | |
920 | 970 | | |
| |||
965 | 1015 | | |
966 | 1016 | | |
967 | 1017 | | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
968 | 1026 | | |
969 | 1027 | | |
970 | 1028 | | |
| |||
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
265 | 272 | | |
266 | 273 | | |
267 | 274 | | |
| |||
306 | 313 | | |
307 | 314 | | |
308 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
309 | 323 | | |
310 | 324 | | |
311 | 325 | | |
| |||
517 | 531 | | |
518 | 532 | | |
519 | 533 | | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
520 | 541 | | |
521 | 542 | | |
522 | 543 | | |
| |||
637 | 658 | | |
638 | 659 | | |
639 | 660 | | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
640 | 668 | | |
641 | 669 | | |
642 | 670 | | |
| |||
759 | 787 | | |
760 | 788 | | |
761 | 789 | | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
762 | 797 | | |
763 | 798 | | |
764 | 799 | | |
| |||
0 commit comments