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

Commit 8cd96cc

Browse files
committed
Fix buffer and exporters local bugs
1 parent 9e71d0f commit 8cd96cc

2 files changed

Lines changed: 21 additions & 16 deletions

File tree

packages/opencensus-core/src/trace/model/tracer.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ export type Func<T> = (...args: any[]) => T;
2929

3030
export 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 {

packages/opencensus-core/src/trace/sampler/sampler.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class Sampler{
3232
* @param spanId
3333
* @param isRemote
3434
*/
35-
constructor(traceId?:string, spanId?:string, isRemote?:boolean){
35+
constructor(traceId?:string, spanId?:string, isRemote?:boolean){
3636
debug('Samplre constructor')
3737
if(traceId){
3838
this.traceId = traceId;
@@ -68,16 +68,16 @@ export class Sampler{
6868
}
6969

7070
public continue (traceId:string):boolean{
71-
debug('Samplre continue')
71+
//debug('Samplre continue')
7272
let lower_bytes = traceId.substring(16)
7373
let lower_long: number
74-
debug('SAMPLER CONTINUE lower_bytes :',lower_bytes)
74+
//debug('SAMPLER CONTINUE lower_bytes :',lower_bytes)
7575

7676
lower_long = parseInt(lower_bytes, 16);
7777

78-
debug('SAMPLER CONTINUE lower_long :',lower_long)
79-
debug('SAMPLER CONTINUE this.idUpperBound :',this.idUpperBound)
80-
debug('SAMPLER CONTINUE diff :',lower_long - this.idUpperBound)
78+
//debug('SAMPLER CONTINUE lower_long :',lower_long)
79+
//debug('SAMPLER CONTINUE this.idUpperBound :',this.idUpperBound)
80+
//debug('SAMPLER CONTINUE diff :',lower_long - this.idUpperBound)
8181

8282
if(lower_long <= this.idUpperBound){
8383
debug('trace sampler TRUE')

0 commit comments

Comments
 (0)