Skip to content

Commit 6e22fd5

Browse files
authored
chore(plugin-mongodb-core): add missing codecov script (open-telemetry#601)
* chore(plugin-mongodb-core): add missing codecov script * fix(mongodb-plugin): check currentSpan against undefined * chore(scope-managers): return undefined if no scope is found (following open-telemetry#569)
1 parent 54879ab commit 6e22fd5

6 files changed

Lines changed: 20 additions & 11 deletions

File tree

packages/opentelemetry-plugin-mongodb-core/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"repository": "open-telemetry/opentelemetry-js",
99
"scripts": {
1010
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
11+
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
1112
"tdd": "yarn test -- --watch-extensions ts --watch",
1213
"clean": "rimraf build/*",
1314
"check": "gts check",
@@ -40,8 +41,8 @@
4041
"access": "public"
4142
},
4243
"devDependencies": {
43-
"@opentelemetry/node": "^0.1.1",
44-
"@opentelemetry/tracing": "^0.1.1",
44+
"@opentelemetry/node": "^0.2.0",
45+
"@opentelemetry/tracing": "^0.2.0",
4546
"@types/mocha": "^5.2.7",
4647
"@types/mongodb": "^3.2.3",
4748
"@types/node": "^12.7.2",

packages/opentelemetry-plugin-mongodb-core/src/mongodb.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class MongoDBCorePlugin extends BasePlugin<typeof mongodb> {
106106
const resultHandler =
107107
typeof options === 'function' ? options : callback;
108108
if (
109-
currentSpan === null ||
109+
currentSpan === undefined ||
110110
typeof resultHandler !== 'function' ||
111111
typeof commands !== 'object'
112112
) {
@@ -208,7 +208,7 @@ export class MongoDBCorePlugin extends BasePlugin<typeof mongodb> {
208208
): mongodb.Cursor {
209209
const currentSpan = plugin._tracer.getCurrentSpan();
210210
const resultHandler = args[0];
211-
if (currentSpan === null || typeof resultHandler !== 'function') {
211+
if (currentSpan === undefined || typeof resultHandler !== 'function') {
212212
return original.apply(this, args);
213213
}
214214
const span = plugin._tracer.startSpan(`mongodb.query`, {

packages/opentelemetry-scope-async-hooks/src/AsyncHooksScopeManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class AsyncHooksScopeManager implements ScopeManager {
5050
}
5151

5252
active(): unknown {
53-
return this._scopes[asyncHooks.executionAsyncId()] || null;
53+
return this._scopes[asyncHooks.executionAsyncId()] || undefined;
5454
}
5555

5656
with<T extends (...args: unknown[]) => ReturnType<T>>(

packages/opentelemetry-scope-async-hooks/test/AsyncHooksScopeManager.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ describe('AsyncHooksScopeManager', () => {
135135
setTimeout(() => {
136136
assert.strictEqual(
137137
scopeManager.active(),
138-
null,
138+
undefined,
139139
'should have no scope'
140140
);
141141
return done();
@@ -228,7 +228,7 @@ describe('AsyncHooksScopeManager', () => {
228228
const patchedEe = scopeManager.bind(ee, scope);
229229
const handler = () => {
230230
setImmediate(() => {
231-
assert.deepStrictEqual(scopeManager.active(), null);
231+
assert.deepStrictEqual(scopeManager.active(), undefined);
232232
patchedEe.removeAllListeners('test');
233233
assert.strictEqual(patchedEe.listeners('test').length, 0);
234234
return done();

packages/opentelemetry-scope-base/src/NoopScopeManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import * as types from './types';
1818

1919
export class NoopScopeManager implements types.ScopeManager {
2020
active(): unknown {
21-
return null;
21+
return undefined;
2222
}
2323

2424
with<T extends (...args: unknown[]) => ReturnType<T>>(

packages/opentelemetry-scope-base/test/NoopScopeManager.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('NoopScopeManager', () => {
4848
scopeManager.with(test, () => {
4949
assert.strictEqual(
5050
scopeManager.active(),
51-
null,
51+
undefined,
5252
'should not have scope'
5353
);
5454
return done();
@@ -66,12 +66,20 @@ describe('NoopScopeManager', () => {
6666

6767
describe('.active()', () => {
6868
it('should always return null (when enabled)', () => {
69-
assert.strictEqual(scopeManager.active(), null, 'should not have scope');
69+
assert.strictEqual(
70+
scopeManager.active(),
71+
undefined,
72+
'should not have scope'
73+
);
7074
});
7175

7276
it('should always return null (when disabled)', () => {
7377
scopeManager.disable();
74-
assert.strictEqual(scopeManager.active(), null, 'should not have scope');
78+
assert.strictEqual(
79+
scopeManager.active(),
80+
undefined,
81+
'should not have scope'
82+
);
7583
scopeManager.enable();
7684
});
7785
});

0 commit comments

Comments
 (0)