opentelemetry-exporter-otlp-proto-http: Generalize OTLP HTTP exporters to allow using alternative HTTP clients#5169
Conversation
|
If we were ok with dropping requests entirely, we could also get rid of the custom retry/backoffs code and use https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html#utilities |
Great suggestion, although my thought is that we should still stick to explicitly handling retries in the |
Description
Refinement of #5164
Motivation
The three OTLP/HTTP signal exporters previously each carried a duplicated copy of session setup, compression, and retry/backoff logic. This PR introduces a
BaseHTTPTransportABC so the underlying HTTP library is swappable, and switches the exporters tourllib3by default (a lighter weight alternative torequests)Note that as implemented in this PR, backwards compatibility is preserved. In the case that the legacy
sessionparameter is passed in, or a credential provider is provided via theOTEL_PYTHON_EXPORTER_OTLP_HTTP_*_CREDENTIAL_PROVIDERenvironment variable, theRequestsHTTPTransportwill be used instead of theUrllib3HTTPTransport.One open question for maintainers is if we think it safe to drop
requestsas a required dependency. Given that theRequestsHTTPTransportwill only be used if the user explicitly passes arequestssession into the constructor or initializesOTEL_PYTHON_EXPORTER_OTLP_HTTP_*_CREDENTIAL_PROVIDERenvironment variable, it is mostly safe to assume that the user must already haverequestsinstalled as a dependency. If the user does not manually construct a session,requestswill no longer be imported/used - hence it's preferable to remove it as a dependency. The only "breaking" change is thatrequestswill no longer be a transitive dependency of the exporter package, so any users relying on this will encounter an import error.Follow-ups:
httpx,urllib, etc.).opentelemetry_otlp_http_transportentry point +OTEL_PYTHON_OTLP_HTTP_TRANSPORTenv var can be added up so users can plug in a custom transport implementation without code changes.Fixes #3439 and #4171
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Tox
Does This PR Require a Contrib Repo Change?
Checklist: