import { loadConfiguration } from './config_loader' ; export const initApm = ( argv , rootDir , isDistributable , serviceName ) => { const apmConfigLoader = loadConfiguration ( argv , rootDir , isDistributable ) ; const apmConfig = apmConfigLoader . getConfig ( serviceName ) ; const apm = require ( 'elastic-apm-node' ) ; apm . addFilter ( ( payload ) => { try { if ( payload . context ?. user && typeof payload . context . user === 'object' ) { Object . keys ( payload . context . user ) . forEach ( ( key ) => { payload . context . user [ key ] = '[REDACTED]' ; } ) ; } } catch ( e ) { } return payload ; } ) ; apm . start ( apmConfig ) ; } ;