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

Commit 3cf908a

Browse files
committed
Changing class name TraceManger to Tracer, creating class Tracing. Moving class files Span.ts, Trace.ts and Tracer.ts to trace/model
1 parent bfed75d commit 3cf908a

5 files changed

Lines changed: 19 additions & 26 deletions

File tree

packages/opencensus-core/src/trace/instrumentation/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
export interface Plugin <TM> {
18-
applyPatch: (module: any, manager: TM, version: string) => void;
18+
applyPatch(module: any, manager: TM, version: string): void;
1919
}
2020

2121
export abstract class BasePlugin <TM> {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {Clock} from '../internal/clock';
17+
import {Clock} from '../../internal/clock';
1818
import {Trace} from './trace';
19-
import {debug, randomSpanId} from '../internal/util'
20-
import {TracerComponent} from './types/tracetypes'
19+
import {debug, randomSpanId} from '../../internal/util'
20+
import {TraceBaseModel} from '../types/tracetypes'
2121

2222

23-
export class Span extends TracerComponent {
23+
export class Span extends TraceBaseModel {
2424

25-
private trace: TracerComponent;
25+
private trace: TraceBaseModel;
2626
private _parentSpanId: string;
2727

28-
constructor(trace: TracerComponent) {
28+
constructor(trace: TraceBaseModel) {
2929
super()
3030
this.trace = trace;
3131
this.setId(randomSpanId());

packages/opencensus-core/src/trace/model/root-span.ts renamed to packages/opencensus-core/src/trace/model/trace.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
*/
1616

1717
import {Span} from './span'
18-
import {Clock} from '../internal/clock'
18+
import {Clock} from '../../internal/clock'
1919
import * as uuid from 'uuid';
20-
import {debug} from '../internal/util'
21-
import {TracerComponent} from './types/tracetypes'
20+
import {debug} from '../../internal/util'
21+
import {TraceBaseModel} from '../types/tracetypes'
2222

23-
export class Trace extends TracerComponent {
23+
export class Trace extends TraceBaseModel {
2424

2525
private spans: Span[] = [];
2626

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,28 @@
1414
* limitations under the License.
1515
*/
1616

17-
import * as cls from '../internal/cls';
17+
import * as cls from '../../internal/cls';
1818
import {Trace} from './trace'
1919
import {Span} from './span'
20-
import {PluginLoader} from './plugins/pluginloader'
21-
import {debug} from '../internal/util'
22-
import {Stackdriver} from '../exporters/stackdriver/stackdriver'
23-
import {StackdriverOptions} from '../exporters/stackdriver/options'
20+
import {debug} from '../../internal/util'
21+
import {Stackdriver} from '../../exporters/stackdriver/stackdriver'
22+
import {StackdriverOptions} from '../../exporters/stackdriver/options'
2423

2524
export type Func<T> = (...args: any[]) => T;
2625

27-
export class TraceManager {
26+
export class Tracer {
2827

2928
readonly PLUGINS = ['http', 'https', 'mongodb-core', 'express']
3029

3130
private _active: boolean;
3231
private contextManager: cls.Namespace;
33-
private pluginLoader: PluginLoader;
34-
private exporter
3532

3633
//TODO: temp solution
3734
private endedTraces: Trace[] = [];
3835

3936
constructor() {
4037
this._active = false;
4138
this.contextManager = cls.createNamespace();
42-
this.pluginLoader = new PluginLoader(this);
43-
this.exporter = new Stackdriver(new StackdriverOptions('opencensus-cesar'));
4439
}
4540

4641
public get currentTrace(): Trace {
@@ -51,8 +46,7 @@ export class TraceManager {
5146
this.contextManager.set('trace', trace);
5247
}
5348

54-
public start(config?:Object): TraceManager {
55-
this.pluginLoader.loadPlugins(this.PLUGINS);
49+
public start(config?:Object): Tracer {
5650
this._active = true;
5751
return this;
5852
}
@@ -71,10 +65,8 @@ export class TraceManager {
7165
public endTrace(): void {
7266
if (!this.currentTrace) return debug('cannot end trace - no active trace found')
7367
this.currentTrace.end();
74-
this.exporter.emit(this.currentTrace);
7568
this.addEndedTrace(this.currentTrace);
7669
//this.clearCurrentTrace();
77-
this.startTrace();
7870
}
7971

8072
public clearCurrentTrace() {
@@ -102,6 +94,7 @@ export class TraceManager {
10294
if (this.active) {
10395
//TODO: temp solution
10496
this.endedTraces.push(trace);
97+
// this.exporter.emit(this.currentTrace);
10598
}
10699
}
107100

packages/opencensus-core/src/trace/types/tracetypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {debug, randomSpanId} from '../../internal/util'
2121
export interface MapLabels { [propName: string]: string; }
2222
export interface MapObjects { [propName: string]: any; }
2323

24-
export abstract class TracerComponent {
24+
export abstract class TraceBaseModel {
2525

2626
private _className: string;
2727
private _id: string;

0 commit comments

Comments
 (0)