Skip to content

Commit 01367e5

Browse files
chore: test updated
1 parent fc8c071 commit 01367e5

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

packages/instrumentation-mongodb/test/mongodb-v4-v5-v6.metrics.test.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,10 @@ const otelTestingMeterProvider = new MeterProvider({
4040
readers: [metricReader],
4141
});
4242

43-
import {
44-
getInstrumentation,
45-
registerInstrumentationTesting,
46-
} from '@opentelemetry/contrib-test-utils';
47-
48-
// Get instrumentation (singleton)
49-
let instrumentation: MongoDBInstrumentation;
50-
{
51-
const instance: MongoDBInstrumentation | undefined = getInstrumentation();
52-
if (!instance) {
53-
instrumentation = new MongoDBInstrumentation();
54-
registerInstrumentationTesting(instrumentation);
55-
} else {
56-
instrumentation = instance;
57-
}
58-
}
43+
import { registerInstrumentationTesting } from '@opentelemetry/contrib-test-utils';
44+
const instrumentation = registerInstrumentationTesting(
45+
new MongoDBInstrumentation()
46+
);
5947

6048
import { accessCollection, DEFAULT_MONGO_HOST } from './utils';
6149
import type { MongoClient, Collection } from 'mongodb';

packages/instrumentation-mongodb/test/mongodb-v7.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import {
3030
resetMemoryExporter,
3131
} from '@opentelemetry/contrib-test-utils';
3232

33+
import * as semver from 'semver';
34+
3335
// Get instrumentation (singleton)
3436
let instrumentation: MongoDBInstrumentation;
3537
{
@@ -59,6 +61,13 @@ describe('MongoDBInstrumentation-Tracing-v7', () => {
5961
shouldTest = false;
6062
}
6163

64+
if (!semver.satisfies(process.version, '>=20.19.0')) {
65+
console.log(
66+
`Skipping mongodb v7 tests. Node.js ${process.version} does not meet minimum requirement of >=20.19.0`
67+
);
68+
shouldTest = false;
69+
}
70+
6271
const HOST = process.env.MONGODB_HOST || DEFAULT_MONGO_HOST;
6372
const PORT = process.env.MONGODB_PORT || 27017;
6473
const DB_NAME = process.env.MONGODB_DB || 'opentelemetry-tests-traces';

0 commit comments

Comments
 (0)