@@ -32,7 +32,7 @@ export class Tracing implements core.Tracing {
3232 /** Plugin names */
3333 private defaultPlugins : core . PluginNames ;
3434 /** A configuration object to start the tracing */
35- private configLocal : core . Config = null ;
35+ private configLocal : core . Config = { } ;
3636 /** An object to log information to */
3737 private logger : core . Logger = null ;
3838 /** Singleton instance */
@@ -94,31 +94,29 @@ export class Tracing implements core.Tracing {
9494 this . activeLocal = false ;
9595 this . tracer . stop ( ) ;
9696 this . pluginLoader . unloadPlugins ( ) ;
97- this . configLocal = null ;
97+ this . configLocal = { } ;
9898 this . logger = null ;
9999 }
100100
101101
102102 /** Gets the exporter. */
103103 get exporter ( ) : core . Exporter {
104- return this . configLocal ? this . configLocal . exporter as core . Exporter : null ;
104+ return this . configLocal . exporter ?
105+ this . configLocal . exporter as core . Exporter :
106+ null ;
105107 }
106108
107109 /**
108110 * Registers an exporter to send the collected traces to.
109111 * @param exporter The exporter to send the traces to.
110112 */
111113 registerExporter ( exporter : core . Exporter ) : core . Tracing {
114+ if ( this . configLocal . exporter ) {
115+ this . unregisterExporter ( this . configLocal . exporter ) ;
116+ }
112117 if ( exporter ) {
113- if ( this . configLocal . exporter ) {
114- this . unregisterExporter ( this . configLocal . exporter ) ;
115- }
116118 this . configLocal . exporter = exporter ;
117119 this . tracer . registerSpanEventListener ( exporter ) ;
118- } else {
119- if ( this . configLocal . exporter ) {
120- this . unregisterExporter ( this . configLocal . exporter ) ;
121- }
122120 }
123121 return this ;
124122 }
0 commit comments