Skip to content

Commit f7fef01

Browse files
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
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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. receiver/filelog)
7+
component: receiver/oracledb
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add transaction, lock, and recovery metrics
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: [49064]
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+
The new metrics are disabled by default and add no new database queries.
20+
21+
# If your change doesn't affect end users or the exported elements of any package,
22+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
23+
# Optional: The change log or logs in which this entry should be included.
24+
# e.g. '[user]' or '[user, api]'
25+
# Include 'user' if the change is relevant to end users.
26+
# Include 'api' if there is a change to a library API.
27+
# Default: '[user]'
28+
change_logs: [user]

receiver/oracledbreceiver/documentation.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ Total wall-clock time spent in database calls.
409409
410410
| Name | Description | Values | Requirement Level | Semantic Convention |
411411
| ---- | ----------- | ------ | ----------------- | ------------------- |
412-
| oracledb.session.type | Class of session the database time is attributed to. | Str: ``foreground`` | Recommended | - |
412+
| oracledb.session.type | Class of session the activity is attributed to. | Str: ``background``, ``foreground`` | Recommended | - |
413413
414414
### oracledb.db_block_gets
415415
@@ -463,6 +463,20 @@ Fraction of executions that did not require a parse, as computed by Oracle V$SYS
463463
| ---- | ----------- | ------ | ----------------- | ------------------- |
464464
| oracledb.parse.type | Type of parse operation (e.g., soft). | Str: ``soft`` | Recommended | - |
465465
466+
### oracledb.gc.current_block.time
467+
468+
Cumulative time spent transferring current blocks between instances over RAC cache fusion.
469+
470+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
471+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
472+
| s | Sum | Double | Cumulative | true | Development |
473+
474+
#### Attributes
475+
476+
| Name | Description | Values | Requirement Level | Semantic Convention |
477+
| ---- | ----------- | ------ | ----------------- | ------------------- |
478+
| network.io.direction | Direction of the network transfer. | Str: ``receive``, ``transmit`` | Recommended | - |
479+
466480
### oracledb.host.cpu.usage.rate
467481
468482
Host CPU consumption rate across all cores, in CPU-seconds used per second.
@@ -509,6 +523,20 @@ Total count of LOB (large object) I/O operations.
509523
| ---- | ----------- | ------ | ----------------- | ------------------- |
510524
| disk.io.direction | Direction of the storage I/O operation. | Str: ``read``, ``write`` | Recommended | - |
511525
526+
### oracledb.lock.time
527+
528+
Cumulative time spent on transaction lock activity.
529+
530+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
531+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
532+
| s | Sum | Double | Cumulative | true | Development |
533+
534+
#### Attributes
535+
536+
| Name | Description | Values | Requirement Level | Semantic Convention |
537+
| ---- | ----------- | ------ | ----------------- | ------------------- |
538+
| oracledb.session.type | Class of session the activity is attributed to. | Str: ``background``, ``foreground`` | Recommended | - |
539+
512540
### oracledb.logons
513541
514542
Number of logon operations
@@ -697,6 +725,14 @@ Number of SELECT statements executed in parallel
697725
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
698726
| {queries} | Sum | Int | Cumulative | true | Development |
699727
728+
### oracledb.recovery.blocks
729+
730+
Number of blocks read during instance or media recovery.
731+
732+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
733+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
734+
| {block} | Sum | Int | Cumulative | true | Development |
735+
700736
### oracledb.recycle_bin.limit
701737
702738
Total size of the recycle bin.
@@ -858,6 +894,20 @@ Fraction of the shared pool that is currently free, as computed by Oracle V$SYSM
858894
| ---- | ----------- | ---------- | --------- |
859895
| % | Gauge | Double | Development |
860896
897+
### oracledb.smon.posts
898+
899+
Number of times SMON was posted to perform recovery.
900+
901+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
902+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
903+
| {post} | Sum | Int | Cumulative | true | Development |
904+
905+
#### Attributes
906+
907+
| Name | Description | Values | Requirement Level | Semantic Convention |
908+
| ---- | ----------- | ------ | ----------------- | ------------------- |
909+
| oracledb.smon.type | Type of recovery SMON was posted to perform. | Str: ``instance``, ``transaction`` | Recommended | - |
910+
861911
### oracledb.sort.operations
862912
863913
Total count of sort operations.
@@ -914,7 +964,7 @@ Bytes transferred via SQL*Net between Oracle and clients/dblinks. Sourced from v
914964
915965
| Name | Description | Values | Requirement Level | Semantic Convention |
916966
| ---- | ----------- | ------ | ----------------- | ------------------- |
917-
| network.io.direction | Direction of the SQL*Net network transfer. | Str: ``receive``, ``transmit`` | Recommended | - |
967+
| network.io.direction | Direction of the network transfer. | Str: ``receive``, ``transmit`` | Recommended | - |
918968
| destination.type | Type of the SQL*Net destination endpoint (client application or remote database link). | Str: ``client``, ``dblink`` | Recommended | - |
919969
920970
### oracledb.storage.usage
@@ -965,6 +1015,14 @@ Average response time per transaction.
9651015
| ---- | ----------- | ---------- | --------- |
9661016
| s | Gauge | Double | Development |
9671017
1018+
### oracledb.transaction.rollbacks
1019+
1020+
Total number of transactions rolled back.
1021+
1022+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
1023+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
1024+
| {rollback} | Sum | Int | Cumulative | true | Development |
1025+
9681026
## Default Events
9691027
9701028
The following events are emitted by default. Each of them can be disabled by applying the following configuration:

