@@ -29,15 +29,15 @@ export type Func<T> = (...args: any[]) => T;
2929
3030export class Tracer implements OnEndSpanEventListener {
3131
32- readonly PLUGINS = [ 'http' , 'https' , 'mongodb-core' , 'express' ] ;
32+ readonly PLUGINS = [ 'http' , 'https' , 'mongodb-core' ] ;
3333
3434 //public buffer: Buffer;
3535 private _active : boolean ;
3636 private contextManager : cls . Namespace ;
3737 private config : TracerConfig ;
3838
3939 //TODO: simple solution - to be rewied in future
40- private eventListeners : OnEndSpanEventListener [ ] = [ ] ;
40+ private eventListeners : OnEndSpanEventListener [ ] = [ ] ;
4141 //TODO: temp solution
4242 private endedTraces : RootSpan [ ] = [ ] ;
4343
@@ -76,12 +76,17 @@ export class Tracer implements OnEndSpanEventListener {
7676 return this . contextManager . runAndReturn ( ( root ) => {
7777 let newRoot = new RootSpan ( this , options ) ;
7878 this . setCurrentRootSpan ( newRoot ) ;
79- if ( options . sampler == null ) {
79+ if ( ! options ) {
80+ options = < TraceOptions > { }
81+ }
82+ if ( ! options . sampler ) {
83+ // options.sampler = new Sampler(newRoot.traceId);
84+ // options.sampler.probability(0.6);
8085 options . sampler = new Sampler ( newRoot . traceId ) ;
81- options . sampler . probability ( 0.6 ) ;
86+ options . sampler . always ( ) ;
8287 }
8388 newRoot . sampler = options . sampler ;
84- if ( newRoot . sampler . continue ( newRoot . traceId ) ) {
89+ if ( newRoot . sampler . continue ( newRoot . traceId ) ) {
8590 newRoot . start ( ) ;
8691 return fn ( newRoot ) ;
8792 }
@@ -90,12 +95,12 @@ export class Tracer implements OnEndSpanEventListener {
9095 }
9196
9297
93- public onEndSpan ( root :RootSpan ) : void {
98+ public onEndSpan ( root : RootSpan ) : void {
9499 if ( ! root ) {
95100 return debug ( 'cannot end trace - no active trace found' )
96101 }
97- if ( this . currentRootSpan != root ) {
98- debug ( 'currentRootSpan != root on notifyEnd. Need more investigation.' )
102+ if ( this . currentRootSpan != root ) {
103+ debug ( 'currentRootSpan != root on notifyEnd. Need more investigation.' )
99104 }
100105 this . notifyEndSpan ( root ) ;
101106 //this.clearCurrentTrace();
@@ -107,8 +112,8 @@ export class Tracer implements OnEndSpanEventListener {
107112
108113 private notifyEndSpan ( root : RootSpan ) {
109114 if ( this . active ) {
110- debug ( 'starting to notify listeners the end of rootspans' )
111- if ( this . eventListeners && this . eventListeners . length > 0 ) {
115+ debug ( 'starting to notify listeners the end of rootspans' )
116+ if ( this . eventListeners && this . eventListeners . length > 0 ) {
112117 this . eventListeners . forEach ( ( listener ) => listener . onEndSpan ( root ) )
113118 }
114119 } else {
0 commit comments