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

Commit 7af710f

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 7af710f

5 files changed

Lines changed: 24 additions & 29 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: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,31 @@
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'
23+
import { Exporter } from '../../exporters/exporter';
2424

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

27-
export class TraceManager {
27+
export class Tracer {
2828

2929
readonly PLUGINS = ['http', 'https', 'mongodb-core', 'express']
3030

3131
private _active: boolean;
3232
private contextManager: cls.Namespace;
33-
private pluginLoader: PluginLoader;
34-
private exporter
33+
private exporter: Exporter;
3534

3635
//TODO: temp solution
3736
private endedTraces: Trace[] = [];
3837

39-
constructor() {
38+
constructor(exporter:Exporter) {
4039
this._active = false;
4140
this.contextManager = cls.createNamespace();
42-
this.pluginLoader = new PluginLoader(this);
43-
this.exporter = new Stackdriver(new StackdriverOptions('opencensus-cesar'));
41+
this.exporter = exporter;
4442
}
4543

4644
public get currentTrace(): Trace {
@@ -51,8 +49,7 @@ export class TraceManager {
5149
this.contextManager.set('trace', trace);
5250
}
5351

54-
public start(config?:Object): TraceManager {
55-
this.pluginLoader.loadPlugins(this.PLUGINS);
52+
public start(config?:Object): Tracer {
5653
this._active = true;
5754
return this;
5855
}
@@ -71,10 +68,8 @@ export class TraceManager {
7168
public endTrace(): void {
7269
if (!this.currentTrace) return debug('cannot end trace - no active trace found')
7370
this.currentTrace.end();
74-
this.exporter.emit(this.currentTrace);
7571
this.addEndedTrace(this.currentTrace);
7672
//this.clearCurrentTrace();
77-
this.startTrace();
7873
}
7974

8075
public clearCurrentTrace() {
@@ -97,11 +92,11 @@ export class TraceManager {
9792
this.exporter.emit(this.currentTrace);
9893
}*/
9994

100-
10195
private addEndedTrace(trace: Trace) {
10296
if (this.active) {
10397
//TODO: temp solution
104-
this.endedTraces.push(trace);
98+
//this.endedTraces.push(trace);
99+
this.exporter.emit(this.currentTrace);
105100
}
106101
}
107102

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)