* @returns {String} Returns a json string with the startup message. * @private
()
| 355 | * @private |
| 356 | */ |
| 357 | _getStatusEvent() { |
| 358 | const cc = this._client.controlConnection; |
| 359 | const options = this._client.options; |
| 360 | const state = this._client.getState(); |
| 361 | const connectedNodes = {}; |
| 362 | |
| 363 | state.getConnectedHosts().forEach(h => { |
| 364 | connectedNodes[h.address] = { |
| 365 | connections: state.getOpenConnections(h), |
| 366 | inFlightQueries: state.getInFlightQueries(h) |
| 367 | }; |
| 368 | }); |
| 369 | |
| 370 | const message = { |
| 371 | metadata: { |
| 372 | name: 'driver.status', |
| 373 | insightMappingId: 'v1', |
| 374 | insightType: 'EVENT', |
| 375 | timestamp: Date.now(), |
| 376 | tags: { language: 'nodejs' } |
| 377 | }, |
| 378 | data: { |
| 379 | clientId: options.id, |
| 380 | sessionId: this._sessionId, |
| 381 | controlConnection: cc.host ? cc.host.address : undefined, |
| 382 | connectedNodes |
| 383 | } |
| 384 | }; |
| 385 | |
| 386 | return JSON.stringify(message); |
| 387 | } |
| 388 | |
| 389 | /** |
| 390 | * Cleans any timer used internally and sets the client as closed. |
no test coverage detected