-
Notifications
You must be signed in to change notification settings - Fork 40
fix(collector): optimized metrics timeout handling #2084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b5601f1
912d431
7ec6193
657002d
3753ff7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,9 @@ if (typeof process.env.INSTANA_TRACER_METRICS_INTERVAL === 'string') { | |
| } | ||
| } | ||
|
|
||
| /** @type {number | null} */ | ||
| let originalTracingMetricsDelay = null; | ||
|
|
||
| /** @type {NodeJS.Timeout} */ | ||
| let tracingMetricsTimeout = null; | ||
|
|
||
|
|
@@ -183,23 +186,38 @@ function sendTracingMetrics() { | |
|
|
||
| agentConnection.sendTracingMetricsToAgent(payload, error => { | ||
| if (error) { | ||
| logger.info( | ||
| `Error received while trying to send tracing metrics to agent: ${error?.message}.` + | ||
| ' This will not affect monitoring or tracing.' | ||
| ); | ||
| if (typeof error.message === 'string' && error.message.indexOf('Got status code 404')) { | ||
| if (typeof error.message === 'string' && error.message.indexOf('Got status code 404') !== -1) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The good old classic bug.
Thats why
Appeared in the logs. But that was wrong. We do not receive a 404 on timeout error. |
||
| logger.info( | ||
| 'Apparently the version of the Instana host agent on this host does not support the POST /tracermetrics ' + | ||
| 'endpoint, will stop sending tracing metrics.' | ||
| 'endpoint, will stop sending tracing metrics. This will not affect monitoring or tracing.' | ||
| ); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| logger.warn( | ||
| `Error received while trying to send tracing metrics to agent: ${error?.message}.` + | ||
| ' This will not affect monitoring or tracing. Will retry sending tracing metrics on next interval.' | ||
| ); | ||
|
|
||
| if (originalTracingMetricsDelay === null) { | ||
| originalTracingMetricsDelay = tracingMetricsDelay; | ||
| } | ||
|
|
||
| // Reduce noisyness, increase retry time on error. | ||
| tracingMetricsDelay += 1000; | ||
| } else if (originalTracingMetricsDelay !== null) { | ||
| // on success, restore original delay | ||
| tracingMetricsDelay = originalTracingMetricsDelay; | ||
| originalTracingMetricsDelay = null; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a tiny logic to increase the retry time for sending tracer metrics to /tracermetrics endpoint on error. Please review carefully.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SInce this is metrics only, I think this should be fine |
||
| } | ||
|
|
||
| scheduleTracingMetrics(); | ||
| }); | ||
| } | ||
|
|
||
| function scheduleTracingMetrics() { | ||
| logger.debug(`Sending tracing metrics to /tracermetrics in ${tracingMetricsDelay} ms...`); | ||
| tracingMetricsTimeout = setTimeout(sendTracingMetrics, tracingMetricsDelay); | ||
| tracingMetricsTimeout.unref(); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This resolves the warning