receiver/oracledbreceiver/internal/metadata/config.schema.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ $defs:
262262
enabled:
263263
type: boolean
264264
default: true
265+
oracledb.gc.current_block.time:
266+
description: "OracledbGcCurrentBlockTimeMetricConfig provides config for the oracledb.gc.current_block.time metric."
267+
type: object
268+
properties:
269+
enabled:
270+
type: boolean
271+
default: false
265272
oracledb.hard_parses:
266273
description: "OracledbHardParsesMetricConfig provides config for the oracledb.hard_parses metric."
267274
type: object
@@ -306,6 +313,13 @@ $defs:
306313
- "disk.io.direction"
307314
default:
308315
- "disk.io.direction"
316+
oracledb.lock.time:
317+
description: "OracledbLockTimeMetricConfig provides config for the oracledb.lock.time metric."
318+
type: object
319+
properties:
320+
enabled:
321+
type: boolean
322+
default: false
309323
oracledb.logical_reads:
310324
description: "OracledbLogicalReadsMetricConfig provides config for the oracledb.logical_reads metric."
311325
type: object
@@ -517,6 +531,13 @@ $defs:
517531
enabled:
518532
type: boolean
519533
default: false
534+
oracledb.recovery.blocks:
535+
description: "OracledbRecoveryBlocksMetricConfig provides config for the oracledb.recovery.blocks metric."
536+
type: object
537+
properties:
538+
enabled:
539+
type: boolean
540+
default: false
520541
oracledb.recycle_bin.limit:
521542
description: "OracledbRecycleBinLimitMetricConfig provides config for the oracledb.recycle_bin.limit metric."
522543
type: object
@@ -637,6 +658,13 @@ $defs:
637658
default:
638659
- "session_type"
639660
- "session_status"
661+
oracledb.smon.posts:
662+
description: "OracledbSmonPostsMetricConfig provides config for the oracledb.smon.posts metric."
663+
type: object
664+
properties:
665+
enabled:
666+
type: boolean
667+
default: false
640668
oracledb.sort.operations:
641669
description: "OracledbSortOperationsMetricConfig provides config for the oracledb.sort.operations metric."
642670
type: object
@@ -759,6 +787,13 @@ $defs:
759787
enabled:
760788
type: boolean
761789
default: false
790+
oracledb.transaction.rollbacks:
791+
description: "OracledbTransactionRollbacksMetricConfig provides config for the oracledb.transaction.rollbacks metric."
792+
type: object
793+
properties:
794+
enabled:
795+
type: boolean
796+
default: false
762797
oracledb.transactions.limit:
763798
description: "OracledbTransactionsLimitMetricConfig provides config for the oracledb.transactions.limit metric."
764799
type: object

0 commit comments

Comments
 (0)