1515 */
1616
1717import { Sampler } from './config/sampler' ;
18- import { SpanBaseModel } from './model/spanbasemodel' ;
1918
2019/** Default type for functions */
2120export type Func < T > = ( ...args : any [ ] ) => T ;
@@ -63,11 +62,6 @@ export interface TraceOptions {
6362 type ?: string ;
6463}
6564
66- /** Defines an end span event listener */
67- export interface OnEndSpanEventListener {
68- /** Happens when a span is ended */
69- onEndSpan ( span : SpanBaseModel ) : void ;
70- }
7165
7266/** Defines the span data */
7367export interface SpanData {
@@ -81,32 +75,83 @@ export interface SpanData {
8175 parentSpanId ?: string ;
8276}
8377
84- /** Interface for RootSpan */
85- export interface RootSpan {
86- /** Get the span list from RootSpan instance */
87- readonly spans : Span [ ] ;
88-
89- /** Start the RootSpan instance */
90- start ( ) : void ;
91- /** End the RootSpan instance */
92- end ( ) : void ;
93- /** Start a new Span instance in the RootSpan instance */
94- startSpan ( name : string , type : string , parentSpanId ?: string ) : Span ;
95- }
9678
9779/** Interface for Span */
9880export interface Span {
99- /** Gets the traceId from span instance */
81+
82+ /** The Span ID of this span */
83+ readonly id : string ;
84+ remoteParent : string ;
85+ /** The span ID of this span's parent. If it's a root span, must be empty */
86+ parentSpanId : string ;
87+ /** The resource name of the span */
88+ name : string ;
89+ /** Type of span. Used to specify additional relationships between spans */
90+ type : string ;
91+ /** A final status for this span */
92+ status : number ;
93+ /** A sampler that will decide if the span will be sampled or not */
94+ sampler : Sampler ;
95+ /** Constructs a new SpanBaseModel instance. */
10096 readonly traceId : string ;
101- /** Gets the parentSpanId from span instance */
102- readonly parentSpanId : string ;
103- /** Gets the traceContext from span instance */
97+ /** Indicates if span was started. */
98+ readonly started : boolean ;
99+ /** Indicates if span was ended. */
100+ readonly ended : boolean ;
101+ /**
102+ * Gives a timestap that indicates the span's start time in RFC3339 UTC
103+ * "Zulu" format.
104+ */
105+ readonly startTime : Date ;
106+ /**
107+ * Gives a timestap that indicates the span's end time in RFC3339 UTC
108+ * "Zulu" format.
109+ */
110+ readonly endTime : Date ;
111+ /**
112+ * Gives a timestap that indicates the span's duration in RFC3339 UTC
113+ * "Zulu" format.
114+ */
115+ readonly duration : number ;
116+ /** Gives the TraceContext of the span. */
104117 readonly traceContext : TraceContext ;
105-
106- /** Starts a span instance. */
118+ /**
119+ * Adds an atribute to the span.
120+ * @param key Describes the value added.
121+ * @param value The result of an operation.
122+ */
123+ addAtribute ( key : string , value : string ) : void ;
124+ /**
125+ * Adds an annotation to the span.
126+ * @param key Describes the value added.
127+ * @param value The result of an operation.
128+ */
129+ addAnotation ( key : string , value : string | number | boolean ) : void ;
130+ /** Starts a span. */
107131 start ( ) : void ;
108132 /** Ends a span. */
109133 end ( ) : void ;
134+ /** Forces to end a span. */
135+ truncate ( ) : void ;
136+ }
137+
138+ /** Interface for RootSpan */
139+ export interface RootSpan extends Span {
140+ /** Get the span list from RootSpan instance */
141+ readonly spans : Span [ ] ;
142+
143+ /** Start the RootSpan instance */
144+ start ( ) : void ;
145+ /** End the RootSpan instance */
146+ end ( ) : void ;
147+ /** Start a new Span instance in the RootSpan instance */
148+ startSpan ( name : string , type : string , parentSpanId ?: string ) : Span ;
149+ }
150+
151+ /** Defines an end span event listener */
152+ export interface OnEndSpanEventListener {
153+ /** Happens when a span is ended */
154+ onEndSpan ( span : Span ) : void ;
110155}
111156
112157/** Interface for Tracer */
0 commit comments