[Backport 7.x] Added new observability events (#1370)
Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
29ee3ec582
commit
07bcd62285
@ -49,6 +49,15 @@ client.on('response', (err, result) => {
|
||||
The client emits the following events:
|
||||
[cols=2*]
|
||||
|===
|
||||
|`serialization`
|
||||
a|Emitted before starting serialization and compression. If you want to measure this phase duration, you should measure the time elapsed between this event and `request`.
|
||||
[source,js]
|
||||
----
|
||||
client.on('serialization', (err, result) => {
|
||||
console.log(err, result)
|
||||
})
|
||||
----
|
||||
|
||||
|`request`
|
||||
a|Emitted before sending the actual request to {es} _(emitted multiple times in case of retries)_.
|
||||
[source,js]
|
||||
@ -58,6 +67,15 @@ client.on('request', (err, result) => {
|
||||
})
|
||||
----
|
||||
|
||||
|`deserialization`
|
||||
a|Emitted before starting deserialization and decompression. If you want to measure this phase duration, you should measure the time elapsed between this event and `response`. _(This event might not be emitted in certain situations)_.
|
||||
[source,js]
|
||||
----
|
||||
client.on('deserialization', (err, result) => {
|
||||
console.log(err, result)
|
||||
})
|
||||
----
|
||||
|
||||
|`response`
|
||||
a|Emitted once {es} response has been received and parsed.
|
||||
[source,js]
|
||||
@ -87,7 +105,7 @@ client.on('resurrect', (err, result) => {
|
||||
|
||||
|===
|
||||
|
||||
The values of `result` in `request`, `response` and `sniff` will be:
|
||||
The values of `result` in `serialization`, `request`, `deserialization`, `response` and `sniff` will be:
|
||||
|
||||
[source,ts]
|
||||
----
|
||||
@ -127,6 +145,29 @@ request: {
|
||||
};
|
||||
----
|
||||
|
||||
[discrete]
|
||||
==== Events order
|
||||
|
||||
The event order is described in the following graph, in some edge cases, the order is not guaranteed.
|
||||
You can find in https://github.com/elastic/elasticsearch-js/blob/master/test/acceptance/events-order.test.js[`test/acceptance/events-order.test.js`] how the order changes based on the situation.
|
||||
|
||||
[source]
|
||||
----
|
||||
serialization
|
||||
│
|
||||
│ (serialization and compression happens between those two events)
|
||||
│
|
||||
└─▶ request
|
||||
│
|
||||
│ (actual time spent over the wire)
|
||||
│
|
||||
└─▶ deserialization
|
||||
│
|
||||
│ (deserialization and decompression happens between those two events)
|
||||
│
|
||||
└─▶ response
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Correlation id
|
||||
|
||||
Reference in New Issue
Block a user