@@ -49,6 +49,9 @@ import {
49
49
} from '../../../../ml/server' ;
50
50
import { getServiceInstancesDetailedStatisticsPeriods } from './get_service_instances/detailed_statistics' ;
51
51
import { ML_ERRORS } from '../../../common/anomaly_detection' ;
52
+ import { ScopedAnnotationsClient } from '../../../../observability/server' ;
53
+ import { Annotation } from './../../../../observability/common/annotations' ;
54
+ import { ConnectionStatsItemWithImpact } from './../../../common/connections' ;
52
55
53
56
const servicesRoute = createApmServerRoute ( {
54
57
endpoint : 'GET /internal/apm/services' ,
@@ -373,8 +376,10 @@ const serviceAnnotationsRoute = createApmServerRoute({
373
376
const [ annotationsClient , searchAggregatedTransactions ] = await Promise . all (
374
377
[
375
378
observability
376
- ? withApmSpan ( 'get_scoped_annotations_client' , ( ) =>
377
- observability . setup . getScopedAnnotationsClient ( context , request )
379
+ ? withApmSpan (
380
+ 'get_scoped_annotations_client' ,
381
+ ( ) : Promise < undefined | ScopedAnnotationsClient > =>
382
+ observability . setup . getScopedAnnotationsClient ( context , request )
378
383
)
379
384
: undefined ,
380
385
getSearchAggregatedTransactions ( {
@@ -443,8 +448,10 @@ const serviceAnnotationsCreateRoute = createApmServerRoute({
443
448
} = resources ;
444
449
445
450
const annotationsClient = observability
446
- ? await withApmSpan ( 'get_scoped_annotations_client' , ( ) =>
447
- observability . setup . getScopedAnnotationsClient ( context , request )
451
+ ? await withApmSpan (
452
+ 'get_scoped_annotations_client' ,
453
+ ( ) : Promise < undefined | ScopedAnnotationsClient > =>
454
+ observability . setup . getScopedAnnotationsClient ( context , request )
448
455
)
449
456
: undefined ;
450
457
@@ -454,20 +461,22 @@ const serviceAnnotationsCreateRoute = createApmServerRoute({
454
461
455
462
const { body, path } = params ;
456
463
457
- return withApmSpan ( 'create_annotation' , ( ) =>
458
- annotationsClient . create ( {
459
- message : body . service . version ,
460
- ...body ,
461
- '@timestamp' : new Date ( body [ '@timestamp' ] ) . toISOString ( ) ,
462
- annotation : {
463
- type : 'deployment' ,
464
- } ,
465
- service : {
466
- ...body . service ,
467
- name : path . serviceName ,
468
- } ,
469
- tags : uniq ( [ 'apm' ] . concat ( body . tags ?? [ ] ) ) ,
470
- } )
464
+ return withApmSpan (
465
+ 'create_annotation' ,
466
+ ( ) : Promise < { _id : string ; _index : string ; _source : Annotation } > =>
467
+ annotationsClient . create ( {
468
+ message : body . service . version ,
469
+ ...body ,
470
+ '@timestamp' : new Date ( body [ '@timestamp' ] ) . toISOString ( ) ,
471
+ annotation : {
472
+ type : 'deployment' ,
473
+ } ,
474
+ service : {
475
+ ...body . service ,
476
+ name : path . serviceName ,
477
+ } ,
478
+ tags : uniq ( [ 'apm' ] . concat ( body . tags ?? [ ] ) ) ,
479
+ } )
471
480
) ;
472
481
} ,
473
482
} ) ;
@@ -925,18 +934,25 @@ export const serviceDependenciesRoute = createApmServerRoute({
925
934
] ) ;
926
935
927
936
return {
928
- serviceDependencies : currentPeriod . map ( ( item ) => {
929
- const { stats, ...rest } = item ;
930
- const previousPeriodItem = previousPeriod . find (
931
- ( prevItem ) => item . location . id === prevItem . location . id
932
- ) ;
933
-
934
- return {
935
- ...rest ,
936
- currentStats : stats ,
937
- previousStats : previousPeriodItem ?. stats || null ,
938
- } ;
939
- } ) ,
937
+ serviceDependencies : currentPeriod . map (
938
+ (
939
+ item
940
+ ) : Omit < ConnectionStatsItemWithImpact , 'stats' > & {
941
+ currentStats : ConnectionStatsItemWithImpact [ 'stats' ] ;
942
+ previousStats : ConnectionStatsItemWithImpact [ 'stats' ] | null ;
943
+ } => {
944
+ const { stats, ...rest } = item ;
945
+ const previousPeriodItem = previousPeriod . find (
946
+ ( prevItem ) : boolean => item . location . id === prevItem . location . id
947
+ ) ;
948
+
949
+ return {
950
+ ...rest ,
951
+ currentStats : stats ,
952
+ previousStats : previousPeriodItem ?. stats || null ,
953
+ } ;
954
+ }
955
+ ) ,
940
956
} ;
941
957
} ,
942
958
} ) ;
0 commit comments