Skip to content
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

OT Exporter retry when there are network issues #12905

Merged
merged 4 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/monitor/opentelemetry-exporter-azure-monitor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 1.0.0-beta.1 (Unreleased)

- OT Exporter retry when there are network issues
- OpenTelemetry Exporter using Resources API to get service properties
- Rename package to `@azure/opentelemetry-exporter-azure-monitor`
- [BREAKING] Deprecate all configuration options except for `connectionString`
- [BREAKING] Removed support for `TelemetryProcessor`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { Logger } from "@opentelemetry/api";
import { ConsoleLogger, LogLevel, ExportResult } from "@opentelemetry/core";
import { ReadableSpan, SpanExporter } from "@opentelemetry/tracing";
import { RestError } from "@azure/core-http";
import { ConnectionStringParser } from "../utils/connectionStringParser";
import { HttpSender, FileSystemPersist } from "../platform";
import {
Expand Down Expand Up @@ -105,12 +106,20 @@ export class AzureMonitorTraceExporter implements SpanExporter {
return ExportResult.FAILED_NOT_RETRYABLE;
}
} catch (senderErr) {
// Request failed -- always retry
this._logger.error(
"Envelopes could not be exported and are not retriable. Error message:",
senderErr.message
);
return ExportResult.FAILED_NOT_RETRYABLE;
if (this._isNetworkError(senderErr)) {
this._logger.error(
"Retrying due to transient client side error. Error message:",
senderErr.message
);
return ExportResult.FAILED_RETRYABLE;
}
else {
this._logger.error(
"Envelopes could not be exported and are not retriable. Error message:",
senderErr.message
);
return ExportResult.FAILED_NOT_RETRYABLE;
}
}
}

Expand Down Expand Up @@ -140,4 +149,21 @@ export class AzureMonitorTraceExporter implements SpanExporter {
this._logger.warn(`Failed to fetch persisted file`, err);
}
}

private _isNetworkError(error: Error): boolean {
if (error instanceof RestError) {
if (
error &&
error.code &&
(error.code === "ETIMEDOUT" ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These all seems sensible to me but I'm wondering how you curated this list?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error.code === "ESOCKETTIMEDOUT" ||
error.code === "ECONNREFUSED" ||
error.code === "ECONNRESET" ||
error.code === "ENOENT")
) {
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ describe("#AzureMonitorBaseExporter", () => {

describe("Sender/Persister Controller", () => {
describe("#exportEnvelopes()", () => {
const scope = nock(DEFAULT_BREEZE_ENDPOINT).post("/v2/track");
const scope = nock(DEFAULT_BREEZE_ENDPOINT)
.log(console.log)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log in here for debugging only? Should it be removed before we commit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, removing it

.post("/v2/track");
const envelope = {
name: "Name",
time: new Date()
Expand Down