@instana/collector
Advanced tools
Comparing version 2.21.0 to 2.21.1
@@ -6,2 +6,17 @@ # Change Log | ||
## [2.21.1](https://github.com/instana/nodejs/compare/v2.21.0...v2.21.1) (2023-05-02) | ||
### Bug Fixes | ||
* **announce:** fix timeout for host agent lookup ([d4e440f](https://github.com/instana/nodejs/commit/d4e440fd91ce8a8d14e5ce90e819a7259a7c9442)) | ||
* **db2:** capture the correct destination dsn per client ([9529690](https://github.com/instana/nodejs/commit/9529690070871fddd2d31b0b646badc320dde56b)) | ||
* **elasticsearch:** capture the correct destination host per client ([cc23d05](https://github.com/instana/nodejs/commit/cc23d057a9d60a3a179e20451e0bc336e3c9a56d)) | ||
* **nats:** capture the correct destination nats address per client ([59e5ddf](https://github.com/instana/nodejs/commit/59e5ddfbbe85a724bfc040e140e63bf906706f2f)) | ||
* **nats-streaming:** capture correct destination address per client ([678d702](https://github.com/instana/nodejs/commit/678d70276dcb761eeb64dc3c848157267458192c)) | ||
# [2.21.0](https://github.com/instana/nodejs/compare/v2.20.2...v2.21.0) (2023-04-21) | ||
@@ -8,0 +23,0 @@ |
{ | ||
"name": "@instana/collector", | ||
"version": "2.21.0", | ||
"version": "2.21.1", | ||
"description": "The Instana Node.js metrics and trace data collector", | ||
@@ -138,4 +138,4 @@ "author": { | ||
"dependencies": { | ||
"@instana/core": "2.21.0", | ||
"@instana/shared-metrics": "2.21.0", | ||
"@instana/core": "2.21.1", | ||
"@instana/shared-metrics": "2.21.1", | ||
"bunyan": "^1.8.15", | ||
@@ -146,3 +146,3 @@ "semver": "7.3.3", | ||
"optionalDependencies": { | ||
"@instana/autoprofile": "2.21.0" | ||
"@instana/autoprofile": "2.21.1" | ||
}, | ||
@@ -157,3 +157,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "2c570cf285754fa54ed88f7e8c1cab7df35e3d43" | ||
"gitHead": "8a2dd3f98de2b29b9c8faf145cec0dd471c98c2d" | ||
} |
@@ -14,4 +14,2 @@ /* | ||
const EXPECTED_SERVER_HEADER = 'Instana Agent'; | ||
/** @type {import('@instana/core/src/logger').GenericLogger} */ | ||
@@ -33,2 +31,4 @@ let logger; | ||
const expectedServerHeader = 'Instana Agent'; | ||
const requestTimeout = 5000; | ||
const retryTimeoutMillis = 60 * 1000; | ||
@@ -55,8 +55,4 @@ | ||
logger.debug( | ||
'No Instana host agent is running on %s:%s. Trying the default gateway next.', | ||
agentHost, | ||
agentOpts.port, | ||
{ | ||
error: localhostCheckErr | ||
} | ||
`No Instana host agent is running on ${agentHost}:${agentOpts.port}: ${localhostCheckErr}. Trying the default ` + | ||
'gateway next.' | ||
); | ||
@@ -66,9 +62,10 @@ | ||
if (getDefaultGatewayErr) { | ||
logger.debug('Error while trying to determine the default gateway.', { error: getDefaultGatewayErr }); | ||
logger.warn( | ||
'The Instana host agent cannot be contacted via %s:%s and the default gateway cannot be determined. ' + | ||
'Scheduling another attempt to establish a connection to the Instana host agent in %s ms.', | ||
agentHost, | ||
agentOpts.port, | ||
retryTimeoutMillis | ||
`The Instana host agent cannot be reached via ${agentHost}:${agentOpts.port} and the default gateway ` + | ||
`cannot be determined. Details: Error for the connection attempt: ${safelyExtractErrorMessage( | ||
localhostCheckErr | ||
)}; error for determining the gateway: ${safelyExtractErrorMessage( | ||
getDefaultGatewayErr | ||
)}. The Instana host agent might not be ready yet, scheduling another attempt to establish a connection ` + | ||
`in ${retryTimeoutMillis} ms.` | ||
); | ||
@@ -87,13 +84,9 @@ const defaultGatewayRetryTimeout = setTimeout(enter, retryTimeoutMillis, ctx); | ||
logger.debug('Failed to reach the Instana host agent via the default gateway %s', defaultGateway, { | ||
error: defaultGatewayCheckErr | ||
}); | ||
logger.warn( | ||
'The Instana host agent can neither be reached via %s:%s nor via the default gateway %s:%s. ' + | ||
'Scheduling another attempt to establish a connection to the Instana host agent in %s ms.', | ||
agentHost, | ||
agentOpts.port, | ||
defaultGateway, | ||
agentOpts.port, | ||
retryTimeoutMillis | ||
`The Instana host agent can neither be reached via ${agentHost}:${agentOpts.port} nor via the default ` + | ||
`gateway ${defaultGateway}:${agentOpts.port}. Details: Error for the first attempt: ` + | ||
`${safelyExtractErrorMessage(localhostCheckErr)}; error for the second attempt: ${safelyExtractErrorMessage( | ||
defaultGatewayCheckErr | ||
)}. The Instana host agent might not be ready yet, scheduling another attempt to establish a connection ` + | ||
`in ${retryTimeoutMillis} ms.` | ||
); | ||
@@ -135,6 +128,8 @@ const checkHostRetryTimeout = setTimeout(enter, retryTimeoutMillis, ctx); | ||
agent: http.agent, | ||
method: 'GET' | ||
method: 'GET', | ||
// timeout for establishing a connection | ||
timeout: requestTimeout | ||
}, | ||
res => { | ||
if (res.headers.server === EXPECTED_SERVER_HEADER) { | ||
if (res.headers.server === expectedServerHeader) { | ||
cb(null); | ||
@@ -144,3 +139,5 @@ } else { | ||
new Error( | ||
`Host ${host}:${agentOpts.port} did not respond with expected agent header. Got: ${res.headers.server}` | ||
`The attempt to connect to the Instana host agent on ${host}:${agentOpts.port} has failed, the ` + | ||
`response did not contain the expected "Server" header. Expected ${expectedServerHeader}, ` + | ||
`but received: ${res.headers.server}` | ||
) | ||
@@ -153,12 +150,25 @@ ); | ||
} catch (e) { | ||
cb(new Error(`Host lookup failed due to: ${e.message}`)); | ||
cb( | ||
new Error( | ||
`The attempt to connect to the Instana host agent on ${host}:${agentOpts.port} has failed with the following ` + | ||
`error: ${e.message}` | ||
) | ||
); | ||
return; | ||
} | ||
req.setTimeout(5000, function onTimeout() { | ||
cb(new Error('Host check timed out')); | ||
req.on('timeout', function onTimeout() { | ||
cb(new Error(`The attempt to connect to the Instana host agent on ${host}:${agentOpts.port} has timed out`)); | ||
}); | ||
// additional idle timeout (that is, not getting a response after establishing a connection) | ||
req.setTimeout(requestTimeout); | ||
req.on('error', err => { | ||
cb(new Error(`Host check failed: ${err.message}`)); | ||
cb( | ||
new Error( | ||
`The attempt to connect to the Instana host agent on ${host}:${agentOpts.port} has failed with the following ` + | ||
`error: ${err.message}` | ||
) | ||
); | ||
}); | ||
@@ -170,2 +180,15 @@ | ||
/** | ||
* @param {Error} error | ||
*/ | ||
function safelyExtractErrorMessage(error) { | ||
if (error == null) { | ||
return null; | ||
} | ||
if (error.message) { | ||
return error.message; | ||
} | ||
return error; | ||
} | ||
/** | ||
* @param {string} host | ||
@@ -172,0 +195,0 @@ */ |
122633
2743
+ Added@instana/autoprofile@2.21.1(transitive)
+ Added@instana/core@2.21.1(transitive)
+ Added@instana/shared-metrics@2.21.1(transitive)
- Removed@instana/autoprofile@2.21.0(transitive)
- Removed@instana/core@2.21.0(transitive)
- Removed@instana/shared-metrics@2.21.0(transitive)
Updated@instana/core@2.21.1