Skip to content

Commit 963c343

Browse files
committed
change mask default to false
1 parent f47d8d4 commit 963c343

File tree

4 files changed

+4
-15
lines changed

4 files changed

+4
-15
lines changed

packages/instrumentation-mysql2/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ You can set the following instrumentation options:
4848
| ------- | ---- | ----------- |
4949
| `responseHook` | `MySQL2InstrumentationExecutionResponseHook` (function) | Function for adding custom attributes from db response |
5050
| `addSqlCommenterCommentToQueries` | `boolean` | If true, adds [sqlcommenter](https://github.com/open-telemetry/opentelemetry-sqlcommenter) specification compliant comment to queries with tracing context (default false). _NOTE: A comment will not be added to queries that already contain `--` or `/* ... */` in them, even if these are not actually part of comments_ |
51-
| `maskStatement` | `boolean` | If true, masks the `db.statement` attribute in spans (default true) with the `maskStatementHook` |
51+
| `maskStatement` | `boolean` | If true, masks the `db.statement` attribute in spans (default false) with the `maskStatementHook` |
5252
| `maskStatementHook` | `MySQL2InstrumentationMaskStatementHook` (function) | Function for masking the `db.statement` attribute in spans Default: `return query.replace(/\b\d+\b/g, '?').replac(/(["'])(?:(?=(\\?))\2.)*?\1/g, '?');`|
5353

5454

packages/instrumentation-mysql2/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface MySQL2InstrumentationConfig extends InstrumentationConfig {
3333
/**
3434
* If true, the query will be masked before setting it as a span attribute, using the {@link maskStatementHook}.
3535
*
36-
* @default true
36+
* @default false
3737
* @see maskStatementHook
3838
*/
3939
maskStatement?: boolean;

packages/instrumentation-mysql2/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export function getDbStatement(
109109
query: string | Query | QueryOptions,
110110
format?: formatType,
111111
values?: any[],
112-
maskStatement = true,
112+
maskStatement = false,
113113
maskStatementHook: MySQL2InstrumentationQueryMaskingHook = defaultMaskingHook
114114
): string {
115115
const [querySql, queryValues] =

packages/instrumentation-mysql2/test/mysql.test.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ describe('mysql2', () => {
156156
contextManager = new AsyncLocalStorageContextManager().enable();
157157
context.setGlobalContextManager(contextManager);
158158
instrumentation.setTracerProvider(provider);
159-
instrumentation.setConfig({
160-
maskStatement: false,
161-
});
162159
instrumentation.enable();
163160
connection = createConnection({
164161
port,
@@ -1131,7 +1128,6 @@ describe('mysql2', () => {
11311128
responseHook: (span, responseHookInfo) => {
11321129
throw new Error('random failure!');
11331130
},
1134-
maskStatement: false,
11351131
};
11361132
instrumentation.setConfig(config);
11371133
});
@@ -1159,7 +1155,6 @@ describe('mysql2', () => {
11591155
JSON.stringify(responseHookInfo.queryResults)
11601156
);
11611157
},
1162-
maskStatement: false,
11631158
};
11641159
instrumentation.setConfig(config);
11651160
});
@@ -1389,10 +1384,7 @@ describe('mysql2', () => {
13891384
});
13901385
});
13911386
});
1392-
it('should not mask query if maskStatement is false', done => {
1393-
instrumentation.setConfig({
1394-
maskStatement: false,
1395-
});
1387+
it('should not mask query if maskStatement is false (default)', done => {
13961388
const query = 'SELECT 1+1 as solution';
13971389
const span = provider.getTracer('default').startSpan('test span');
13981390
context.with(trace.setSpan(context.active(), span), () => {
@@ -1499,9 +1491,6 @@ describe('mysql2', () => {
14991491
contextManager = new AsyncLocalStorageContextManager().enable();
15001492
context.setGlobalContextManager(contextManager);
15011493
instrumentation.setTracerProvider(provider);
1502-
instrumentation.setConfig({
1503-
maskStatement: false,
1504-
});
15051494
instrumentation.enable();
15061495
connection = await createConnection({
15071496
port,

0 commit comments

Comments
 (0)