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

Commit c4e1162

Browse files
committed
chord: merge commit
2 parents baf1b76 + a38a897 commit c4e1162

1 file changed

Lines changed: 56 additions & 55 deletions

File tree

  • packages/opencensus-core/src/trace/model

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

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

17-
import { Clock } from '../../internal/clock'
18-
import { RootSpan } from './rootspan'
19-
import { debug, randomSpanId } from '../../internal/util'
20-
import { SpanBaseModel, TraceContext } from '../types/tracetypes'
21-
17+
import {Clock} from '../../internal/clock';
18+
import {debug, randomSpanId} from '../../internal/util';
19+
import {SpanBaseModel, TraceContext} from '../types/tracetypes';
20+
import {RootSpan} from './rootspan';
2221

22+
/**
23+
* This class represent a span.
24+
*/
2325
export class Span extends SpanBaseModel {
26+
private root: RootSpan;
2427

25-
private root: RootSpan;
26-
// private _parentSpanId: string;
27-
28-
constructor(root: RootSpan) {
29-
super()
30-
this.root = root;
31-
}
32-
33-
public get traceId(): string {
34-
return this.root.traceId;
35-
}
36-
37-
public get parentSpanId(): string {
38-
return this.root.id;
39-
}
28+
/**
29+
* Constructs a new Span instance.
30+
* @param root
31+
*/
32+
constructor(root: RootSpan) {
33+
super();
34+
this.root = root;
35+
}
4036

41-
public get traceContext(): TraceContext {
42-
return {
43-
traceId: this.traceId.toString(),
44-
spanId: this.id.toString(),
45-
options: 1 // always traced
46-
};
47-
}
37+
/** Gets trace id of rootspan. */
38+
get traceId(): string {
39+
return this.root.traceId;
40+
}
4841

49-
public start() {
50-
super.start();
51-
debug('starting span %o',
52-
{
53-
traceId: this.traceId,
54-
spanId: this.id,
55-
name: this.name
56-
})
57-
}
42+
/** Gets trace id of rootspan. */
43+
get parentSpanId(): string {
44+
return this.root.id;
45+
}
5846

59-
private notifyEnd () {
60-
this.root.onEndSpan(this);
61-
}
47+
/** Gets trace context of rootspan. */
48+
get traceContext(): TraceContext {
49+
return {
50+
traceId: this.traceId.toString(),
51+
spanId: this.id.toString(),
52+
options: 1 // always traced
53+
};
54+
}
6255

63-
public end(): void {
64-
// if(this.sampler.continue(this.traceId)) {
65-
66-
super.end();
67-
this.notifyEnd();
68-
debug('ending span %o',
69-
{
70-
spanId: this.id,
71-
traceId: this.traceId,
72-
name: this.name,
73-
startTime: this.startTime,
74-
endTime: this.endTime,
75-
duration: this.duration
76-
});
77-
// }
78-
}
56+
/** Starts the span instance. */
57+
start() {
58+
super.start();
59+
debug(
60+
'starting span %o',
61+
{traceId: this.traceId, spanId: this.id, name: this.name});
62+
}
7963

64+
/** Notifies an end operation on span instance. */
65+
private notifyEnd() {
66+
this.root.onEndSpan(this);
67+
}
8068

69+
/** Ends the span. */
70+
end(): void {
71+
super.end();
72+
this.notifyEnd();
73+
debug('ending span %o', {
74+
spanId: this.id,
75+
traceId: this.traceId,
76+
name: this.name,
77+
startTime: this.startTime,
78+
endTime: this.endTime,
79+
duration: this.duration
80+
});
81+
}
8182
}

0 commit comments

Comments
 (0)