Improve observability (#834)

* API generation

* Added correlation id support

* Updated docs

* Updated test

* Updated code generation

* API generation

* Updated code generation

* Added support for client name and custom context object

* Updated docs

* Updated test

* Fix docs

* Updated docs

* Added id support also for sniffing

* Updated test

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Apply suggestions

* Update docs/configuration.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/configuration.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Update docs/observability.asciidoc

Co-Authored-By: delvedor <delvedor@users.noreply.github.com>

* Apply suggestions

* Updated README.md

* Fixed test

* Addressed suggestions
This commit is contained in:
Tomas Della Vedova
2019-05-03 17:23:40 +02:00
committed by delvedor
parent 7d810f8110
commit 14fc908d4b
279 changed files with 2314 additions and 142 deletions

View File

@ -704,11 +704,13 @@ test('Should call markAlive with a successful response', t => {
})
test('Should call resurrect on every request', t => {
t.plan(3)
t.plan(5)
class CustomConnectionPool extends ConnectionPool {
resurrect (now) {
resurrect ({ now, requestId, name }) {
t.type(now, 'number')
t.type(requestId, 'number')
t.type(name, 'string')
}
}
@ -725,7 +727,8 @@ test('Should call resurrect on every request', t => {
maxRetries: 3,
requestTimeout: 30000,
sniffInterval: false,
sniffOnStart: false
sniffOnStart: false,
name: 'elasticsearch-js'
})
transport.request({
@ -2107,3 +2110,30 @@ test('Should accept custom querystring in the optons object', t => {
t.end()
})
test('Should pass request params and options to generateRequestId', t => {
t.plan(3)
const pool = new ConnectionPool({ Connection: MockConnection })
pool.addConnection('http://localhost:9200')
const params = { method: 'GET', path: '/hello' }
const options = { context: { winter: 'is coming' } }
const transport = new Transport({
emit: () => {},
connectionPool: pool,
serializer: new Serializer(),
maxRetries: 3,
requestTimeout: 30000,
sniffInterval: false,
sniffOnStart: false,
generateRequestId: function (requestParams, requestOptions) {
t.deepEqual(requestParams, params)
t.deepEqual(requestOptions, options)
return 'id'
}
})
transport.request(params, options, t.error)
})