Skip to content

Commit 58587ce

Browse files
sincejunedd-jasminesun
authored andcommitted
[chore][receiver/sqlserver] Update obfuscation library to use mssql mode (open-telemetry#40525)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This will be helpful for decreasing obfuscation failures in SQL Server receiver.
1 parent 1a3b7e8 commit 58587ce

File tree

7 files changed

+34
-7
lines changed

7 files changed

+34
-7
lines changed
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: sqlserverreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Update obfuscation library to use `mssql` mode.
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: [40525]
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: Now it can obfuscate more SQL Server specific queries which may not work before.
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/sqlserverreceiver/obfuscate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func lazyInitObfuscator() *obfuscate.Obfuscator {
3333

3434
// ObfuscateSQL obfuscates & normalizes the provided SQL query, writing the error into errResult if the operation fails.
3535
func obfuscateSQL(rawQuery string) (string, error) {
36-
obfuscatedQuery, err := lazyInitObfuscator().ObfuscateSQLStringWithOptions(rawQuery, &obfuscate.SQLConfig{})
36+
obfuscatedQuery, err := lazyInitObfuscator().ObfuscateSQLStringWithOptions(rawQuery, &obfuscate.SQLConfig{DBMS: "mssql"})
3737
if err != nil {
3838
return "", err
3939
}

receiver/sqlserverreceiver/obfuscate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestObfuscateSQL(t *testing.T) {
2626
}
2727

2828
func TestObfuscateInvalidSQL(t *testing.T) {
29-
sql := "SELECT cpu_time AS [CPU Usage (time)]"
29+
sql := "SELECT cpu_time AS [CPU Usage (time)"
3030
result, err := obfuscateSQL(sql)
3131

3232
assert.Error(t, err)

receiver/sqlserverreceiver/testdata/expectedQueryPlan.xml

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

receiver/sqlserverreceiver/testdata/expectedQueryTextAndPlanQuery.yaml

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

receiver/sqlserverreceiver/testdata/queryTextAndPlanQueryInvalidData.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"total_logical_writes": "4A",
1414
"total_rows": "2A",
1515
"total_grant_kb": "3096A",
16-
"query_text": "SELECT cpu_time AS [CPU Usage (time)]",
16+
"query_text": "SELECT cpu_time AS [CPU Usage (time)",
1717
"query_plan": "<ShowPlanXML"
1818
}
1919
]

receiver/sqlserverreceiver/testdata/recordInvalidDatabaseSampleQueryData.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"request_status": "running",
1212
"host_name": "DESKTOP-GHAEGRD",
1313
"command": "SELECT",
14-
"statement_text": "SELECT cpu_time AS [CPU Usage (time)]",
14+
"statement_text": "SELECT cpu_time AS [CPU Usage (time)",
1515
"blocking_session_id": "a0",
1616
"wait_type": "",
1717
"wait_time": "a0",

0 commit comments

Comments
 (0)