Skip to content

Commit 59b934b

Browse files
committed
chore(instrumentation-mysql2): Simplify the process of terminating a poolCluster
1 parent 010b96d commit 59b934b

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import * as semver from 'semver';
1817
import { context, trace, SpanStatusCode } from '@opentelemetry/api';
1918
import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks';
2019
import {
@@ -34,12 +33,8 @@ import {
3433
SimpleSpanProcessor,
3534
} from '@opentelemetry/sdk-trace-base';
3635
import * as assert from 'assert';
37-
import {
38-
MySQL2Instrumentation,
39-
MySQL2InstrumentationConfig,
40-
} from '../src';
36+
import { MySQL2Instrumentation, MySQL2InstrumentationConfig } from '../src';
4137

42-
const LIB_VERSION = testUtils.getPackageVersion('mysql2');
4338
const port = Number(process.env.MYSQL_PORT) || 33306;
4439
const database = process.env.MYSQL_DATABASE || 'test_db';
4540
const host = process.env.MYSQL_HOST || '127.0.0.1';
@@ -158,11 +153,7 @@ describe('mysql2/promise', () => {
158153
instrumentation.disable();
159154
await connection.end();
160155
await pool.end();
161-
if (isPoolClusterEndIgnoreCallback()) {
162-
await poolCluster.end();
163-
} else {
164-
await poolCluster.end();
165-
}
156+
await poolCluster.end();
166157
});
167158

168159
describe('when the query is a string', () => {
@@ -972,9 +963,3 @@ function assertSpan(
972963
assert.strictEqual(span.status.code, SpanStatusCode.ERROR);
973964
}
974965
}
975-
976-
function isPoolClusterEndIgnoreCallback() {
977-
// Since v2.2.0 `end` function respect callback
978-
// https://github.com/sidorares/node-mysql2/commit/1481015626e506754adc4308e5508356a3a03aa0
979-
return semver.lt(LIB_VERSION, '2.2.0');
980-
}

0 commit comments

Comments
 (0)