Skip to content

Commit b734b81

Browse files
committed
[receiver/oracledb] Support query-level log collection - Query samples implementation
1 parent a466a0e commit b734b81

File tree

13 files changed

+614
-11
lines changed

13 files changed

+614
-11
lines changed

receiver/oracledbreceiver/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ type TopQueryCollection struct {
3333
TopQueryCount uint `mapstructure:"top_query_count"`
3434
}
3535

36+
type QuerySample struct {
37+
MaxRowsPerQuery uint64 `mapstructure:"max_rows_per_query"`
38+
39+
// prevent unkeyed literal initialization
40+
_ struct{}
41+
}
42+
3643
type Config struct {
3744
DataSource string `mapstructure:"datasource"`
3845
Endpoint string `mapstructure:"endpoint"`
@@ -44,6 +51,7 @@ type Config struct {
4451
metadata.LogsBuilderConfig `mapstructure:",squash"`
4552

4653
TopQueryCollection `mapstructure:"top_query_collection"`
54+
QuerySample `mapstructure:"query_sample_collection"`
4755
}
4856

4957
func (c Config) Validate() error {

receiver/oracledbreceiver/documentation.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,40 @@ events:
389389
enabled: true
390390
```
391391
392+
### db.server.query_sample
393+
394+
sample query
395+
396+
#### Attributes
397+
398+
| Name | Description | Values |
399+
| ---- | ----------- | ------ |
400+
| db.query.text | The text of the database query being executed. | Any Str |
401+
| db.system.name | The database management system (DBMS) product as identified by the client instrumentation. | Any Str |
402+
| user.name | Database user name under which a session is connected to | Any Str |
403+
| db.namespace | The database name. | Any Str |
404+
| client.address | Hostname or address of the client. | Any Str |
405+
| client.port | TCP port used by the client. | Any Int |
406+
| network.peer.address | IP address of the peer client. | Any Str |
407+
| network.peer.port | TCP port used by the peer client. | Any Int |
408+
| oracledb.plan_hash_value | Binary hash value calculated on the query execution plan and used to identify similar query execution plans, reported in the HEX format. | Any Str |
409+
| oracledb.sql_id | The SQL ID of the query. | Any Str |
410+
| oracledb.child_number | The child number of the query. | Any Str |
411+
| oracledb.sid | ID of the Oracle Server session. | Any Str |
412+
| oracledb.serial | Serial number associated with a session. | Any Str |
413+
| oracledb.process | The operating system process ID (PID) associated with a session. | Any Str |
414+
| oracledb.schemaname | Oracle schema under which SQL statements are being executed | Any Str |
415+
| oracledb.program | Name of the client program or tool that initiated the Oracle database session. | Any Str |
416+
| oracledb.module | Logical module name of the client application that initiated a query or session. | Any Str |
417+
| oracledb.status | Execution state or result of a database query or session. | Any Str |
418+
| oracledb.state | Current state of the query or the session executing it. | Any Str |
419+
| oracledb.wait_class | The category of wait events a query or session is currently experiencing in Oracle Database. | Any Str |
420+
| oracledb.event | The specific wait event that a query or session is currently experiencing. | Any Str |
421+
| oracledb.object_name | Name of the database object that a query is accessing. | Any Str |
422+
| oracledb.object_type | Type of the database object that a query is accessing. | Any Str |
423+
| oracledb.osuser | Name of the operating system user that initiated or is running the Oracle database session. | Any Str |
424+
| oracledb.duration_sec | Total time taken by a database query to execute. | Any Double |
425+
392426
### db.server.top_query
393427
394428
Collection of event metrics for top N queries, filtered based on the highest CPU time consumed (oracledb.elapsed_time).

receiver/oracledbreceiver/factory.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ func createDefaultConfig() component.Config {
4444
ControllerConfig: cfg,
4545
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
4646
LogsBuilderConfig: metadata.DefaultLogsBuilderConfig(),
47+
QuerySample: QuerySample{
48+
MaxRowsPerQuery: 100,
49+
},
4750
TopQueryCollection: TopQueryCollection{
4851
MaxQuerySampleCount: 1000,
4952
TopQueryCount: 200,
@@ -120,7 +123,7 @@ func createLogsReceiverFunc(sqlOpenerFunc sqlOpenerFunc, clientProviderFunc clie
120123

121124
mp, err := newLogsScraper(logsBuilder, sqlCfg.LogsBuilderConfig, sqlCfg.ControllerConfig, settings.Logger, func() (*sql.DB, error) {
122125
return sqlOpenerFunc(getDataSource(*sqlCfg))
123-
}, clientProviderFunc, instanceName, metricCache, sqlCfg.TopQueryCollection, hostName)
126+
}, clientProviderFunc, instanceName, metricCache, sqlCfg.TopQueryCollection, sqlCfg.QuerySample, hostName)
124127
if err != nil {
125128
return nil, err
126129
}

receiver/oracledbreceiver/internal/metadata/generated_config.go

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

receiver/oracledbreceiver/internal/metadata/generated_logs.go

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

receiver/oracledbreceiver/internal/metadata/generated_logs_test.go

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

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ all_set:
8484
oracledb.user_rollbacks:
8585
enabled: true
8686
events:
87+
db.server.query_sample:
88+
enabled: true
8789
db.server.top_query:
8890
enabled: true
8991
resource_attributes:
@@ -176,6 +178,8 @@ none_set:
176178
oracledb.user_rollbacks:
177179
enabled: false
178180
events:
181+
db.server.query_sample:
182+
enabled: false
179183
db.server.top_query:
180184
enabled: false
181185
resource_attributes:

0 commit comments

Comments
 (0)