import { BaseSpan } from './base_span' ; import { generateShortId } from '../utils/generate_id' ; import { ApmFields } from './apm_fields' ; export class Span extends BaseSpan { constructor ( fields ) { super ( { ... fields , 'processor.event' : 'span' , 'span.id' : generateShortId ( ) , } ) ; } duration ( duration ) { this . fields [ 'span.duration.us' ] = duration * 1000 ; return this ; } destination ( resource , type ? , name ? ) { if ( ! type ) { type = this . fields [ 'span.type' ] ; } if ( ! name ) { name = resource ; } this . fields [ 'span.destination.service.resource' ] = resource ; this . fields [ 'span.destination.service.name' ] = name ; this . fields [ 'span.destination.service.type' ] = type ; return this ; } }