-
Notifications
You must be signed in to change notification settings - Fork 761
Implement partial success logging in OTLP exporters #4805
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
michaelsafyan
wants to merge
10
commits into
open-telemetry:main
Choose a base branch
from
michaelsafyan:issue4803_partial_success_logging
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.
+60
−1
Open
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1008906
Implement partial success logging.
michaelsafyan 72b2325
Add tests.
michaelsafyan baefbc0
Merge branch 'open-telemetry:main' into issue4803_partial_success_log…
michaelsafyan e008658
Fix: OTEL_LOG_LEVEL default to info for partial success logging.
michaelsafyan d40ab67
Fixes partial success logging to apply at only 'verbose' and 'debug' …
michaelsafyan 5725ccd
Simplify tests to address pylint issue and reformat with ruff.
michaelsafyan 818456e
Undo changes to environment variable docs
michaelsafyan 10aedae
Merge branch 'main' into issue4803_partial_success_logging
michaelsafyan b44507a
Merge branch 'main' into issue4803_partial_success_logging
michaelsafyan d84b22a
Remove conditional logic around recording partial success.
michaelsafyan 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
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
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 |
|---|---|---|
|
|
@@ -93,6 +93,7 @@ | |
| OTEL_EXPORTER_OTLP_HEADERS, | ||
| OTEL_EXPORTER_OTLP_INSECURE, | ||
| OTEL_EXPORTER_OTLP_TIMEOUT, | ||
| OTEL_LOG_LEVEL, | ||
| ) | ||
| from opentelemetry.sdk.metrics.export import MetricExportResult, MetricsData | ||
| from opentelemetry.sdk.resources import Resource as SDKResource | ||
|
|
@@ -257,6 +258,11 @@ def _get_credentials( | |
| return ssl_channel_credentials() | ||
|
|
||
|
|
||
| def _should_log_partial_responses(): | ||
| otel_log_level = environ.get(OTEL_LOG_LEVEL, "info").lower() | ||
| return otel_log_level in ["verbose", "debug"] | ||
|
|
||
|
|
||
| # pylint: disable=no-member | ||
| class OTLPExporterMixin( | ||
| ABC, Generic[SDKDataT, ExportServiceRequestT, ExportResultT, ExportStubT] | ||
|
|
@@ -293,6 +299,9 @@ def __init__( | |
| self._endpoint = endpoint or environ.get( | ||
| OTEL_EXPORTER_OTLP_ENDPOINT, "http://localhost:4317" | ||
| ) | ||
| self._partial_response_logging_enabled = ( | ||
| _should_log_partial_responses() | ||
| ) | ||
|
|
||
| parsed_url = urlparse(self._endpoint) | ||
|
|
||
|
|
@@ -374,6 +383,15 @@ def _translate_data( | |
| ) -> ExportServiceRequestT: | ||
| pass | ||
|
|
||
| def _log_partial_success(self, partial_success): | ||
|
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. nit: can we just inline this code instead of having a function (same thing below) |
||
| logger.debug("Partial success:\n%s", partial_success) | ||
|
|
||
| def _process_response(self, response): | ||
| if self._partial_response_logging_enabled and response.HasField( | ||
| "partial_success" | ||
| ): | ||
| self._log_partial_success(response.partial_success) | ||
|
|
||
| def _export( | ||
| self, | ||
| data: SDKDataT, | ||
|
|
@@ -388,11 +406,12 @@ def _export( | |
| deadline_sec = time() + self._timeout | ||
| for retry_num in range(_MAX_RETRYS): | ||
| try: | ||
| self._client.Export( | ||
| response = self._client.Export( | ||
| request=self._translate_data(data), | ||
| metadata=self._headers, | ||
| timeout=deadline_sec - time(), | ||
| ) | ||
| self._process_response(response) | ||
| return self._result.SUCCESS # type: ignore [reportReturnType] | ||
| except RpcError as error: | ||
| retry_info_bin = dict(error.trailing_metadata()).get( # type: ignore [reportAttributeAccessIssue] | ||
|
|
||
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
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.
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.
We add a
DuplicateFilterto theloggeron line 116 (as an aside I don't like the github code review tool, which doesn't let me add a comment to a line that wasn't modified...)I'm thinking we should update that to reference
record.linenoinstead ofrecord.msgwhich could be unique.... and that is sufficient to suppress noisy logging, and also avoid the endless logging issues...If you want to take a stab at that change here that'd be great, if not I think we can proceed without that and I can make it separately..
I don't think we should special case the logging exporter because we have this duplicate filter thing.