Skip to content

Retry loop never executed in OTLP HTTP exporters #4712

@pafi-code

Description

@pafi-code

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:

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:

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:

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

  1. Configure a OTLPExporter to export to an address where no collector is running
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions