@@ -19,6 +19,7 @@ import {debug, randomSpanId} from '../../internal/util';
1919import { Sampler } from '../config/types' ;
2020
2121import { Annotation , Attributes , Link , MessageEvent , Span , TraceContext } from './types' ;
22+ import { Logger } from '../../common/types' ;
2223
2324/** Defines a base model for spans. */
2425export abstract class SpanBaseModel implements Span {
@@ -33,6 +34,8 @@ export abstract class SpanBaseModel implements Span {
3334 private truncated = false ;
3435 /** The Span ID of this span */
3536 readonly id : string ;
37+ /** An object to log information to */
38+ logger : Logger ;
3639 /** A set of attributes, each in the format [KEY]:[VALUE] */
3740 attributes : Attributes = { } ;
3841 /** A text annotation with a set of attributes. */
@@ -78,7 +81,7 @@ export abstract class SpanBaseModel implements Span {
7881 */
7982 get startTime ( ) : Date {
8083 if ( ! this . clock ) {
81- debug ( 'calling startTime() on null clock' ) ;
84+ this . logger . debug ( 'calling startTime() on null clock' ) ;
8285 return null ;
8386 }
8487
@@ -91,7 +94,7 @@ export abstract class SpanBaseModel implements Span {
9194 */
9295 get endTime ( ) : Date {
9396 if ( ! this . clock ) {
94- debug ( 'calling endTime() on null clock' ) ;
97+ this . logger . debug ( 'calling endTime() on null clock' ) ;
9598 return null ;
9699 }
97100
@@ -104,7 +107,7 @@ export abstract class SpanBaseModel implements Span {
104107 */
105108 get duration ( ) : number {
106109 if ( ! this . clock ) {
107- debug ( 'calling duration() on null clock' ) ;
110+ this . logger . debug ( 'calling duration() on null clock' ) ;
108111 return null ;
109112 }
110113
@@ -176,7 +179,7 @@ export abstract class SpanBaseModel implements Span {
176179 /** Starts the span. */
177180 start ( ) {
178181 if ( this . started ) {
179- debug (
182+ this . logger . debug (
180183 'calling %s.start() on already started %s %o' , this . className ,
181184 this . className , { id : this . id , name : this . name , type : this . type } ) ;
182185 return ;
@@ -188,13 +191,13 @@ export abstract class SpanBaseModel implements Span {
188191 /** Ends the span. */
189192 end ( ) : void {
190193 if ( this . ended ) {
191- debug (
194+ this . logger . debug (
192195 'calling %s.end() on already ended %s %o' , this . className ,
193196 this . className , { id : this . id , name : this . name , type : this . type } ) ;
194197 return ;
195198 }
196199 if ( ! this . started ) {
197- debug (
200+ this . logger . debug (
198201 'calling %s.end() on un-started %s %o' , this . className ,
199202 this . className , { id : this . id , name : this . name , type : this . type } ) ;
200203 return ;
@@ -210,6 +213,7 @@ export abstract class SpanBaseModel implements Span {
210213 // TODO: review
211214 this . truncated = true ;
212215 this . end ( ) ;
213- debug ( 'truncating %s %o' , this . className , { id : this . id , name : this . name } ) ;
216+ this . logger . debug (
217+ 'truncating %s %o' , this . className , { id : this . id , name : this . name } ) ;
214218 }
215219}
0 commit comments