import { ApmError } from './apm_error' ; import { Entity } from '../entity' ; import { Metricset } from './metricset' ; import { Span } from './span' ; import { Transaction } from './transaction' ; import { ApmApplicationMetricFields , ApmFields } from './apm_fields' ; export class Instance extends Entity < ApmFields > { transaction ( transactionName , transactionType = 'request' ) { return new Transaction ( { ... this . fields , 'transaction.name' : transactionName , 'transaction.type' : transactionType , } ) ; } span ( spanName , spanType , spanSubtype ? ) { return new Span ( { ... this . fields , 'span.name' : spanName , 'span.type' : spanType , 'span.subtype' : spanSubtype , } ) ; } error ( message , type ? , groupingName ? ) { return new ApmError ( { ... this . fields , 'error.exception' : [ { message , ... ( type ? { type } : { } ) } ] , 'error.grouping_name' : groupingName || message , } ) ; } podId ( podId ) { this . fields [ 'kubernetes.pod.uid' ] = podId ; return this ; } appMetrics ( metrics ) { return new Metricset ( { ... this . fields , 'metricset.name' : 'app' , ... metrics , } ) ; } }