Open bgardner87 opened 4 years ago
I may have time soon to pick this up and work on it, and I'm also noticing that this only applies to the legacy version of the elasticsearch javascript client.
I can confirm the same at my end. Below is an example Stack trace:
TypeError: transportConfig.host.split is not a function or its return value is not iterable
at Transport.wrappedRequest [as request] (/mnt/docker-disk/applications/myapp/node_modules/elastic-apm-node/lib/instrumentation/modules/elasticsearch.js:45:49)
at exec (/mnt/docker-disk/applications/myapp/node_modules/elasticsearch/src/lib/client_action.js:361:20)
at EsApiClient.action [as search] (/mnt/docker-disk/applications/myapp/node_modules/elasticsearch/src/lib/client_action.js:61:16)
Same on my end:
ERROR - /sessions.json error TypeError: transportConfig.host.split is not a function or its return value is not iterable -at Transport.wrappedRequest [as request] (/data/moloch/viewer/node_modules/elastic-apm-node/lib/instrumentation/modules/elasticsearch.js:45:49) -at exec (/data/moloch/node_modules/elasticsearch/src/lib/client_action.js:403:20) -at EsApiClient.action [as search] (/data/moloch/node_modules/elasticsearch/src/lib/client_action.js:61:16)
Possible workaround: use the key hosts
instead of host
. According to https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/16.x/config-options.html, (this is the legacy-client) this is possible, and this has solved the problem for me.
Describe the bug
When you have an elasticsearch config similar to this:
The updated APM code crashes because it's not anticipating the array for the host property.
Issue was introduced in this commit: https://github.com/elastic/apm-agent-nodejs/commit/aa8eb56a8486b53802e378638920d44248ce64dc#diff-daccb535f6ab4446fed3816cc2a6dc92
Specifically this bit of code in the elasticsearch module:
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:
Expected behavior
APM should be able to handle host specified as an array.
Environment (please complete the following information)
How are you starting the agent? (please tick one of the boxes)
agent.start()
directly (e.g.require('elastic-apm-node').start(...)
)elastic-apm-node/start
from within the source code-r elastic-apm-node/start