diff --git a/packages/opentelemetry-plugin-mongodb-core/package.json b/packages/opentelemetry-plugin-mongodb-core/package.json index f54d725add..6744a3c994 100644 --- a/packages/opentelemetry-plugin-mongodb-core/package.json +++ b/packages/opentelemetry-plugin-mongodb-core/package.json @@ -8,6 +8,7 @@ "repository": "open-telemetry/opentelemetry-js", "scripts": { "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'", + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "tdd": "yarn test -- --watch-extensions ts --watch", "clean": "rimraf build/*", "check": "gts check", @@ -40,8 +41,8 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/node": "^0.1.1", - "@opentelemetry/tracing": "^0.1.1", + "@opentelemetry/node": "^0.2.0", + "@opentelemetry/tracing": "^0.2.0", "@types/mocha": "^5.2.7", "@types/mongodb": "^3.2.3", "@types/node": "^12.7.2", diff --git a/packages/opentelemetry-plugin-mongodb-core/src/mongodb.ts b/packages/opentelemetry-plugin-mongodb-core/src/mongodb.ts index 7300556e1f..0c2afbbf3f 100644 --- a/packages/opentelemetry-plugin-mongodb-core/src/mongodb.ts +++ b/packages/opentelemetry-plugin-mongodb-core/src/mongodb.ts @@ -106,7 +106,7 @@ export class MongoDBCorePlugin extends BasePlugin { const resultHandler = typeof options === 'function' ? options : callback; if ( - currentSpan === null || + currentSpan === undefined || typeof resultHandler !== 'function' || typeof commands !== 'object' ) { @@ -208,7 +208,7 @@ export class MongoDBCorePlugin extends BasePlugin { ): mongodb.Cursor { const currentSpan = plugin._tracer.getCurrentSpan(); const resultHandler = args[0]; - if (currentSpan === null || typeof resultHandler !== 'function') { + if (currentSpan === undefined || typeof resultHandler !== 'function') { return original.apply(this, args); } const span = plugin._tracer.startSpan(`mongodb.query`, { diff --git a/packages/opentelemetry-scope-async-hooks/src/AsyncHooksScopeManager.ts b/packages/opentelemetry-scope-async-hooks/src/AsyncHooksScopeManager.ts index a8a5b1f13d..f3f4ee7f78 100644 --- a/packages/opentelemetry-scope-async-hooks/src/AsyncHooksScopeManager.ts +++ b/packages/opentelemetry-scope-async-hooks/src/AsyncHooksScopeManager.ts @@ -50,7 +50,7 @@ export class AsyncHooksScopeManager implements ScopeManager { } active(): unknown { - return this._scopes[asyncHooks.executionAsyncId()] || null; + return this._scopes[asyncHooks.executionAsyncId()] || undefined; } with ReturnType>( diff --git a/packages/opentelemetry-scope-async-hooks/test/AsyncHooksScopeManager.test.ts b/packages/opentelemetry-scope-async-hooks/test/AsyncHooksScopeManager.test.ts index fa6d85cef8..c5333786f4 100644 --- a/packages/opentelemetry-scope-async-hooks/test/AsyncHooksScopeManager.test.ts +++ b/packages/opentelemetry-scope-async-hooks/test/AsyncHooksScopeManager.test.ts @@ -135,7 +135,7 @@ describe('AsyncHooksScopeManager', () => { setTimeout(() => { assert.strictEqual( scopeManager.active(), - null, + undefined, 'should have no scope' ); return done(); @@ -228,7 +228,7 @@ describe('AsyncHooksScopeManager', () => { const patchedEe = scopeManager.bind(ee, scope); const handler = () => { setImmediate(() => { - assert.deepStrictEqual(scopeManager.active(), null); + assert.deepStrictEqual(scopeManager.active(), undefined); patchedEe.removeAllListeners('test'); assert.strictEqual(patchedEe.listeners('test').length, 0); return done(); diff --git a/packages/opentelemetry-scope-base/src/NoopScopeManager.ts b/packages/opentelemetry-scope-base/src/NoopScopeManager.ts index 348e84cd50..ac32db311f 100644 --- a/packages/opentelemetry-scope-base/src/NoopScopeManager.ts +++ b/packages/opentelemetry-scope-base/src/NoopScopeManager.ts @@ -18,7 +18,7 @@ import * as types from './types'; export class NoopScopeManager implements types.ScopeManager { active(): unknown { - return null; + return undefined; } with ReturnType>( diff --git a/packages/opentelemetry-scope-base/test/NoopScopeManager.test.ts b/packages/opentelemetry-scope-base/test/NoopScopeManager.test.ts index 735a578cfc..4767f5793f 100644 --- a/packages/opentelemetry-scope-base/test/NoopScopeManager.test.ts +++ b/packages/opentelemetry-scope-base/test/NoopScopeManager.test.ts @@ -48,7 +48,7 @@ describe('NoopScopeManager', () => { scopeManager.with(test, () => { assert.strictEqual( scopeManager.active(), - null, + undefined, 'should not have scope' ); return done(); @@ -66,12 +66,20 @@ describe('NoopScopeManager', () => { describe('.active()', () => { it('should always return null (when enabled)', () => { - assert.strictEqual(scopeManager.active(), null, 'should not have scope'); + assert.strictEqual( + scopeManager.active(), + undefined, + 'should not have scope' + ); }); it('should always return null (when disabled)', () => { scopeManager.disable(); - assert.strictEqual(scopeManager.active(), null, 'should not have scope'); + assert.strictEqual( + scopeManager.active(), + undefined, + 'should not have scope' + ); scopeManager.enable(); }); });