Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit d017e2f

Browse files
authored
opencensus-nodejs: Enforce strictNullChecks (#426)
1 parent fa110c4 commit d017e2f

3 files changed

Lines changed: 5 additions & 22 deletions

File tree

packages/opencensus-nodejs/src/trace/tracing.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class Tracing implements core.Tracing {
2727
/** A tracer object */
2828
readonly tracer: core.Tracer;
2929
/** A plugin loader object */
30-
private pluginLoader: PluginLoader;
30+
private pluginLoader?: PluginLoader;
3131
/** Plugin names */
3232
private defaultPlugins: core.PluginNames;
3333
/** A configuration object to start the tracing */
@@ -92,12 +92,13 @@ export class Tracing implements core.Tracing {
9292
stop() {
9393
this.activeLocal = false;
9494
this.tracer.stop();
95-
this.pluginLoader.unloadPlugins();
95+
if (this.pluginLoader) {
96+
this.pluginLoader.unloadPlugins();
97+
}
9698
this.configLocal = {};
9799
this.logger = logger.logger();
98100
}
99101

100-
101102
/** Gets the exporter. */
102103
get exporter(): core.Exporter {
103104
return this.configLocal.exporter ?
@@ -120,7 +121,6 @@ export class Tracing implements core.Tracing {
120121
return this;
121122
}
122123

123-
124124
/**
125125
* Unregisters an exporter.
126126
* @param exporter The exporter to stop sending traces to.

packages/opencensus-nodejs/test/test-tracing.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
17-
1816
import * as core from '@opencensus/core';
1917
import {logger} from '@opencensus/core';
2018
import * as assert from 'assert';
21-
2219
import {defaultConfig} from '../src/trace/config/default-config';
2320
import {Constants} from '../src/trace/constants';
2421
import {Tracing} from '../src/trace/tracing';
2522

26-
27-
2823
const NOOP_EXPORTER = new core.NoopExporter();
2924
describe('Tracing', () => {
3025
Constants.DEFAULT_INSTRUMENTATION_MODULES = ['http', 'https'];
@@ -278,18 +273,6 @@ describe('Tracing', () => {
278273
assert.strictEqual(tracing.config.exporter, newExporter);
279274
assert.strictEqual(tracing.tracer.eventListeners.length, 1);
280275
});
281-
282-
it('should register a null to unRegister', () => {
283-
const tracing = new Tracing();
284-
tracing.start();
285-
const exporter = NOOP_EXPORTER;
286-
tracing.registerExporter(exporter);
287-
assert.strictEqual(tracing.config.exporter, exporter);
288-
assert.strictEqual(tracing.tracer.eventListeners.length, 1);
289-
tracing.registerExporter(null);
290-
assert.ok(tracing.config.exporter instanceof core.NoopExporter);
291-
assert.strictEqual(tracing.tracer.eventListeners.length, 0);
292-
});
293276
});
294277

295278
/** Should unregister the exporter instance */

packages/opencensus-nodejs/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"pretty": true,
77
"module": "commonjs",
88
"target": "es6",
9-
"strictNullChecks": false,
9+
"strictNullChecks": true,
1010
"noUnusedLocals": true,
1111
"sourceMap": false
1212
},

0 commit comments

Comments
 (0)