Added new observability events (#1365)

This commit is contained in:
Tomas Della Vedova
2020-12-09 11:43:46 +01:00
committed by GitHub
parent 9fea1aedc0
commit 33035901cf
6 changed files with 522 additions and 4 deletions

View File

@ -268,6 +268,8 @@ class Transport {
if (!isCompressed) {
response.setEncoding('utf8')
}
this.emit('deserialization', null, result)
response.on('data', onData)
response.on('error', onEnd)
response.on('end', onEnd)
@ -340,6 +342,7 @@ class Transport {
}
}
this.emit('serialization', null, result)
const headers = Object.assign({}, this.headers, lowerCaseHeaders(options.headers))
if (options.opaqueId !== undefined) {
@ -354,6 +357,7 @@ class Transport {
try {
params.body = this.serializer.serialize(params.body)
} catch (err) {
this.emit('request', err, result)
process.nextTick(callback, err, result)
return transportReturn
}
@ -369,6 +373,7 @@ class Transport {
try {
params.body = this.serializer.ndserialize(params.bulkBody)
} catch (err) {
this.emit('request', err, result)
process.nextTick(callback, err, result)
return transportReturn
}
@ -408,6 +413,7 @@ class Transport {
gzip(params.body, (err, buffer) => {
/* istanbul ignore next */
if (err) {
this.emit('request', err, result)
return callback(err, result)
}
params.headers['content-encoding'] = compression