1414 * limitations under the License.
1515 */
1616
17- import * as cls from '../../internal/cls' ;
17+ import * as cls from '../../internal/cls'
1818import { Trace } from './trace'
1919import { Span } from './span'
2020import { debug } from '../../internal/util'
2121import { Stackdriver } from '../../exporters/stackdriver/stackdriver'
2222import { StackdriverOptions } from '../../exporters/stackdriver/options'
23- import { Exporter } from '../../exporters/exporter' ;
23+ import { Exporter } from '../../exporters/exporter'
2424
2525export type Func < T > = ( ...args : any [ ] ) => T ;
2626
2727export class Tracer {
2828
29- readonly PLUGINS = [ 'http' , 'https' , 'mongodb-core' , 'express' ]
29+ readonly PLUGINS = [ 'http' , 'https' , 'mongodb-core' , 'express' ] ;
3030
3131 private _active : boolean ;
3232 private contextManager : cls . Namespace ;
@@ -35,10 +35,9 @@ export class Tracer {
3535 //TODO: temp solution
3636 private endedTraces : Trace [ ] = [ ] ;
3737
38- constructor ( exporter : Exporter ) {
38+ constructor ( ) {
3939 this . _active = false ;
4040 this . contextManager = cls . createNamespace ( ) ;
41- this . exporter = exporter ;
4241 }
4342
4443 public get currentTrace ( ) : Trace {
@@ -66,7 +65,9 @@ export class Tracer {
6665 }
6766
6867 public endTrace ( ) : void {
69- if ( ! this . currentTrace ) return debug ( 'cannot end trace - no active trace found' )
68+ if ( ! this . currentTrace ) {
69+ return debug ( 'cannot end trace - no active trace found' )
70+ }
7071 this . currentTrace . end ( ) ;
7172 this . addEndedTrace ( this . currentTrace ) ;
7273 //this.clearCurrentTrace();
@@ -81,7 +82,7 @@ export class Tracer {
8182 if ( ! this . currentTrace ) {
8283 debug ( 'no current trace found - cannot start a new span' ) ;
8384 } else {
84- newSpan = this . currentTrace . startSpan ( name , type )
85+ newSpan = this . currentTrace . startSpan ( name , type ) ;
8586 }
8687 return newSpan ;
8788 }
@@ -120,6 +121,10 @@ export class Tracer {
120121 namespace . bindEmitter ( emitter ) ;
121122 }
122123
124+ public registerExporter ( exporter :Exporter ) {
125+ this . exporter = exporter ;
126+ }
127+
123128}
124129
125130
0 commit comments