Skip to content

Commit 01de308

Browse files
authored
[oracledb/receiver] Removing the toLowercase on sql_text in topN & adding child_address into samples payload (#42164)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Removing the toLowercase conversion on sql text in top_query payload. Also, adding child_address into the query_samples payload. <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes #37478 <!--Describe what testing was performed and which tests were added.--> #### Testing unit tests updated <!--Describe the documentation added.--> #### Documentation updated <!--Please delete paragraphs that you did not use before submitting.-->
1 parent 0d8c168 commit 01de308

File tree

10 files changed

+47
-10
lines changed

10 files changed

+47
-10
lines changed

.chloggen/oracle_sql_case_fix.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: oracledbreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Removing the toLowercase conversion on sql text in top_query payload. Also, adding child_address into the query_samples payload.
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: [37478]
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/oracledbreceiver/documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ sample query
416416
| 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 |
417417
| oracledb.sql_id | The SQL ID of the query. | Any Str |
418418
| oracledb.child_number | The child number of the query. | Any Str |
419+
| oracledb.child_address | Address of the child cursor. | Any Str |
419420
| oracledb.sid | ID of the Oracle Server session. | Any Str |
420421
| oracledb.serial | Serial number associated with a session. | Any Str |
421422
| oracledb.process | The operating system process ID (PID) associated with a session. | Any Str |

receiver/oracledbreceiver/internal/metadata/generated_logs.go

Lines changed: 4 additions & 3 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: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/oracledbreceiver/metadata.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ events:
207207
- oracledb.plan_hash_value
208208
- oracledb.sql_id
209209
- oracledb.child_number
210+
- oracledb.child_address
210211
- oracledb.sid
211212
- oracledb.serial
212213
- oracledb.process

receiver/oracledbreceiver/scraper.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ func (s *oracleScraper) collectQuerySamples(ctx context.Context, logs plog.Logs)
695695
const sqlID = "SQL_ID"
696696
const schemaName = "SCHEMANAME"
697697
const sqlChildNumber = "SQL_CHILD_NUMBER"
698+
const childAddress = "CHILD_ADDRESS"
698699
const sid = "SID"
699700
const serialNumber = "SERIAL#"
700701
const status = "STATUS"
@@ -748,7 +749,7 @@ func (s *oracleScraper) collectQuerySamples(ctx context.Context, logs plog.Logs)
748749
})
749750

750751
s.lb.RecordDbServerQuerySampleEvent(queryContext, timestamp, obfuscatedSQL, dbSystemNameVal, row[username], row[serviceName], row[hostName],
751-
clientPort, row[hostName], clientPort, queryPlanHashVal, row[sqlID], row[sqlChildNumber], row[sid], row[serialNumber], row[process],
752+
clientPort, row[hostName], clientPort, queryPlanHashVal, row[sqlID], row[sqlChildNumber], row[childAddress], row[sid], row[serialNumber], row[process],
752753
row[schemaName], row[program], row[module], row[status], row[state], row[waitclass], row[event], row[objectName], row[objectType],
753754
row[osUser], queryDuration)
754755
}
@@ -770,8 +771,7 @@ func (s *oracleScraper) obfuscateCacheHits(hits []queryMetricCacheHit) []queryMe
770771
if err != nil {
771772
s.logger.Error("oracleScraper failed getting metric rows", zap.Error(err))
772773
} else {
773-
obfuscatedSQLLowerCase := strings.ToLower(obfuscatedSQL)
774-
hit.queryText = obfuscatedSQLLowerCase
774+
hit.queryText = obfuscatedSQL
775775
obfuscatedHits = append(obfuscatedHits, hit)
776776
}
777777
}

