From 6cf79ef81a9f569a0cb65bbc59bb73e517ebbb7b Mon Sep 17 00:00:00 2001 From: Michele Azzolari Date: Sat, 7 Dec 2024 17:41:21 +0100 Subject: [PATCH] fixup! fix(instrumentation-mysql2)!: do not include parameterized values to db.statement span attribute (#1758) --- .../src/instrumentation.ts | 14 ++++++++++--- .../test/mysql.test.ts | 21 +++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts index ef5562b115..6a80fd5983 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts @@ -154,8 +154,16 @@ export class MySQL2Instrumentation extends InstrumentationBase { }); }); + it('should intercept pool.query(text: options, callback, null)', done => { + const span = provider.getTracer('default').startSpan('test span'); + context.with(trace.setSpan(context.active(), span), () => { + const sql = 'SELECT 1+1 as solution'; + // @ts-ignore + pool.query( + { sql }, + (err, res: mysqlTypes.RowDataPacket[]) => { + assert.ifError(err); + assert.ok(res); + assert.strictEqual(res[0].solution, 2); + const spans = memoryExporter.getFinishedSpans(); + assert.strictEqual(spans.length, 1); + assertSpan(spans[0], sql); + done(); + }, + null + ); + }); + }); + it('should intercept pool.query(text: string, values: [], callback)', done => { const span = provider.getTracer('default').startSpan('test span'); context.with(trace.setSpan(context.active(), span), () => {