elastic cloud latest version
const config = require('./config');
const apm = require('elastic-apm-node').start({
serviceName: config.ELASTIC_APM_SERVICE_NAME,
secretToken: config.ELASTIC_APM_SERVICE_SECRET,
serverUrl: config.ELASTIC_APM_SERVER_URL,
environment: config.ELASTIC_APM_ENV,
})
function globalUser (payload) {
if (payload.context &&
payload.context.request &&
payload.context.request.headers &&
payload.context.request.headers['x-user-id']) {
// redact sensitive data
const xUserId = payload.context.request.headers["x-user-id"]
console.log(xUserId)
apm.setUserContext({id: xUserId})
}
return payload // remember to return the modified payload
}
apm.addFilter(globalUser)
module.exports = apm;
this is not updated user.id