Skip to content

Commit 1f82b74

Browse files
macnopichlermarc
andcommitted
Update plugins/node/opentelemetry-instrumentation-mysql2/test/mysql.test.ts
Co-authored-by: Marc Pichler <[email protected]>
1 parent b9093ae commit 1f82b74

File tree

1 file changed

+7
-4
lines changed
  • plugins/node/opentelemetry-instrumentation-mysql2/test

1 file changed

+7
-4
lines changed

plugins/node/opentelemetry-instrumentation-mysql2/test/mysql.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,15 +1242,19 @@ describe('mysql2', () => {
12421242
let instrumentation: MySQL2Instrumentation;
12431243

12441244
let contextManager: AsyncHooksContextManager;
1245-
const provider = new BasicTracerProvider();
12461245
const memoryExporter = new InMemorySpanExporter();
1247-
1246+
const provider = new BasicTracerProvider({
1247+
spanProcessors: [new SimpleSpanProcessor(memoryExporter)],
1248+
});
12481249
let connection: mysqlTypesProm.Connection;
12491250
let rootConnection: mysqlTypesProm.Connection;
12501251
let mysqlTypesPromReload: typeof mysqlTypesProm;
12511252

12521253
before(async function () {
1253-
// cleanup cache for mysql2
1254+
// cleanup cache for 'mysql2'
1255+
// in previous iterations these tests would have passed since 'mysql2' was already loaded,
1256+
// but 'mysql2/promise' does not import 'mysql2'. Therefore, if used without ever loading 'mysql2',
1257+
// the relevant code would never get patched.
12541258
delete require.cache[require.resolve('../src')];
12551259
Object.keys(require.cache).forEach(key => {
12561260
if (key.includes('mysql2/')) {
@@ -1271,7 +1275,6 @@ describe('mysql2', () => {
12711275
this.test!.parent!.pending = true;
12721276
this.skip();
12731277
}
1274-
provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter));
12751278
rootConnection = await mysqlTypesPromReload.createConnection({
12761279
port,
12771280
user: 'root',

0 commit comments

Comments
 (0)