import { PluginInitializerContext } from 'opensearch-dashboards/server' ; import { UsageCollectionSetup } from '../../../../usage_collection/server' ; import { fetchProvider } from './fetch' ; export interface Usage { successCount : number ; errorCount : number ; averageDuration : number | null ; } export async function registerUsageCollector ( usageCollection , context ) { try { const collector = usageCollection . makeUsageCollector < Usage > ( { type : 'search' , isReady : ( ) => true , fetch : fetchProvider ( context . config . legacy . globalConfig$ ) , schema : { successCount : { type : 'number' } , errorCount : { type : 'number' } , averageDuration : { type : 'long' } , } , } ) ; usageCollection . registerCollector ( collector ) ; } catch ( err ) { return ; } }