import Context from '../../trace/context/Context' ; import Span from '../../trace/span/Span' ; import DummySpan from '../../trace/span/DummySpan' ; import Segment from '../../trace/context/Segment' ; import { Component } from '../Component' ; import { ContextCarrier } from './ContextCarrier' ; import ContextManager from './ContextManager' ; export default class DummyContext implements Context { segment : Segment = new Segment ( ) ; nSpans = 0 ; finished = false ; newEntrySpan ( operation , carrier ? , inherit ? ) { return DummySpan . create ( this ) ; } newExitSpan ( operation , component , inherit ? ) { return DummySpan . create ( this ) ; } newLocalSpan ( operation ) { return DummySpan . create ( this ) ; } start ( span ) { const spans = ContextManager . spansDup ( ) ; if ( ! this . nSpans ++ ) { ContextManager . checkCold ( ) ; if ( spans . indexOf ( span ) === - 1 ) spans . push ( span ) ; } return this ; } stop ( span ) { if ( -- this . nSpans ) return false ; ContextManager . clear ( span ) ; return true ; } async ( span ) { ContextManager . clear ( span ) ; } resync ( span ) { ContextManager . restore ( span ) ; } traceId ( ) { if ( ! this . segment . relatedTraces ) { return 'N/A' ; } return this . segment . relatedTraces [ 0 ] . toString ( ) ; } }