Repository navigation
opentelemetry-exporter-otlp-proto-grpc: reconstruct client on first DEADLINE_EXCEEDED error #5707
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
Open
herin049
wants to merge
7
commits into
open-telemetry:main
Choose a base branch
from
herin049:fix/grpc-deadline-exceeded
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+72
−17
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0588bcf
opentelemetry-exporter-otlp-proto-grpc: reconstruct client on first D…
herin049 be67249
add changelog fragment
herin049 d6cff44
update channel reconstruction policy
herin049 38d7a7e
Merge branch 'main' into fix/grpc-deadline-exceeded
herin049 58ec0b8
Merge branch 'main' into fix/grpc-deadline-exceeded
herin049 02eb31f
Merge branch 'main' into fix/grpc-deadline-exceeded
herin049 e19c3de
Merge branch 'main' into fix/grpc-deadline-exceeded
herin049 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| `opentelemetry-exporter-otlp-proto-grpc`: reconstruct gRPC channel after 3 consecutive `UNAVAILABLE` or `DEADLINE_EXCEEDED` errors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,6 +120,8 @@ | |
| ] | ||
| ) | ||
| _MAX_RETRYS = 6 | ||
| _CHANNEL_RECONNECT_ERROR_CODES = frozenset([StatusCode.UNAVAILABLE, StatusCode.DEADLINE_EXCEEDED]) | ||
| _CHANNEL_RECONNECT_ERROR_THRESHOLD = 3 | ||
| logger = getLogger(__name__) | ||
| # This prevents logs generated when a log fails to be written to generate another log which fails to be written etc. etc. | ||
| logger.addFilter(DuplicateFilter()) | ||
|
|
@@ -351,6 +353,7 @@ def __init__( | |
|
|
||
| self._channel = None | ||
| self._client = None | ||
| self._consecutive_reconnect_errors = 0 | ||
|
|
||
| self._shutdown_in_progress = threading.Event() | ||
| self._shutdown = False | ||
|
|
@@ -435,6 +438,7 @@ def _export( | |
| metadata=self._headers, | ||
| timeout=deadline_sec - time(), | ||
| ) | ||
| self._consecutive_reconnect_errors = 0 | ||
| return self._result.SUCCESS # type: ignore [reportReturnType] | ||
| except RpcError as error: | ||
| retry_info_bin = dict(error.trailing_metadata()).get( # type: ignore [reportAttributeAccessIssue] | ||
|
|
@@ -447,11 +451,18 @@ def _export( | |
| retry_info.ParseFromString(retry_info_bin) | ||
| backoff_seconds = retry_info.retry_delay.seconds + retry_info.retry_delay.nanos / 1.0e9 | ||
|
|
||
| # For UNAVAILABLE errors, reinitialize the channel to force reconnection | ||
| if error.code() == StatusCode.UNAVAILABLE and retry_num == 0: # type: ignore | ||
|
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. gRPC not able to purge by itself? cc @aabmass |
||
| # After consecutive UNAVAILABLE or DEADLINE_EXCEEDED errors, reinitialize | ||
| # the channel to force reconnection. | ||
| if error.code() in _CHANNEL_RECONNECT_ERROR_CODES: # type: ignore [reportAttributeAccessIssue] | ||
|
herin049 marked this conversation as resolved.
Resolved
|
||
| self._consecutive_reconnect_errors += 1 | ||
| else: | ||
| self._consecutive_reconnect_errors = 0 | ||
| if self._consecutive_reconnect_errors >= _CHANNEL_RECONNECT_ERROR_THRESHOLD: | ||
| self._consecutive_reconnect_errors = 0 | ||
| logger.debug( | ||
| "Reinitializing gRPC channel for %s exporter due to UNAVAILABLE error", | ||
| "Reinitializing gRPC channel for %s exporter due to %s error", | ||
| self._exporting, | ||
| error.code(), # type: ignore [reportAttributeAccessIssue] | ||
| ) | ||
| try: | ||
| if self._channel: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.