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

Commit

Permalink
opencensus-nodejs: Enforce strictNullChecks (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 authored Mar 15, 2019
1 parent fa110c4 commit d017e2f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
8 changes: 4 additions & 4 deletions packages/opencensus-nodejs/src/trace/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class Tracing implements core.Tracing {
/** A tracer object */
readonly tracer: core.Tracer;
/** A plugin loader object */
private pluginLoader: PluginLoader;
private pluginLoader?: PluginLoader;
/** Plugin names */
private defaultPlugins: core.PluginNames;
/** A configuration object to start the tracing */
Expand Down Expand Up @@ -92,12 +92,13 @@ export class Tracing implements core.Tracing {
stop() {
this.activeLocal = false;
this.tracer.stop();
this.pluginLoader.unloadPlugins();
if (this.pluginLoader) {
this.pluginLoader.unloadPlugins();
}
this.configLocal = {};
this.logger = logger.logger();
}


/** Gets the exporter. */
get exporter(): core.Exporter {
return this.configLocal.exporter ?
Expand All @@ -120,7 +121,6 @@ export class Tracing implements core.Tracing {
return this;
}


/**
* Unregisters an exporter.
* @param exporter The exporter to stop sending traces to.
Expand Down
17 changes: 0 additions & 17 deletions packages/opencensus-nodejs/test/test-tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/


import * as core from '@opencensus/core';
import {logger} from '@opencensus/core';
import * as assert from 'assert';

import {defaultConfig} from '../src/trace/config/default-config';
import {Constants} from '../src/trace/constants';
import {Tracing} from '../src/trace/tracing';



const NOOP_EXPORTER = new core.NoopExporter();
describe('Tracing', () => {
Constants.DEFAULT_INSTRUMENTATION_MODULES = ['http', 'https'];
Expand Down Expand Up @@ -278,18 +273,6 @@ describe('Tracing', () => {
assert.strictEqual(tracing.config.exporter, newExporter);
assert.strictEqual(tracing.tracer.eventListeners.length, 1);
});

it('should register a null to unRegister', () => {
const tracing = new Tracing();
tracing.start();
const exporter = NOOP_EXPORTER;
tracing.registerExporter(exporter);
assert.strictEqual(tracing.config.exporter, exporter);
assert.strictEqual(tracing.tracer.eventListeners.length, 1);
tracing.registerExporter(null);
assert.ok(tracing.config.exporter instanceof core.NoopExporter);
assert.strictEqual(tracing.tracer.eventListeners.length, 0);
});
});

/** Should unregister the exporter instance */
Expand Down
2 changes: 1 addition & 1 deletion packages/opencensus-nodejs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"pretty": true,
"module": "commonjs",
"target": "es6",
"strictNullChecks": false,
"strictNullChecks": true,
"noUnusedLocals": true,
"sourceMap": false
},
Expand Down

0 comments on commit d017e2f

Please sign in to comment.