diff --git a/.chloggen/add-new-oracledb-metrics.yaml b/.chloggen/add-new-oracledb-metrics.yaml new file mode 100644 index 0000000000000..58c53f3137b1c --- /dev/null +++ b/.chloggen/add-new-oracledb-metrics.yaml @@ -0,0 +1,30 @@ +# 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: oracledbreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add support for additional read/write metrics + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [37814] + +# (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: | + The following metrics are now available, all disabled by default: + 'physical reads direct', 'physical writes', 'physical writes direct', + 'physical read io requests' and 'physical write io requests' metrics' + +# 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] diff --git a/receiver/oracledbreceiver/documentation.md b/receiver/oracledbreceiver/documentation.md index cb31fc8dbb9f6..f8e135641f75f 100644 --- a/receiver/oracledbreceiver/documentation.md +++ b/receiver/oracledbreceiver/documentation.md @@ -257,6 +257,46 @@ Number of times a current block was requested from the buffer cache. | ---- | ----------- | ---------- | ----------------------- | --------- | | {gets} | Sum | Int | Cumulative | true | +### oracledb.physical_read_io_requests + +Number of read requests for application activity + +| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | +| ---- | ----------- | ---------- | ----------------------- | --------- | +| {requests} | Sum | Int | Cumulative | true | + +### oracledb.physical_reads_direct + +Number of reads directly from disk, bypassing the buffer cache + +| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | +| ---- | ----------- | ---------- | ----------------------- | --------- | +| {reads} | Sum | Int | Cumulative | true | + +### oracledb.physical_write_io_requests + +Number of write requests for application activity + +| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | +| ---- | ----------- | ---------- | ----------------------- | --------- | +| {requests} | Sum | Int | Cumulative | true | + +### oracledb.physical_writes + +Number of physical writes + +| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | +| ---- | ----------- | ---------- | ----------------------- | --------- | +| {writes} | Sum | Int | Cumulative | true | + +### oracledb.physical_writes_direct + +Number of writes directly to disk, bypassing the buffer cache + +| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | +| ---- | ----------- | ---------- | ----------------------- | --------- | +| {writes} | Sum | Int | Cumulative | true | + ## Resource Attributes | Name | Description | Values | Enabled | diff --git a/receiver/oracledbreceiver/internal/metadata/generated_config.go b/receiver/oracledbreceiver/internal/metadata/generated_config.go index 4324eff94431c..82e6905584281 100644 --- a/receiver/oracledbreceiver/internal/metadata/generated_config.go +++ b/receiver/oracledbreceiver/internal/metadata/generated_config.go @@ -28,33 +28,38 @@ func (ms *MetricConfig) Unmarshal(parser *confmap.Conf) error { // MetricsConfig provides config for oracledb metrics. type MetricsConfig struct { - OracledbConsistentGets MetricConfig `mapstructure:"oracledb.consistent_gets"` - OracledbCPUTime MetricConfig `mapstructure:"oracledb.cpu_time"` - OracledbDbBlockGets MetricConfig `mapstructure:"oracledb.db_block_gets"` - OracledbDmlLocksLimit MetricConfig `mapstructure:"oracledb.dml_locks.limit"` - OracledbDmlLocksUsage MetricConfig `mapstructure:"oracledb.dml_locks.usage"` - OracledbEnqueueDeadlocks MetricConfig `mapstructure:"oracledb.enqueue_deadlocks"` - OracledbEnqueueLocksLimit MetricConfig `mapstructure:"oracledb.enqueue_locks.limit"` - OracledbEnqueueLocksUsage MetricConfig `mapstructure:"oracledb.enqueue_locks.usage"` - OracledbEnqueueResourcesLimit MetricConfig `mapstructure:"oracledb.enqueue_resources.limit"` - OracledbEnqueueResourcesUsage MetricConfig `mapstructure:"oracledb.enqueue_resources.usage"` - OracledbExchangeDeadlocks MetricConfig `mapstructure:"oracledb.exchange_deadlocks"` - OracledbExecutions MetricConfig `mapstructure:"oracledb.executions"` - OracledbHardParses MetricConfig `mapstructure:"oracledb.hard_parses"` - OracledbLogicalReads MetricConfig `mapstructure:"oracledb.logical_reads"` - OracledbParseCalls MetricConfig `mapstructure:"oracledb.parse_calls"` - OracledbPgaMemory MetricConfig `mapstructure:"oracledb.pga_memory"` - OracledbPhysicalReads MetricConfig `mapstructure:"oracledb.physical_reads"` - OracledbProcessesLimit MetricConfig `mapstructure:"oracledb.processes.limit"` - OracledbProcessesUsage MetricConfig `mapstructure:"oracledb.processes.usage"` - OracledbSessionsLimit MetricConfig `mapstructure:"oracledb.sessions.limit"` - OracledbSessionsUsage MetricConfig `mapstructure:"oracledb.sessions.usage"` - OracledbTablespaceSizeLimit MetricConfig `mapstructure:"oracledb.tablespace_size.limit"` - OracledbTablespaceSizeUsage MetricConfig `mapstructure:"oracledb.tablespace_size.usage"` - OracledbTransactionsLimit MetricConfig `mapstructure:"oracledb.transactions.limit"` - OracledbTransactionsUsage MetricConfig `mapstructure:"oracledb.transactions.usage"` - OracledbUserCommits MetricConfig `mapstructure:"oracledb.user_commits"` - OracledbUserRollbacks MetricConfig `mapstructure:"oracledb.user_rollbacks"` + OracledbConsistentGets MetricConfig `mapstructure:"oracledb.consistent_gets"` + OracledbCPUTime MetricConfig `mapstructure:"oracledb.cpu_time"` + OracledbDbBlockGets MetricConfig `mapstructure:"oracledb.db_block_gets"` + OracledbDmlLocksLimit MetricConfig `mapstructure:"oracledb.dml_locks.limit"` + OracledbDmlLocksUsage MetricConfig `mapstructure:"oracledb.dml_locks.usage"` + OracledbEnqueueDeadlocks MetricConfig `mapstructure:"oracledb.enqueue_deadlocks"` + OracledbEnqueueLocksLimit MetricConfig `mapstructure:"oracledb.enqueue_locks.limit"` + OracledbEnqueueLocksUsage MetricConfig `mapstructure:"oracledb.enqueue_locks.usage"` + OracledbEnqueueResourcesLimit MetricConfig `mapstructure:"oracledb.enqueue_resources.limit"` + OracledbEnqueueResourcesUsage MetricConfig `mapstructure:"oracledb.enqueue_resources.usage"` + OracledbExchangeDeadlocks MetricConfig `mapstructure:"oracledb.exchange_deadlocks"` + OracledbExecutions MetricConfig `mapstructure:"oracledb.executions"` + OracledbHardParses MetricConfig `mapstructure:"oracledb.hard_parses"` + OracledbLogicalReads MetricConfig `mapstructure:"oracledb.logical_reads"` + OracledbParseCalls MetricConfig `mapstructure:"oracledb.parse_calls"` + OracledbPgaMemory MetricConfig `mapstructure:"oracledb.pga_memory"` + OracledbPhysicalReadIoRequests MetricConfig `mapstructure:"oracledb.physical_read_io_requests"` + OracledbPhysicalReads MetricConfig `mapstructure:"oracledb.physical_reads"` + OracledbPhysicalReadsDirect MetricConfig `mapstructure:"oracledb.physical_reads_direct"` + OracledbPhysicalWriteIoRequests MetricConfig `mapstructure:"oracledb.physical_write_io_requests"` + OracledbPhysicalWrites MetricConfig `mapstructure:"oracledb.physical_writes"` + OracledbPhysicalWritesDirect MetricConfig `mapstructure:"oracledb.physical_writes_direct"` + OracledbProcessesLimit MetricConfig `mapstructure:"oracledb.processes.limit"` + OracledbProcessesUsage MetricConfig `mapstructure:"oracledb.processes.usage"` + OracledbSessionsLimit MetricConfig `mapstructure:"oracledb.sessions.limit"` + OracledbSessionsUsage MetricConfig `mapstructure:"oracledb.sessions.usage"` + OracledbTablespaceSizeLimit MetricConfig `mapstructure:"oracledb.tablespace_size.limit"` + OracledbTablespaceSizeUsage MetricConfig `mapstructure:"oracledb.tablespace_size.usage"` + OracledbTransactionsLimit MetricConfig `mapstructure:"oracledb.transactions.limit"` + OracledbTransactionsUsage MetricConfig `mapstructure:"oracledb.transactions.usage"` + OracledbUserCommits MetricConfig `mapstructure:"oracledb.user_commits"` + OracledbUserRollbacks MetricConfig `mapstructure:"oracledb.user_rollbacks"` } func DefaultMetricsConfig() MetricsConfig { @@ -107,9 +112,24 @@ func DefaultMetricsConfig() MetricsConfig { OracledbPgaMemory: MetricConfig{ Enabled: true, }, + OracledbPhysicalReadIoRequests: MetricConfig{ + Enabled: false, + }, OracledbPhysicalReads: MetricConfig{ Enabled: true, }, + OracledbPhysicalReadsDirect: MetricConfig{ + Enabled: false, + }, + OracledbPhysicalWriteIoRequests: MetricConfig{ + Enabled: false, + }, + OracledbPhysicalWrites: MetricConfig{ + Enabled: false, + }, + OracledbPhysicalWritesDirect: MetricConfig{ + Enabled: false, + }, OracledbProcessesLimit: MetricConfig{ Enabled: true, }, diff --git a/receiver/oracledbreceiver/internal/metadata/generated_config_test.go b/receiver/oracledbreceiver/internal/metadata/generated_config_test.go index 867a60249ca43..7785ac5c601f8 100644 --- a/receiver/oracledbreceiver/internal/metadata/generated_config_test.go +++ b/receiver/oracledbreceiver/internal/metadata/generated_config_test.go @@ -25,33 +25,38 @@ func TestMetricsBuilderConfig(t *testing.T) { name: "all_set", want: MetricsBuilderConfig{ Metrics: MetricsConfig{ - OracledbConsistentGets: MetricConfig{Enabled: true}, - OracledbCPUTime: MetricConfig{Enabled: true}, - OracledbDbBlockGets: MetricConfig{Enabled: true}, - OracledbDmlLocksLimit: MetricConfig{Enabled: true}, - OracledbDmlLocksUsage: MetricConfig{Enabled: true}, - OracledbEnqueueDeadlocks: MetricConfig{Enabled: true}, - OracledbEnqueueLocksLimit: MetricConfig{Enabled: true}, - OracledbEnqueueLocksUsage: MetricConfig{Enabled: true}, - OracledbEnqueueResourcesLimit: MetricConfig{Enabled: true}, - OracledbEnqueueResourcesUsage: MetricConfig{Enabled: true}, - OracledbExchangeDeadlocks: MetricConfig{Enabled: true}, - OracledbExecutions: MetricConfig{Enabled: true}, - OracledbHardParses: MetricConfig{Enabled: true}, - OracledbLogicalReads: MetricConfig{Enabled: true}, - OracledbParseCalls: MetricConfig{Enabled: true}, - OracledbPgaMemory: MetricConfig{Enabled: true}, - OracledbPhysicalReads: MetricConfig{Enabled: true}, - OracledbProcessesLimit: MetricConfig{Enabled: true}, - OracledbProcessesUsage: MetricConfig{Enabled: true}, - OracledbSessionsLimit: MetricConfig{Enabled: true}, - OracledbSessionsUsage: MetricConfig{Enabled: true}, - OracledbTablespaceSizeLimit: MetricConfig{Enabled: true}, - OracledbTablespaceSizeUsage: MetricConfig{Enabled: true}, - OracledbTransactionsLimit: MetricConfig{Enabled: true}, - OracledbTransactionsUsage: MetricConfig{Enabled: true}, - OracledbUserCommits: MetricConfig{Enabled: true}, - OracledbUserRollbacks: MetricConfig{Enabled: true}, + OracledbConsistentGets: MetricConfig{Enabled: true}, + OracledbCPUTime: MetricConfig{Enabled: true}, + OracledbDbBlockGets: MetricConfig{Enabled: true}, + OracledbDmlLocksLimit: MetricConfig{Enabled: true}, + OracledbDmlLocksUsage: MetricConfig{Enabled: true}, + OracledbEnqueueDeadlocks: MetricConfig{Enabled: true}, + OracledbEnqueueLocksLimit: MetricConfig{Enabled: true}, + OracledbEnqueueLocksUsage: MetricConfig{Enabled: true}, + OracledbEnqueueResourcesLimit: MetricConfig{Enabled: true}, + OracledbEnqueueResourcesUsage: MetricConfig{Enabled: true}, + OracledbExchangeDeadlocks: MetricConfig{Enabled: true}, + OracledbExecutions: MetricConfig{Enabled: true}, + OracledbHardParses: MetricConfig{Enabled: true}, + OracledbLogicalReads: MetricConfig{Enabled: true}, + OracledbParseCalls: MetricConfig{Enabled: true}, + OracledbPgaMemory: MetricConfig{Enabled: true}, + OracledbPhysicalReadIoRequests: MetricConfig{Enabled: true}, + OracledbPhysicalReads: MetricConfig{Enabled: true}, + OracledbPhysicalReadsDirect: MetricConfig{Enabled: true}, + OracledbPhysicalWriteIoRequests: MetricConfig{Enabled: true}, + OracledbPhysicalWrites: MetricConfig{Enabled: true}, + OracledbPhysicalWritesDirect: MetricConfig{Enabled: true}, + OracledbProcessesLimit: MetricConfig{Enabled: true}, + OracledbProcessesUsage: MetricConfig{Enabled: true}, + OracledbSessionsLimit: MetricConfig{Enabled: true}, + OracledbSessionsUsage: MetricConfig{Enabled: true}, + OracledbTablespaceSizeLimit: MetricConfig{Enabled: true}, + OracledbTablespaceSizeUsage: MetricConfig{Enabled: true}, + OracledbTransactionsLimit: MetricConfig{Enabled: true}, + OracledbTransactionsUsage: MetricConfig{Enabled: true}, + OracledbUserCommits: MetricConfig{Enabled: true}, + OracledbUserRollbacks: MetricConfig{Enabled: true}, }, ResourceAttributes: ResourceAttributesConfig{ OracledbInstanceName: ResourceAttributeConfig{Enabled: true}, @@ -62,33 +67,38 @@ func TestMetricsBuilderConfig(t *testing.T) { name: "none_set", want: MetricsBuilderConfig{ Metrics: MetricsConfig{ - OracledbConsistentGets: MetricConfig{Enabled: false}, - OracledbCPUTime: MetricConfig{Enabled: false}, - OracledbDbBlockGets: MetricConfig{Enabled: false}, - OracledbDmlLocksLimit: MetricConfig{Enabled: false}, - OracledbDmlLocksUsage: MetricConfig{Enabled: false}, - OracledbEnqueueDeadlocks: MetricConfig{Enabled: false}, - OracledbEnqueueLocksLimit: MetricConfig{Enabled: false}, - OracledbEnqueueLocksUsage: MetricConfig{Enabled: false}, - OracledbEnqueueResourcesLimit: MetricConfig{Enabled: false}, - OracledbEnqueueResourcesUsage: MetricConfig{Enabled: false}, - OracledbExchangeDeadlocks: MetricConfig{Enabled: false}, - OracledbExecutions: MetricConfig{Enabled: false}, - OracledbHardParses: MetricConfig{Enabled: false}, - OracledbLogicalReads: MetricConfig{Enabled: false}, - OracledbParseCalls: MetricConfig{Enabled: false}, - OracledbPgaMemory: MetricConfig{Enabled: false}, - OracledbPhysicalReads: MetricConfig{Enabled: false}, - OracledbProcessesLimit: MetricConfig{Enabled: false}, - OracledbProcessesUsage: MetricConfig{Enabled: false}, - OracledbSessionsLimit: MetricConfig{Enabled: false}, - OracledbSessionsUsage: MetricConfig{Enabled: false}, - OracledbTablespaceSizeLimit: MetricConfig{Enabled: false}, - OracledbTablespaceSizeUsage: MetricConfig{Enabled: false}, - OracledbTransactionsLimit: MetricConfig{Enabled: false}, - OracledbTransactionsUsage: MetricConfig{Enabled: false}, - OracledbUserCommits: MetricConfig{Enabled: false}, - OracledbUserRollbacks: MetricConfig{Enabled: false}, + OracledbConsistentGets: MetricConfig{Enabled: false}, + OracledbCPUTime: MetricConfig{Enabled: false}, + OracledbDbBlockGets: MetricConfig{Enabled: false}, + OracledbDmlLocksLimit: MetricConfig{Enabled: false}, + OracledbDmlLocksUsage: MetricConfig{Enabled: false}, + OracledbEnqueueDeadlocks: MetricConfig{Enabled: false}, + OracledbEnqueueLocksLimit: MetricConfig{Enabled: false}, + OracledbEnqueueLocksUsage: MetricConfig{Enabled: false}, + OracledbEnqueueResourcesLimit: MetricConfig{Enabled: false}, + OracledbEnqueueResourcesUsage: MetricConfig{Enabled: false}, + OracledbExchangeDeadlocks: MetricConfig{Enabled: false}, + OracledbExecutions: MetricConfig{Enabled: false}, + OracledbHardParses: MetricConfig{Enabled: false}, + OracledbLogicalReads: MetricConfig{Enabled: false}, + OracledbParseCalls: MetricConfig{Enabled: false}, + OracledbPgaMemory: MetricConfig{Enabled: false}, + OracledbPhysicalReadIoRequests: MetricConfig{Enabled: false}, + OracledbPhysicalReads: MetricConfig{Enabled: false}, + OracledbPhysicalReadsDirect: MetricConfig{Enabled: false}, + OracledbPhysicalWriteIoRequests: MetricConfig{Enabled: false}, + OracledbPhysicalWrites: MetricConfig{Enabled: false}, + OracledbPhysicalWritesDirect: MetricConfig{Enabled: false}, + OracledbProcessesLimit: MetricConfig{Enabled: false}, + OracledbProcessesUsage: MetricConfig{Enabled: false}, + OracledbSessionsLimit: MetricConfig{Enabled: false}, + OracledbSessionsUsage: MetricConfig{Enabled: false}, + OracledbTablespaceSizeLimit: MetricConfig{Enabled: false}, + OracledbTablespaceSizeUsage: MetricConfig{Enabled: false}, + OracledbTransactionsLimit: MetricConfig{Enabled: false}, + OracledbTransactionsUsage: MetricConfig{Enabled: false}, + OracledbUserCommits: MetricConfig{Enabled: false}, + OracledbUserRollbacks: MetricConfig{Enabled: false}, }, ResourceAttributes: ResourceAttributesConfig{ OracledbInstanceName: ResourceAttributeConfig{Enabled: false}, diff --git a/receiver/oracledbreceiver/internal/metadata/generated_metrics.go b/receiver/oracledbreceiver/internal/metadata/generated_metrics.go index d99643264d687..30384eaaed505 100644 --- a/receiver/oracledbreceiver/internal/metadata/generated_metrics.go +++ b/receiver/oracledbreceiver/internal/metadata/generated_metrics.go @@ -818,6 +818,57 @@ func newMetricOracledbPgaMemory(cfg MetricConfig) metricOracledbPgaMemory { return m } +type metricOracledbPhysicalReadIoRequests struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills oracledb.physical_read_io_requests metric with initial data. +func (m *metricOracledbPhysicalReadIoRequests) init() { + m.data.SetName("oracledb.physical_read_io_requests") + m.data.SetDescription("Number of read requests for application activity") + m.data.SetUnit("{requests}") + m.data.SetEmptySum() + m.data.Sum().SetIsMonotonic(true) + m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) +} + +func (m *metricOracledbPhysicalReadIoRequests) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricOracledbPhysicalReadIoRequests) updateCapacity() { + if m.data.Sum().DataPoints().Len() > m.capacity { + m.capacity = m.data.Sum().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricOracledbPhysicalReadIoRequests) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricOracledbPhysicalReadIoRequests(cfg MetricConfig) metricOracledbPhysicalReadIoRequests { + m := metricOracledbPhysicalReadIoRequests{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + type metricOracledbPhysicalReads struct { data pmetric.Metric // data buffer for generated metric. config MetricConfig // metric config provided by user. @@ -869,6 +920,210 @@ func newMetricOracledbPhysicalReads(cfg MetricConfig) metricOracledbPhysicalRead return m } +type metricOracledbPhysicalReadsDirect struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills oracledb.physical_reads_direct metric with initial data. +func (m *metricOracledbPhysicalReadsDirect) init() { + m.data.SetName("oracledb.physical_reads_direct") + m.data.SetDescription("Number of reads directly from disk, bypassing the buffer cache") + m.data.SetUnit("{reads}") + m.data.SetEmptySum() + m.data.Sum().SetIsMonotonic(true) + m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) +} + +func (m *metricOracledbPhysicalReadsDirect) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricOracledbPhysicalReadsDirect) updateCapacity() { + if m.data.Sum().DataPoints().Len() > m.capacity { + m.capacity = m.data.Sum().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricOracledbPhysicalReadsDirect) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricOracledbPhysicalReadsDirect(cfg MetricConfig) metricOracledbPhysicalReadsDirect { + m := metricOracledbPhysicalReadsDirect{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricOracledbPhysicalWriteIoRequests struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills oracledb.physical_write_io_requests metric with initial data. +func (m *metricOracledbPhysicalWriteIoRequests) init() { + m.data.SetName("oracledb.physical_write_io_requests") + m.data.SetDescription("Number of write requests for application activity") + m.data.SetUnit("{requests}") + m.data.SetEmptySum() + m.data.Sum().SetIsMonotonic(true) + m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) +} + +func (m *metricOracledbPhysicalWriteIoRequests) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricOracledbPhysicalWriteIoRequests) updateCapacity() { + if m.data.Sum().DataPoints().Len() > m.capacity { + m.capacity = m.data.Sum().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricOracledbPhysicalWriteIoRequests) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricOracledbPhysicalWriteIoRequests(cfg MetricConfig) metricOracledbPhysicalWriteIoRequests { + m := metricOracledbPhysicalWriteIoRequests{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricOracledbPhysicalWrites struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills oracledb.physical_writes metric with initial data. +func (m *metricOracledbPhysicalWrites) init() { + m.data.SetName("oracledb.physical_writes") + m.data.SetDescription("Number of physical writes") + m.data.SetUnit("{writes}") + m.data.SetEmptySum() + m.data.Sum().SetIsMonotonic(true) + m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) +} + +func (m *metricOracledbPhysicalWrites) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricOracledbPhysicalWrites) updateCapacity() { + if m.data.Sum().DataPoints().Len() > m.capacity { + m.capacity = m.data.Sum().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricOracledbPhysicalWrites) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricOracledbPhysicalWrites(cfg MetricConfig) metricOracledbPhysicalWrites { + m := metricOracledbPhysicalWrites{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricOracledbPhysicalWritesDirect struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills oracledb.physical_writes_direct metric with initial data. +func (m *metricOracledbPhysicalWritesDirect) init() { + m.data.SetName("oracledb.physical_writes_direct") + m.data.SetDescription("Number of writes directly to disk, bypassing the buffer cache") + m.data.SetUnit("{writes}") + m.data.SetEmptySum() + m.data.Sum().SetIsMonotonic(true) + m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) +} + +func (m *metricOracledbPhysicalWritesDirect) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricOracledbPhysicalWritesDirect) updateCapacity() { + if m.data.Sum().DataPoints().Len() > m.capacity { + m.capacity = m.data.Sum().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricOracledbPhysicalWritesDirect) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricOracledbPhysicalWritesDirect(cfg MetricConfig) metricOracledbPhysicalWritesDirect { + m := metricOracledbPhysicalWritesDirect{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + type metricOracledbProcessesLimit struct { data pmetric.Metric // data buffer for generated metric. config MetricConfig // metric config provided by user. @@ -1373,40 +1628,45 @@ func newMetricOracledbUserRollbacks(cfg MetricConfig) metricOracledbUserRollback // MetricsBuilder provides an interface for scrapers to report metrics while taking care of all the transformations // required to produce metric representation defined in metadata and user config. type MetricsBuilder struct { - config MetricsBuilderConfig // config of the metrics builder. - startTime pcommon.Timestamp // start time that will be applied to all recorded data points. - metricsCapacity int // maximum observed number of metrics per resource. - metricsBuffer pmetric.Metrics // accumulates metrics data before emitting. - buildInfo component.BuildInfo // contains version information. - resourceAttributeIncludeFilter map[string]filter.Filter - resourceAttributeExcludeFilter map[string]filter.Filter - metricOracledbConsistentGets metricOracledbConsistentGets - metricOracledbCPUTime metricOracledbCPUTime - metricOracledbDbBlockGets metricOracledbDbBlockGets - metricOracledbDmlLocksLimit metricOracledbDmlLocksLimit - metricOracledbDmlLocksUsage metricOracledbDmlLocksUsage - metricOracledbEnqueueDeadlocks metricOracledbEnqueueDeadlocks - metricOracledbEnqueueLocksLimit metricOracledbEnqueueLocksLimit - metricOracledbEnqueueLocksUsage metricOracledbEnqueueLocksUsage - metricOracledbEnqueueResourcesLimit metricOracledbEnqueueResourcesLimit - metricOracledbEnqueueResourcesUsage metricOracledbEnqueueResourcesUsage - metricOracledbExchangeDeadlocks metricOracledbExchangeDeadlocks - metricOracledbExecutions metricOracledbExecutions - metricOracledbHardParses metricOracledbHardParses - metricOracledbLogicalReads metricOracledbLogicalReads - metricOracledbParseCalls metricOracledbParseCalls - metricOracledbPgaMemory metricOracledbPgaMemory - metricOracledbPhysicalReads metricOracledbPhysicalReads - metricOracledbProcessesLimit metricOracledbProcessesLimit - metricOracledbProcessesUsage metricOracledbProcessesUsage - metricOracledbSessionsLimit metricOracledbSessionsLimit - metricOracledbSessionsUsage metricOracledbSessionsUsage - metricOracledbTablespaceSizeLimit metricOracledbTablespaceSizeLimit - metricOracledbTablespaceSizeUsage metricOracledbTablespaceSizeUsage - metricOracledbTransactionsLimit metricOracledbTransactionsLimit - metricOracledbTransactionsUsage metricOracledbTransactionsUsage - metricOracledbUserCommits metricOracledbUserCommits - metricOracledbUserRollbacks metricOracledbUserRollbacks + config MetricsBuilderConfig // config of the metrics builder. + startTime pcommon.Timestamp // start time that will be applied to all recorded data points. + metricsCapacity int // maximum observed number of metrics per resource. + metricsBuffer pmetric.Metrics // accumulates metrics data before emitting. + buildInfo component.BuildInfo // contains version information. + resourceAttributeIncludeFilter map[string]filter.Filter + resourceAttributeExcludeFilter map[string]filter.Filter + metricOracledbConsistentGets metricOracledbConsistentGets + metricOracledbCPUTime metricOracledbCPUTime + metricOracledbDbBlockGets metricOracledbDbBlockGets + metricOracledbDmlLocksLimit metricOracledbDmlLocksLimit + metricOracledbDmlLocksUsage metricOracledbDmlLocksUsage + metricOracledbEnqueueDeadlocks metricOracledbEnqueueDeadlocks + metricOracledbEnqueueLocksLimit metricOracledbEnqueueLocksLimit + metricOracledbEnqueueLocksUsage metricOracledbEnqueueLocksUsage + metricOracledbEnqueueResourcesLimit metricOracledbEnqueueResourcesLimit + metricOracledbEnqueueResourcesUsage metricOracledbEnqueueResourcesUsage + metricOracledbExchangeDeadlocks metricOracledbExchangeDeadlocks + metricOracledbExecutions metricOracledbExecutions + metricOracledbHardParses metricOracledbHardParses + metricOracledbLogicalReads metricOracledbLogicalReads + metricOracledbParseCalls metricOracledbParseCalls + metricOracledbPgaMemory metricOracledbPgaMemory + metricOracledbPhysicalReadIoRequests metricOracledbPhysicalReadIoRequests + metricOracledbPhysicalReads metricOracledbPhysicalReads + metricOracledbPhysicalReadsDirect metricOracledbPhysicalReadsDirect + metricOracledbPhysicalWriteIoRequests metricOracledbPhysicalWriteIoRequests + metricOracledbPhysicalWrites metricOracledbPhysicalWrites + metricOracledbPhysicalWritesDirect metricOracledbPhysicalWritesDirect + metricOracledbProcessesLimit metricOracledbProcessesLimit + metricOracledbProcessesUsage metricOracledbProcessesUsage + metricOracledbSessionsLimit metricOracledbSessionsLimit + metricOracledbSessionsUsage metricOracledbSessionsUsage + metricOracledbTablespaceSizeLimit metricOracledbTablespaceSizeLimit + metricOracledbTablespaceSizeUsage metricOracledbTablespaceSizeUsage + metricOracledbTransactionsLimit metricOracledbTransactionsLimit + metricOracledbTransactionsUsage metricOracledbTransactionsUsage + metricOracledbUserCommits metricOracledbUserCommits + metricOracledbUserRollbacks metricOracledbUserRollbacks } // MetricBuilderOption applies changes to default metrics builder. @@ -1428,39 +1688,44 @@ func WithStartTime(startTime pcommon.Timestamp) MetricBuilderOption { } func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.Settings, options ...MetricBuilderOption) *MetricsBuilder { mb := &MetricsBuilder{ - config: mbc, - startTime: pcommon.NewTimestampFromTime(time.Now()), - metricsBuffer: pmetric.NewMetrics(), - buildInfo: settings.BuildInfo, - metricOracledbConsistentGets: newMetricOracledbConsistentGets(mbc.Metrics.OracledbConsistentGets), - metricOracledbCPUTime: newMetricOracledbCPUTime(mbc.Metrics.OracledbCPUTime), - metricOracledbDbBlockGets: newMetricOracledbDbBlockGets(mbc.Metrics.OracledbDbBlockGets), - metricOracledbDmlLocksLimit: newMetricOracledbDmlLocksLimit(mbc.Metrics.OracledbDmlLocksLimit), - metricOracledbDmlLocksUsage: newMetricOracledbDmlLocksUsage(mbc.Metrics.OracledbDmlLocksUsage), - metricOracledbEnqueueDeadlocks: newMetricOracledbEnqueueDeadlocks(mbc.Metrics.OracledbEnqueueDeadlocks), - metricOracledbEnqueueLocksLimit: newMetricOracledbEnqueueLocksLimit(mbc.Metrics.OracledbEnqueueLocksLimit), - metricOracledbEnqueueLocksUsage: newMetricOracledbEnqueueLocksUsage(mbc.Metrics.OracledbEnqueueLocksUsage), - metricOracledbEnqueueResourcesLimit: newMetricOracledbEnqueueResourcesLimit(mbc.Metrics.OracledbEnqueueResourcesLimit), - metricOracledbEnqueueResourcesUsage: newMetricOracledbEnqueueResourcesUsage(mbc.Metrics.OracledbEnqueueResourcesUsage), - metricOracledbExchangeDeadlocks: newMetricOracledbExchangeDeadlocks(mbc.Metrics.OracledbExchangeDeadlocks), - metricOracledbExecutions: newMetricOracledbExecutions(mbc.Metrics.OracledbExecutions), - metricOracledbHardParses: newMetricOracledbHardParses(mbc.Metrics.OracledbHardParses), - metricOracledbLogicalReads: newMetricOracledbLogicalReads(mbc.Metrics.OracledbLogicalReads), - metricOracledbParseCalls: newMetricOracledbParseCalls(mbc.Metrics.OracledbParseCalls), - metricOracledbPgaMemory: newMetricOracledbPgaMemory(mbc.Metrics.OracledbPgaMemory), - metricOracledbPhysicalReads: newMetricOracledbPhysicalReads(mbc.Metrics.OracledbPhysicalReads), - metricOracledbProcessesLimit: newMetricOracledbProcessesLimit(mbc.Metrics.OracledbProcessesLimit), - metricOracledbProcessesUsage: newMetricOracledbProcessesUsage(mbc.Metrics.OracledbProcessesUsage), - metricOracledbSessionsLimit: newMetricOracledbSessionsLimit(mbc.Metrics.OracledbSessionsLimit), - metricOracledbSessionsUsage: newMetricOracledbSessionsUsage(mbc.Metrics.OracledbSessionsUsage), - metricOracledbTablespaceSizeLimit: newMetricOracledbTablespaceSizeLimit(mbc.Metrics.OracledbTablespaceSizeLimit), - metricOracledbTablespaceSizeUsage: newMetricOracledbTablespaceSizeUsage(mbc.Metrics.OracledbTablespaceSizeUsage), - metricOracledbTransactionsLimit: newMetricOracledbTransactionsLimit(mbc.Metrics.OracledbTransactionsLimit), - metricOracledbTransactionsUsage: newMetricOracledbTransactionsUsage(mbc.Metrics.OracledbTransactionsUsage), - metricOracledbUserCommits: newMetricOracledbUserCommits(mbc.Metrics.OracledbUserCommits), - metricOracledbUserRollbacks: newMetricOracledbUserRollbacks(mbc.Metrics.OracledbUserRollbacks), - resourceAttributeIncludeFilter: make(map[string]filter.Filter), - resourceAttributeExcludeFilter: make(map[string]filter.Filter), + config: mbc, + startTime: pcommon.NewTimestampFromTime(time.Now()), + metricsBuffer: pmetric.NewMetrics(), + buildInfo: settings.BuildInfo, + metricOracledbConsistentGets: newMetricOracledbConsistentGets(mbc.Metrics.OracledbConsistentGets), + metricOracledbCPUTime: newMetricOracledbCPUTime(mbc.Metrics.OracledbCPUTime), + metricOracledbDbBlockGets: newMetricOracledbDbBlockGets(mbc.Metrics.OracledbDbBlockGets), + metricOracledbDmlLocksLimit: newMetricOracledbDmlLocksLimit(mbc.Metrics.OracledbDmlLocksLimit), + metricOracledbDmlLocksUsage: newMetricOracledbDmlLocksUsage(mbc.Metrics.OracledbDmlLocksUsage), + metricOracledbEnqueueDeadlocks: newMetricOracledbEnqueueDeadlocks(mbc.Metrics.OracledbEnqueueDeadlocks), + metricOracledbEnqueueLocksLimit: newMetricOracledbEnqueueLocksLimit(mbc.Metrics.OracledbEnqueueLocksLimit), + metricOracledbEnqueueLocksUsage: newMetricOracledbEnqueueLocksUsage(mbc.Metrics.OracledbEnqueueLocksUsage), + metricOracledbEnqueueResourcesLimit: newMetricOracledbEnqueueResourcesLimit(mbc.Metrics.OracledbEnqueueResourcesLimit), + metricOracledbEnqueueResourcesUsage: newMetricOracledbEnqueueResourcesUsage(mbc.Metrics.OracledbEnqueueResourcesUsage), + metricOracledbExchangeDeadlocks: newMetricOracledbExchangeDeadlocks(mbc.Metrics.OracledbExchangeDeadlocks), + metricOracledbExecutions: newMetricOracledbExecutions(mbc.Metrics.OracledbExecutions), + metricOracledbHardParses: newMetricOracledbHardParses(mbc.Metrics.OracledbHardParses), + metricOracledbLogicalReads: newMetricOracledbLogicalReads(mbc.Metrics.OracledbLogicalReads), + metricOracledbParseCalls: newMetricOracledbParseCalls(mbc.Metrics.OracledbParseCalls), + metricOracledbPgaMemory: newMetricOracledbPgaMemory(mbc.Metrics.OracledbPgaMemory), + metricOracledbPhysicalReadIoRequests: newMetricOracledbPhysicalReadIoRequests(mbc.Metrics.OracledbPhysicalReadIoRequests), + metricOracledbPhysicalReads: newMetricOracledbPhysicalReads(mbc.Metrics.OracledbPhysicalReads), + metricOracledbPhysicalReadsDirect: newMetricOracledbPhysicalReadsDirect(mbc.Metrics.OracledbPhysicalReadsDirect), + metricOracledbPhysicalWriteIoRequests: newMetricOracledbPhysicalWriteIoRequests(mbc.Metrics.OracledbPhysicalWriteIoRequests), + metricOracledbPhysicalWrites: newMetricOracledbPhysicalWrites(mbc.Metrics.OracledbPhysicalWrites), + metricOracledbPhysicalWritesDirect: newMetricOracledbPhysicalWritesDirect(mbc.Metrics.OracledbPhysicalWritesDirect), + metricOracledbProcessesLimit: newMetricOracledbProcessesLimit(mbc.Metrics.OracledbProcessesLimit), + metricOracledbProcessesUsage: newMetricOracledbProcessesUsage(mbc.Metrics.OracledbProcessesUsage), + metricOracledbSessionsLimit: newMetricOracledbSessionsLimit(mbc.Metrics.OracledbSessionsLimit), + metricOracledbSessionsUsage: newMetricOracledbSessionsUsage(mbc.Metrics.OracledbSessionsUsage), + metricOracledbTablespaceSizeLimit: newMetricOracledbTablespaceSizeLimit(mbc.Metrics.OracledbTablespaceSizeLimit), + metricOracledbTablespaceSizeUsage: newMetricOracledbTablespaceSizeUsage(mbc.Metrics.OracledbTablespaceSizeUsage), + metricOracledbTransactionsLimit: newMetricOracledbTransactionsLimit(mbc.Metrics.OracledbTransactionsLimit), + metricOracledbTransactionsUsage: newMetricOracledbTransactionsUsage(mbc.Metrics.OracledbTransactionsUsage), + metricOracledbUserCommits: newMetricOracledbUserCommits(mbc.Metrics.OracledbUserCommits), + metricOracledbUserRollbacks: newMetricOracledbUserRollbacks(mbc.Metrics.OracledbUserRollbacks), + resourceAttributeIncludeFilter: make(map[string]filter.Filter), + resourceAttributeExcludeFilter: make(map[string]filter.Filter), } if mbc.ResourceAttributes.OracledbInstanceName.MetricsInclude != nil { mb.resourceAttributeIncludeFilter["oracledb.instance.name"] = filter.CreateFilter(mbc.ResourceAttributes.OracledbInstanceName.MetricsInclude) @@ -1553,7 +1818,12 @@ func (mb *MetricsBuilder) EmitForResource(options ...ResourceMetricsOption) { mb.metricOracledbLogicalReads.emit(ils.Metrics()) mb.metricOracledbParseCalls.emit(ils.Metrics()) mb.metricOracledbPgaMemory.emit(ils.Metrics()) + mb.metricOracledbPhysicalReadIoRequests.emit(ils.Metrics()) mb.metricOracledbPhysicalReads.emit(ils.Metrics()) + mb.metricOracledbPhysicalReadsDirect.emit(ils.Metrics()) + mb.metricOracledbPhysicalWriteIoRequests.emit(ils.Metrics()) + mb.metricOracledbPhysicalWrites.emit(ils.Metrics()) + mb.metricOracledbPhysicalWritesDirect.emit(ils.Metrics()) mb.metricOracledbProcessesLimit.emit(ils.Metrics()) mb.metricOracledbProcessesUsage.emit(ils.Metrics()) mb.metricOracledbSessionsLimit.emit(ils.Metrics()) @@ -1750,6 +2020,16 @@ func (mb *MetricsBuilder) RecordOracledbPgaMemoryDataPoint(ts pcommon.Timestamp, return nil } +// RecordOracledbPhysicalReadIoRequestsDataPoint adds a data point to oracledb.physical_read_io_requests metric. +func (mb *MetricsBuilder) RecordOracledbPhysicalReadIoRequestsDataPoint(ts pcommon.Timestamp, inputVal string) error { + val, err := strconv.ParseInt(inputVal, 10, 64) + if err != nil { + return fmt.Errorf("failed to parse int64 for OracledbPhysicalReadIoRequests, value was %s: %w", inputVal, err) + } + mb.metricOracledbPhysicalReadIoRequests.recordDataPoint(mb.startTime, ts, val) + return nil +} + // RecordOracledbPhysicalReadsDataPoint adds a data point to oracledb.physical_reads metric. func (mb *MetricsBuilder) RecordOracledbPhysicalReadsDataPoint(ts pcommon.Timestamp, inputVal string) error { val, err := strconv.ParseInt(inputVal, 10, 64) @@ -1760,6 +2040,46 @@ func (mb *MetricsBuilder) RecordOracledbPhysicalReadsDataPoint(ts pcommon.Timest return nil } +// RecordOracledbPhysicalReadsDirectDataPoint adds a data point to oracledb.physical_reads_direct metric. +func (mb *MetricsBuilder) RecordOracledbPhysicalReadsDirectDataPoint(ts pcommon.Timestamp, inputVal string) error { + val, err := strconv.ParseInt(inputVal, 10, 64) + if err != nil { + return fmt.Errorf("failed to parse int64 for OracledbPhysicalReadsDirect, value was %s: %w", inputVal, err) + } + mb.metricOracledbPhysicalReadsDirect.recordDataPoint(mb.startTime, ts, val) + return nil +} + +// RecordOracledbPhysicalWriteIoRequestsDataPoint adds a data point to oracledb.physical_write_io_requests metric. +func (mb *MetricsBuilder) RecordOracledbPhysicalWriteIoRequestsDataPoint(ts pcommon.Timestamp, inputVal string) error { + val, err := strconv.ParseInt(inputVal, 10, 64) + if err != nil { + return fmt.Errorf("failed to parse int64 for OracledbPhysicalWriteIoRequests, value was %s: %w", inputVal, err) + } + mb.metricOracledbPhysicalWriteIoRequests.recordDataPoint(mb.startTime, ts, val) + return nil +} + +// RecordOracledbPhysicalWritesDataPoint adds a data point to oracledb.physical_writes metric. +func (mb *MetricsBuilder) RecordOracledbPhysicalWritesDataPoint(ts pcommon.Timestamp, inputVal string) error { + val, err := strconv.ParseInt(inputVal, 10, 64) + if err != nil { + return fmt.Errorf("failed to parse int64 for OracledbPhysicalWrites, value was %s: %w", inputVal, err) + } + mb.metricOracledbPhysicalWrites.recordDataPoint(mb.startTime, ts, val) + return nil +} + +// RecordOracledbPhysicalWritesDirectDataPoint adds a data point to oracledb.physical_writes_direct metric. +func (mb *MetricsBuilder) RecordOracledbPhysicalWritesDirectDataPoint(ts pcommon.Timestamp, inputVal string) error { + val, err := strconv.ParseInt(inputVal, 10, 64) + if err != nil { + return fmt.Errorf("failed to parse int64 for OracledbPhysicalWritesDirect, value was %s: %w", inputVal, err) + } + mb.metricOracledbPhysicalWritesDirect.recordDataPoint(mb.startTime, ts, val) + return nil +} + // RecordOracledbProcessesLimitDataPoint adds a data point to oracledb.processes.limit metric. func (mb *MetricsBuilder) RecordOracledbProcessesLimitDataPoint(ts pcommon.Timestamp, inputVal string) error { val, err := strconv.ParseInt(inputVal, 10, 64) diff --git a/receiver/oracledbreceiver/internal/metadata/generated_metrics_test.go b/receiver/oracledbreceiver/internal/metadata/generated_metrics_test.go index 1b364cb94cec6..5c3e44129e6d5 100644 --- a/receiver/oracledbreceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/oracledbreceiver/internal/metadata/generated_metrics_test.go @@ -130,10 +130,25 @@ func TestMetricsBuilder(t *testing.T) { allMetricsCount++ mb.RecordOracledbPgaMemoryDataPoint(ts, "1") + allMetricsCount++ + mb.RecordOracledbPhysicalReadIoRequestsDataPoint(ts, "1") + defaultMetricsCount++ allMetricsCount++ mb.RecordOracledbPhysicalReadsDataPoint(ts, "1") + allMetricsCount++ + mb.RecordOracledbPhysicalReadsDirectDataPoint(ts, "1") + + allMetricsCount++ + mb.RecordOracledbPhysicalWriteIoRequestsDataPoint(ts, "1") + + allMetricsCount++ + mb.RecordOracledbPhysicalWritesDataPoint(ts, "1") + + allMetricsCount++ + mb.RecordOracledbPhysicalWritesDirectDataPoint(ts, "1") + defaultMetricsCount++ allMetricsCount++ mb.RecordOracledbProcessesLimitDataPoint(ts, "1") @@ -410,6 +425,20 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) + case "oracledb.physical_read_io_requests": + assert.False(t, validatedMetrics["oracledb.physical_read_io_requests"], "Found a duplicate in the metrics slice: oracledb.physical_read_io_requests") + validatedMetrics["oracledb.physical_read_io_requests"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Number of read requests for application activity", ms.At(i).Description()) + assert.Equal(t, "{requests}", ms.At(i).Unit()) + assert.True(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) case "oracledb.physical_reads": assert.False(t, validatedMetrics["oracledb.physical_reads"], "Found a duplicate in the metrics slice: oracledb.physical_reads") validatedMetrics["oracledb.physical_reads"] = true @@ -424,6 +453,62 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) + case "oracledb.physical_reads_direct": + assert.False(t, validatedMetrics["oracledb.physical_reads_direct"], "Found a duplicate in the metrics slice: oracledb.physical_reads_direct") + validatedMetrics["oracledb.physical_reads_direct"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Number of reads directly from disk, bypassing the buffer cache", ms.At(i).Description()) + assert.Equal(t, "{reads}", ms.At(i).Unit()) + assert.True(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "oracledb.physical_write_io_requests": + assert.False(t, validatedMetrics["oracledb.physical_write_io_requests"], "Found a duplicate in the metrics slice: oracledb.physical_write_io_requests") + validatedMetrics["oracledb.physical_write_io_requests"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Number of write requests for application activity", ms.At(i).Description()) + assert.Equal(t, "{requests}", ms.At(i).Unit()) + assert.True(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "oracledb.physical_writes": + assert.False(t, validatedMetrics["oracledb.physical_writes"], "Found a duplicate in the metrics slice: oracledb.physical_writes") + validatedMetrics["oracledb.physical_writes"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Number of physical writes", ms.At(i).Description()) + assert.Equal(t, "{writes}", ms.At(i).Unit()) + assert.True(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "oracledb.physical_writes_direct": + assert.False(t, validatedMetrics["oracledb.physical_writes_direct"], "Found a duplicate in the metrics slice: oracledb.physical_writes_direct") + validatedMetrics["oracledb.physical_writes_direct"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Number of writes directly to disk, bypassing the buffer cache", ms.At(i).Description()) + assert.Equal(t, "{writes}", ms.At(i).Unit()) + assert.True(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) case "oracledb.processes.limit": assert.False(t, validatedMetrics["oracledb.processes.limit"], "Found a duplicate in the metrics slice: oracledb.processes.limit") validatedMetrics["oracledb.processes.limit"] = true diff --git a/receiver/oracledbreceiver/internal/metadata/testdata/config.yaml b/receiver/oracledbreceiver/internal/metadata/testdata/config.yaml index 2f44bf2234aa3..7f149864fb1dc 100644 --- a/receiver/oracledbreceiver/internal/metadata/testdata/config.yaml +++ b/receiver/oracledbreceiver/internal/metadata/testdata/config.yaml @@ -33,8 +33,18 @@ all_set: enabled: true oracledb.pga_memory: enabled: true + oracledb.physical_read_io_requests: + enabled: true oracledb.physical_reads: enabled: true + oracledb.physical_reads_direct: + enabled: true + oracledb.physical_write_io_requests: + enabled: true + oracledb.physical_writes: + enabled: true + oracledb.physical_writes_direct: + enabled: true oracledb.processes.limit: enabled: true oracledb.processes.usage: @@ -92,8 +102,18 @@ none_set: enabled: false oracledb.pga_memory: enabled: false + oracledb.physical_read_io_requests: + enabled: false oracledb.physical_reads: enabled: false + oracledb.physical_reads_direct: + enabled: false + oracledb.physical_write_io_requests: + enabled: false + oracledb.physical_writes: + enabled: false + oracledb.physical_writes_direct: + enabled: false oracledb.processes.limit: enabled: false oracledb.processes.usage: diff --git a/receiver/oracledbreceiver/metadata.yaml b/receiver/oracledbreceiver/metadata.yaml index fdc84e8f8a212..71d94058ca081 100644 --- a/receiver/oracledbreceiver/metadata.yaml +++ b/receiver/oracledbreceiver/metadata.yaml @@ -109,6 +109,51 @@ metrics: value_type: int input_type: string unit: "{reads}" + oracledb.physical_reads_direct: + description: Number of reads directly from disk, bypassing the buffer cache + enabled: false + sum: + aggregation_temporality: cumulative + monotonic: true + value_type: int + input_type: string + unit: "{reads}" + oracledb.physical_read_io_requests: + description: Number of read requests for application activity + enabled: false + sum: + aggregation_temporality: cumulative + monotonic: true + value_type: int + input_type: string + unit: "{requests}" + oracledb.physical_writes: + description: Number of physical writes + enabled: false + sum: + aggregation_temporality: cumulative + monotonic: true + value_type: int + input_type: string + unit: "{writes}" + oracledb.physical_writes_direct: + description: Number of writes directly to disk, bypassing the buffer cache + enabled: false + sum: + aggregation_temporality: cumulative + monotonic: true + value_type: int + input_type: string + unit: "{writes}" + oracledb.physical_write_io_requests: + description: Number of write requests for application activity + enabled: false + sum: + aggregation_temporality: cumulative + monotonic: true + value_type: int + input_type: string + unit: "{requests}" oracledb.user_commits: description: Number of user commits. When a user commits a transaction, the redo generated that reflects the changes made to database blocks must be written diff --git a/receiver/oracledbreceiver/scraper.go b/receiver/oracledbreceiver/scraper.go index 3a77b7b88d6bd..6bf454e5a2f4a 100644 --- a/receiver/oracledbreceiver/scraper.go +++ b/receiver/oracledbreceiver/scraper.go @@ -32,6 +32,11 @@ const ( userCommits = "user commits" userRollbacks = "user rollbacks" physicalReads = "physical reads" + physicalReadsDirect = "physical reads direct" + physicalReadIORequests = "physical read IO requests" + physicalWrites = "physical writes" + physicalWritesDirect = "physical writes direct" + physicalWriteIORequests = "physical write IO requests" sessionLogicalReads = "session logical reads" cpuTime = "CPU used by this session" pgaMemory = "session pga memory" @@ -106,6 +111,11 @@ func (s *oracleScraper) scrape(ctx context.Context) (pmetric.Metrics, error) { s.metricsBuilderConfig.Metrics.OracledbUserCommits.Enabled || s.metricsBuilderConfig.Metrics.OracledbUserRollbacks.Enabled || s.metricsBuilderConfig.Metrics.OracledbPhysicalReads.Enabled || + s.metricsBuilderConfig.Metrics.OracledbPhysicalReadsDirect.Enabled || + s.metricsBuilderConfig.Metrics.OracledbPhysicalReadIoRequests.Enabled || + s.metricsBuilderConfig.Metrics.OracledbPhysicalWrites.Enabled || + s.metricsBuilderConfig.Metrics.OracledbPhysicalWritesDirect.Enabled || + s.metricsBuilderConfig.Metrics.OracledbPhysicalWriteIoRequests.Enabled || s.metricsBuilderConfig.Metrics.OracledbLogicalReads.Enabled || s.metricsBuilderConfig.Metrics.OracledbCPUTime.Enabled || s.metricsBuilderConfig.Metrics.OracledbPgaMemory.Enabled || @@ -160,6 +170,31 @@ func (s *oracleScraper) scrape(ctx context.Context) (pmetric.Metrics, error) { if err != nil { scrapeErrors = append(scrapeErrors, err) } + case physicalReadsDirect: + err := s.mb.RecordOracledbPhysicalReadsDirectDataPoint(now, row["VALUE"]) + if err != nil { + scrapeErrors = append(scrapeErrors, err) + } + case physicalReadIORequests: + err := s.mb.RecordOracledbPhysicalReadIoRequestsDataPoint(now, row["VALUE"]) + if err != nil { + scrapeErrors = append(scrapeErrors, err) + } + case physicalWrites: + err := s.mb.RecordOracledbPhysicalWritesDataPoint(now, row["VALUE"]) + if err != nil { + scrapeErrors = append(scrapeErrors, err) + } + case physicalWritesDirect: + err := s.mb.RecordOracledbPhysicalWritesDirectDataPoint(now, row["VALUE"]) + if err != nil { + scrapeErrors = append(scrapeErrors, err) + } + case physicalWriteIORequests: + err := s.mb.RecordOracledbPhysicalWriteIoRequestsDataPoint(now, row["VALUE"]) + if err != nil { + scrapeErrors = append(scrapeErrors, err) + } case sessionLogicalReads: err := s.mb.RecordOracledbLogicalReadsDataPoint(now, row["VALUE"]) if err != nil { diff --git a/receiver/oracledbreceiver/scraper_test.go b/receiver/oracledbreceiver/scraper_test.go index 6e07a0f796238..a8546b137a236 100644 --- a/receiver/oracledbreceiver/scraper_test.go +++ b/receiver/oracledbreceiver/scraper_test.go @@ -32,7 +32,7 @@ func TestScraper_ErrorOnStart(t *testing.T) { } var queryResponses = map[string][]metricRow{ - statsSQL: {{"NAME": enqueueDeadlocks, "VALUE": "18"}, {"NAME": exchangeDeadlocks, "VALUE": "88898"}, {"NAME": executeCount, "VALUE": "178878"}, {"NAME": parseCountTotal, "VALUE": "1999"}, {"NAME": parseCountHard, "VALUE": "1"}, {"NAME": userCommits, "VALUE": "187778888"}, {"NAME": userRollbacks, "VALUE": "1898979879789"}, {"NAME": physicalReads, "VALUE": "1887777"}, {"NAME": sessionLogicalReads, "VALUE": "189"}, {"NAME": cpuTime, "VALUE": "1887"}, {"NAME": pgaMemory, "VALUE": "1999887"}, {"NAME": dbBlockGets, "VALUE": "42"}, {"NAME": consistentGets, "VALUE": "78944"}}, + statsSQL: {{"NAME": enqueueDeadlocks, "VALUE": "18"}, {"NAME": exchangeDeadlocks, "VALUE": "88898"}, {"NAME": executeCount, "VALUE": "178878"}, {"NAME": parseCountTotal, "VALUE": "1999"}, {"NAME": parseCountHard, "VALUE": "1"}, {"NAME": userCommits, "VALUE": "187778888"}, {"NAME": userRollbacks, "VALUE": "1898979879789"}, {"NAME": physicalReads, "VALUE": "1887777"}, {"NAME": physicalReadsDirect, "VALUE": "31337"}, {"NAME": sessionLogicalReads, "VALUE": "189"}, {"NAME": cpuTime, "VALUE": "1887"}, {"NAME": pgaMemory, "VALUE": "1999887"}, {"NAME": dbBlockGets, "VALUE": "42"}, {"NAME": consistentGets, "VALUE": "78944"}}, sessionCountSQL: {{"VALUE": "1"}}, systemResourceLimitsSQL: { {"RESOURCE_NAME": "processes", "CURRENT_UTILIZATION": "3", "MAX_UTILIZATION": "10", "INITIAL_ALLOCATION": "100", "LIMIT_VALUE": "100"},