import { ElasticsearchClient , Logger } from 'kibana/server' ; import { ScopedAnnotationsClient } from '../../../../../observability/server' ; import { getDerivedServiceAnnotations } from './get_derived_service_annotations' ; import { Setup } from '../../../lib/helpers/setup_request' ; import { getStoredAnnotations } from './get_stored_annotations' ; export async function getServiceAnnotations ( { setup , searchAggregatedTransactions , serviceName , environment , annotationsClient , client , logger , start , end , } ) { const derivedAnnotationsPromise = getDerivedServiceAnnotations ( { setup , serviceName , environment , searchAggregatedTransactions , start , end , } ) ; const storedAnnotations = annotationsClient ? await getStoredAnnotations ( { serviceName , environment , annotationsClient , client , logger , start , end , } ) : [ ] ; if ( storedAnnotations . length ) { derivedAnnotationsPromise . catch ( ( ) => { } ) ; return { annotations : storedAnnotations } ; } return { annotations : await derivedAnnotationsPromise , } ; }