ELK 6.5, APM 6.6 Windows
We are seeing the user context logged with errors but not with transactions - see the following NodeJS ExpressJS application:
var apm = require('elastic-apm-node').start({serviceName: 'expresstest', serverUrl: 'http://xxxx:8200'});
apm.setUserContext({id: 1, username: 'jack'});
apm.captureError(new Error('Something is down!'));
var trans = apm.startTransaction("foo", "bar");
trans.setTag("type", "test");
trans.result="success";
trans.end();
The result is
- An error event with the user jack
- A transaction event with no user
I would expect apm.setUserContext
to set the user context "globally" i.e. for all future transactions - must it really be set for each transaction?
{
"transaction": {
"id": "1b23b8ad1e160c73",
"trace_id": "bfaa68b17cc403a681ede938e89bd132",
"name": "foo",
"type": "bar",
"duration": 6.442,
"timestamp": 1551267487527078,
"result": "success",
"sampled": true,
"context": {
"user": {
},
"tags": {
"type": "test"
},
"custom": {
}
},
"span_count": {
"started": 0
}
}
}
{
"error": {
"exception": {
"message": "booga is down!",
"type": "Error",
"stacktrace": [
...
],
"handled": true
},
"culprit": "Object.<anonymous> (index.js)",
"id": "c069bc3de7a8de735fdb2f866dda2804",
"timestamp": 1551267487518000,
"context": {
"user": {
},
"tags": {
},
"custom": {
}
}
}
}