Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
"repository": "open-telemetry/opentelemetry-js-contrib",
"scripts": {
"docker:start": "docker run -e MONGODB_DB=opentelemetry-tests -e MONGODB_PORT=27017 -e MONGODB_HOST=127.0.0.1 -p 27017:27017 --rm mongo",
"test": "npm run test-v5-v6",
"test-v3": "nyc mocha --require '@opentelemetry/contrib-test-utils' 'test/**/mongodb-v3.test.ts'",
"test-v4": "nyc mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v4.test.ts'",
"test-v5-v6": "nyc mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v5-v6.test.ts'",
"test": "npm run test-v3 && npm run test-v4 && npm run test-v5-v6 && nyc merge .nyc_output ./coverage/coverage-final.json",
"test-v3": "tav mongodb 3.7.4 npm run test-v3-run",
"test-v4": "tav mongodb 4.17.0 npm run test-v4-run",
"test-v5-v6": "tav mongodb 6.8.0 npm run test-v5-v6-run",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think is necessary to pin here the version? pacakge.json file already has the version fixed and if we want to update to a newer version we need to do it in both places.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just double checked, for the pinned version, it's not needed. 👍

"test-v3-run": "nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/**/mongodb-v3.test.ts'",
"test-v4-run": "nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v4.test.ts'",
"test-v5-v6-run": "nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v5-v6.test.ts'",
"test-all-versions": "tav",
"tdd": "npm run test -- --watch-extensions ts --watch",
"tdd": "npm run test-v5-v6-run -- --watch-extensions ts --watch",
"clean": "rimraf build/*",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ import {
SEMATTRS_NET_PEER_PORT,
} from '@opentelemetry/semantic-conventions';

// We can't use @ts-expect-error because it will fail depending on the used mongodb version on tests
/* eslint-disable @typescript-eslint/ban-ts-comment */

describe('MongoDBInstrumentation-Tracing-v3', () => {
function create(config: MongoDBInstrumentationConfig = {}) {
instrumentation.setConfig(config);
Expand Down Expand Up @@ -85,7 +88,7 @@ describe('MongoDBInstrumentation-Tracing-v3', () => {
}
// Non traced insertion of basic data to perform tests
const insertData = [{ a: 1 }, { a: 2 }, { a: 3 }];
// @ts-expect-error -- v5 removed callback support
// @ts-ignore -- v5 removed callback support
collection.insertMany(insertData, (err: any, result: any) => {
resetMemoryExporter();
done();
Expand All @@ -94,7 +97,7 @@ describe('MongoDBInstrumentation-Tracing-v3', () => {

afterEach(done => {
if (shouldTest) {
// @ts-expect-error -- v5 removed callback support
// @ts-ignore -- v5 removed callback support
collection.deleteMany({}, done);
} else {
done();
Expand Down Expand Up @@ -619,7 +622,6 @@ describe('MongoDBInstrumentation-Tracing-v3', () => {
let collection: Collection;
before(done => {
accessCollection(URL, DB_NAME, COLLECTION_NAME, {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
useUnifiedTopology: true,
})
Expand All @@ -642,7 +644,7 @@ describe('MongoDBInstrumentation-Tracing-v3', () => {
it('should generate correct span attributes', done => {
const span = trace.getTracer('default').startSpan('findRootSpan');
context.with(trace.setSpan(context.active(), span), () => {
// @ts-expect-error -- v5 removed callback support
// @ts-ignore -- v5 removed callback support
collection.find({ a: 1 }).toArray((err, results) => {
span.end();
const [mongoSpan] = getTestSpans();
Expand Down Expand Up @@ -723,3 +725,5 @@ describe('MongoDBInstrumentation-Tracing-v3', () => {
});
});
});

/* eslint-enable @typescript-eslint/ban-ts-comment */
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import type { MongoClient, Collection } from 'mongodb';
import { assertSpans, accessCollection, DEFAULT_MONGO_HOST } from './utils';
import { SEMATTRS_DB_STATEMENT } from '@opentelemetry/semantic-conventions';

// We can't use @ts-expect-error because it will fail depending on the used mongodb version on tests
/* eslint-disable @typescript-eslint/ban-ts-comment */

describe('MongoDBInstrumentation-Tracing-v4', () => {
function create(config: MongoDBInstrumentationConfig = {}) {
instrumentation.setConfig(config);
Expand Down Expand Up @@ -82,7 +85,7 @@ describe('MongoDBInstrumentation-Tracing-v4', () => {
}
// Non traced insertion of basic data to perform tests
const insertData = [{ a: 1 }, { a: 2 }, { a: 3 }];
// @ts-expect-error -- v5 removed callback support
// @ts-ignore -- v5 removed callback support
collection.insertMany(insertData, (err: any, result: any) => {
resetMemoryExporter();
done();
Expand All @@ -91,7 +94,7 @@ describe('MongoDBInstrumentation-Tracing-v4', () => {

afterEach(done => {
if (shouldTest) {
// @ts-expect-error -- v5 removed callback support
// @ts-ignore -- v5 removed callback support
collection.deleteMany({}, done);
} else {
done();
Expand Down Expand Up @@ -693,3 +696,5 @@ describe('MongoDBInstrumentation-Tracing-v4', () => {
});
});
});

/* eslint-enable @typescript-eslint/ban-ts-comment */
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ import type { MongoClient, Collection } from 'mongodb';
import { assertSpans, accessCollection, DEFAULT_MONGO_HOST } from './utils';
import { SEMATTRS_DB_STATEMENT } from '@opentelemetry/semantic-conventions';

// We can't use @ts-expect-error because it will fail depending on the used mongodb version on tests
/* eslint-disable @typescript-eslint/ban-ts-comment */

describe('MongoDBInstrumentation-Tracing-v5', () => {
function create(config: MongoDBInstrumentationConfig = {}) {
instrumentation.setConfig(config);
Expand Down Expand Up @@ -706,3 +709,5 @@ describe('MongoDBInstrumentation-Tracing-v5', () => {
});
});
});

/* eslint-enable @typescript-eslint/ban-ts-comment */
Loading