receiver/oracledbreceiver/scraper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func TestScraper_ScrapeTopNLogs(t *testing.T) {
310310

311311
var samplesQueryResponses = map[string][]metricRow{
312312
samplesQuery: {{
313-
"ACTION": "00-0af7651916cd43dd8448eb211c80319c-a7ad6b7169203331-01", "MACHINE": "TEST-MACHINE", "USERNAME": "ADMIN", "SCHEMANAME": "ADMIN", "SQL_ID": "48bc50b6fuz4y", "WAIT_CLASS": "ONE", "OBJECT_NAME": "BLAH",
313+
"ACTION": "00-0af7651916cd43dd8448eb211c80319c-a7ad6b7169203331-01", "MACHINE": "TEST-MACHINE", "USERNAME": "ADMIN", "SCHEMANAME": "ADMIN", "SQL_ID": "48bc50b6fuz4y", "WAIT_CLASS": "ONE", "OBJECT_NAME": "BLAH", "CHILD_ADDRESS": "SDF3SDF1234D",
314314
"SQL_CHILD_NUMBER": "0", "SID": "675", "SERIAL#": "51295", "SQL_FULLTEXT": "test_query", "OSUSER": "test-user", "PROCESS": "1115", "OBJECT_TYPE": "OBJECT_TYPE-A",
315315
"PORT": "54440", "PROGRAM": "Oracle SQL Developer for VS Code", "MODULE": "Oracle SQL Developer for VS Code", "STATUS": "ACTIVE", "STATE": "WAITED KNOWN TIME", "PLAN_HASH_VALUE": "4199919568", "DURATION_SEC": "1",
316316
}},

receiver/oracledbreceiver/templates/oracleQuerySampleSql.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ S.USERNAME,
55
S.SCHEMANAME,
66
S.SQL_ID,
77
S.SQL_CHILD_NUMBER,
8+
RAWTOHEX(Q.CHILD_ADDRESS) AS CHILD_ADDRESS,
89
S.SID,
910
S.SERIAL#,
1011
Q.SQL_FULLTEXT,
@@ -29,6 +30,6 @@ CASE WHEN S.PLSQL_ENTRY_OBJECT_ID IS NOT NULL
2930
END AS OBJECT_NAME, P.OBJECT_TYPE
3031
FROM V$SESSION S LEFT JOIN DBA_PROCEDURES P ON S.PLSQL_ENTRY_OBJECT_ID = P.OBJECT_ID
3132
AND S.PLSQL_ENTRY_SUBPROGRAM_ID = P.SUBPROGRAM_ID
32-
LEFT JOIN V$SQL Q ON S.SQL_ID = Q.SQL_ID
33+
JOIN V$SQL Q ON S.SQL_ID = Q.SQL_ID AND S.SQL_CHILD_NUMBER = Q.CHILD_NUMBER
3334
WHERE S.SQL_ID IS NOT NULL AND S.STATUS = 'ACTIVE'
3435
FETCH FIRST :1 ROWS ONLY

receiver/oracledbreceiver/testdata/expectedQueryTextAndPlanQuery.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ resourceLogs:
1818
stringValue: oracle-host-sample-1
1919
- key: db.query.text
2020
value:
21-
stringValue: select count ( * ) from admin. employee e join admin. person p on e. businessentityid = ? join admin. employeepayhistory eph on e. businessentityid = eph. businessentityid where eph. rate > ( select avg ( rate ) from admin. employeepayhistory )
21+
stringValue: SELECT COUNT ( * ) FROM ADMIN. Employee e JOIN ADMIN. Person p ON e. BusinessEntityID = ? JOIN ADMIN. EmployeePayHistory eph ON e. BusinessEntityID = eph. BusinessEntityID WHERE eph. Rate > ( SELECT AVG ( Rate ) FROM ADMIN. EmployeePayHistory )
2222
- key: oracledb.query_plan
2323
value:
2424
stringValue: '[{"ACCESS_PREDICATES":"","BYTES":"","CARDINALITY":"","COST":"1","CPU_COST":"","DEPTH":"0","ID":"0","IO_COST":"","OPERATION":"SELECT STATEMENT","OPTIONS":"FULL","PARENT_ID":"","POSITION":"1","PROJECTION":""}]'

receiver/oracledbreceiver/testdata/expectedSamplesFile.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ resourceLogs:
4343
- key: oracledb.child_number
4444
value:
4545
stringValue: "0"
46+
- key: oracledb.child_address
47+
value:
48+
stringValue: "SDF3SDF1234D"
4649
- key: oracledb.sid
4750
value:
4851
stringValue: "675"

0 commit comments

Comments
 (0)