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:
committed by
delvedor
parent
9dacd9d9ee
commit
b1458e3511
@ -211,3 +211,72 @@ test('Should share the event emitter', t => {
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Should create a child client (generateRequestId check)', t => {
|
||||
t.plan(6)
|
||||
|
||||
function generateRequestId1 () {
|
||||
var id = 0
|
||||
return () => `trace-1-${id++}`
|
||||
}
|
||||
|
||||
function generateRequestId2 () {
|
||||
var id = 0
|
||||
return () => `trace-2-${id++}`
|
||||
}
|
||||
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
Connection: MockConnection,
|
||||
generateRequestId: generateRequestId1()
|
||||
})
|
||||
const child = client.child({
|
||||
Connection: MockConnection,
|
||||
generateRequestId: generateRequestId2()
|
||||
})
|
||||
|
||||
var count = 0
|
||||
client.on('request', (err, { meta }) => {
|
||||
t.error(err)
|
||||
t.strictEqual(
|
||||
meta.request.id,
|
||||
count++ === 0 ? 'trace-1-0' : 'trace-2-0'
|
||||
)
|
||||
})
|
||||
|
||||
client.info(err => {
|
||||
t.error(err)
|
||||
child.info(t.error)
|
||||
})
|
||||
})
|
||||
|
||||
test('Should create a child client (name check)', t => {
|
||||
t.plan(8)
|
||||
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
Connection: MockConnection,
|
||||
name: 'parent'
|
||||
})
|
||||
const child = client.child({
|
||||
Connection: MockConnection,
|
||||
name: 'child'
|
||||
})
|
||||
|
||||
t.strictEqual(client.name, 'parent')
|
||||
t.strictEqual(child.name, 'child')
|
||||
|
||||
var count = 0
|
||||
client.on('request', (err, { meta }) => {
|
||||
t.error(err)
|
||||
t.strictEqual(
|
||||
meta.name,
|
||||
count++ === 0 ? 'parent' : 'child'
|
||||
)
|
||||
})
|
||||
|
||||
client.info(err => {
|
||||
t.error(err)
|
||||
child.info(t.error)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user