@@ -136,15 +136,15 @@ export abstract class SpanBase implements types.Span {
136136 /**
137137 * Adds an annotation to the span.
138138 * @param description Describes the event.
139- * @param timestamp A timestamp that maks the event.
140139 * @param attributes A set of attributes on the annotation.
140+ * @param timestamp A time, in milliseconds. Defaults to Date.now()
141141 */
142142 addAnnotation (
143- description : string , timestamp : number , attributes ?: types . Attributes ) {
143+ description : string , attributes ?: types . Attributes , timestamp = 0 ) {
144144 this . annotations . push ( {
145145 'description' : description ,
146- 'timestamp' : timestamp ,
147146 'attributes' : attributes ,
147+ 'timestamp' : timestamp ? timestamp : Date . now ( ) ,
148148 } as types . Annotation ) ;
149149 }
150150
@@ -170,11 +170,13 @@ export abstract class SpanBase implements types.Span {
170170 * Adds a message event to the span.
171171 * @param type The type of message event.
172172 * @param id An identifier for the message event.
173+ * @param timestamp A time in milliseconds. Defaults to Date.now()
173174 */
174- addMessageEvent ( type : string , id : string ) {
175+ addMessageEvent ( type : string , id : string , timestamp = 0 ) {
175176 this . messageEvents . push ( {
176177 'type' : type ,
177178 'id' : id ,
179+ 'timestamp' : timestamp ? timestamp : Date . now ( ) ,
178180 } as types . MessageEvent ) ;
179181 }
180182
@@ -217,4 +219,4 @@ export abstract class SpanBase implements types.Span {
217219 this . logger . debug (
218220 'truncating %s %o' , this . className , { id : this . id , name : this . name } ) ;
219221 }
220- }
222+ }
0 commit comments