-
Notifications
You must be signed in to change notification settings - Fork 239
Open
Labels
agent-nodejsMake available for APM Agents project planning.Make available for APM Agents project planning.bug
Description
Describe the bug
When you have an elasticsearch config similar to this:
elasticsearch: {
host: [
{
host: process.env.ELASTIC_HOST,
auth: process.env.ELASTIC_AUTHENTICATION,
protocol: process.env.ELASTIC_PROTOCOL,
port: process.env.ELASTIC_PORT
}
],
log: 'error',
requestTimeout: 60000
}
The updated APM code crashes because it's not anticipating the array for the host property.
Issue was introduced in this commit: aa8eb56#diff-daccb535f6ab4446fed3816cc2a6dc92
Specifically this bit of code in the elasticsearch module:
// get the remote host information from elasticsearch Transport options
const transportConfig = this._config
let host, port
if (typeof transportConfig === 'object' && transportConfig.host) {
[host, port] = transportConfig.host.split(':')
}
span.setDestinationContext(getDBDestination(span, host, port))
The host.split is where the error occurs: "TypeError: transportConfig.host.split is not a function or its return value is not iterable"
To Reproduce
Steps to reproduce the behavior:
- Use an array to specify one or more hosts for the elasticsearch client
- Use the latest release of the apm client.
Expected behavior
APM should be able to handle host specified as an array.
Environment (please complete the following information)
- OS: OSX and Ubuntu, should apply to any
- Node.js version: testing on 12, should be an issue for all
- APM Server version: latest in elastic cloud
- Agent version: 3.6.1
How are you starting the agent? (please tick one of the boxes)
- [ X] Calling
agent.start()directly (e.g.require('elastic-apm-node').start(...)) - Requiring
elastic-apm-node/startfrom within the source code - Starting node with
-r elastic-apm-node/start
AnkurThakur
Metadata
Metadata
Assignees
Labels
agent-nodejsMake available for APM Agents project planning.Make available for APM Agents project planning.bug