Skip to content

Abstract out OTLP http exporter logic#5160

Open
lorenzoronzani wants to merge 9 commits intoopen-telemetry:mainfrom
lorenzoronzani:refactor/http-exporter-logic
Open

Abstract out OTLP http exporter logic#5160
lorenzoronzani wants to merge 9 commits intoopen-telemetry:mainfrom
lorenzoronzani:refactor/http-exporter-logic

Conversation

@lorenzoronzani
Copy link
Copy Markdown

@lorenzoronzani lorenzoronzani commented Apr 29, 2026

Description

This PR contains the refactoring required inside the http_exporter_logic component. The idea is to remove the duplicated code abstracting out inside a common section

Fixes #2990

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (functionalities are the same, interfaces also but the logic is moved inside codebase)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Executed component specific unit tests using the following command uv run tox -e py312-test-opentelemetry-exporter-otlp-proto-http

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No. No, it's just an internal refactoring

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added/updated
  • Documentation has been updated, this is a pure internal refactor, not interfaces update so I don't think that a documentation update it's required

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Apr 29, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@lorenzoronzani
Copy link
Copy Markdown
Author

/easycla

@lorenzoronzani lorenzoronzani force-pushed the refactor/http-exporter-logic branch from 2a75552 to 4405d3e Compare April 29, 2026 08:11
client_cert: Optional[Union[str, Tuple[str, str]]],
timeout: float,
shutdown_event: threading.Event,
result: Any,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a better Type for this param ?

backoff_seconds = 2**retry_num * random.uniform(0.8, 1.2)
export_error: Optional[Exception] = None
try:
resp = _export(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use the walrus operator here to shorten it a tiny bit...

if (resp := _export()).ok:

_logger.warning("Shutdown in progress, aborting retry.")
break
return LogRecordExportResult.FAILURE
success = _export_with_retries(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could shorten it a bit by just returning inline here.. return LogRecordExport.success if _export.... else return ... There's also probably a way to pass LogRecordExportResult into the function and return it directly using typing.generics but I couldn't figure that out easily..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Abstract out OTLP http exporter logic

2 participants