-
Notifications
You must be signed in to change notification settings - Fork 758
Description
Describe your environment
OS: Ubuntu
Python version: Python 3.12.11
SDK version: 1.35.0
API version: 1.35.0
What happened?
The OTLPSpanExporter, OTLPMetricExporter as well as the OTLPLogExporter have a "bug" in their _export function:
Lines 146 to 162 in cf31a69
| try: | |
| resp = self._session.post( | |
| url=self._endpoint, | |
| data=data, | |
| verify=self._certificate_file, | |
| timeout=timeout_sec, | |
| cert=self._client_cert, | |
| ) | |
| except ConnectionError: | |
| resp = self._session.post( | |
| url=self._endpoint, | |
| data=data, | |
| verify=self._certificate_file, | |
| timeout=timeout_sec, | |
| cert=self._client_cert, | |
| ) | |
| return resp |
Every of the exporters does some sort of retry via a try-except block. Now if the OTLP collector is not available for whatever reason this will always fail and is not caught within the exporters.
It is later caught in:
opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/_shared_internal/__init__.py
Lines 167 to 170 in d327927
| except Exception: # pylint: disable=broad-exception-caught | |
| self._logger.exception( | |
| "Exception while exporting %s.", self._exporting | |
| ) |
I'm not sure if this is intended behavior. Also the retry loop is never excecuted in case of this raising an exception:
Line 171 in cf31a69
| for retry_num in range(_MAX_RETRYS): |
Initially it annoyed me because it was polluting my sys.out with really long error traces. I know that I could simply disable the logger but I still would like to see that exporting failed somehow. Just not that long error message.
Steps to Reproduce
- Configure a
OTLPExporterto export to an address where no collector is running - Create telemetry.
Expected Result
I would expect that there is a small error message like:
Failed to export spans. Reason: ...
Actual Result
The full error trace is logged to the sys.out and no retry loop is executed.
Additional context
I've already created a pull request as a suggestion but I assume it's not the way how it should be handled.
#4709
Would you like to implement a fix?
Yes
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.