Skip to content

opentelemetry-sdk: add 'force_flush' method to LogRecordExporter ABC#5294

Open
herin049 wants to merge 7 commits into
open-telemetry:mainfrom
herin049:feat/logging-force-flush
Open

opentelemetry-sdk: add 'force_flush' method to LogRecordExporter ABC#5294
herin049 wants to merge 7 commits into
open-telemetry:mainfrom
herin049:feat/logging-force-flush

Conversation

@herin049

Copy link
Copy Markdown
Contributor

Description

The OpenTelemetry SDK specification for logs documents the force flush operation, but this function is currently not required for log exporter implementation. This PR addresses this by adding force_flush to the LogRecordExporter ABC.

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)
  • This change requires a documentation update

How Has This Been Tested?

uv run tox -e py314-test-opentelemetry-sdk

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@herin049 herin049 requested a review from a team as a code owner June 11, 2026 21:00
@xrmx xrmx moved this from Todo to In Progress in Python Logging API/SDK RC Jun 24, 2026

@ocelotl ocelotl left a comment

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.

Please review the type and value of the timeout, besides that, I am ready to approve ✌️ .

"""

@abc.abstractmethod
def force_flush(self, timeout_millis: float = 10_000) -> bool:

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.

I'm not sure the type here should be a float. Also, we are using different values across the SDK:

tigre@sandokan:~/github/ocelotl/opentelemetry/opentelemetry-python/opentelemetry-sdk/src$ ack "def force_flush"
opentelemetry/sdk/_shared_internal/__init__.py
243:    def force_flush(self, timeout_millis: int | None = None) -> bool:

opentelemetry/sdk/trace/__init__.py
134:    def force_flush(self, timeout_millis: int = 30000) -> bool:  # pylint: disable=no-self-use
193:    def force_flush(self, timeout_millis: int = 30000) -> bool:
299:    def force_flush(self, timeout_millis: int = 30000) -> bool:
1458:    def force_flush(self, timeout_millis: int = 30000) -> bool:

opentelemetry/sdk/trace/export/__init__.py
85:    def force_flush(self, timeout_millis: int = 30000) -> bool:  # pyright: ignore[reportReturnType]
141:    def force_flush(self, timeout_millis: int = 30000) -> bool:
235:    def force_flush(self, timeout_millis: int | None = None) -> bool:
350:    def force_flush(self, timeout_millis: int = 30000) -> bool:

opentelemetry/sdk/trace/export/in_memory_span_exporter.py
51:    def force_flush(self, timeout_millis: int = 30000) -> bool:

opentelemetry/sdk/_events/__init__.py
92:    def force_flush(self, timeout_millis: int = 30000) -> bool:

opentelemetry/sdk/_logs/_internal/__init__.py
355:    def force_flush(self, timeout_millis: int = 30000) -> bool:
400:    def force_flush(self, timeout_millis: int = 30000) -> bool:
472:    def force_flush(self, timeout_millis: int = 30000) -> bool:
925:    def force_flush(self, timeout_millis: int = 30000) -> bool:

opentelemetry/sdk/_logs/_internal/export/in_memory_log_exporter.py
49:    def force_flush(self, timeout_millis: float = 10_000) -> bool:

opentelemetry/sdk/_logs/_internal/export/__init__.py
123:    def force_flush(self, timeout_millis: float = 10_000) -> bool:
172:    def force_flush(self, timeout_millis: float = 10_000) -> bool:
261:    def force_flush(self, timeout_millis: int = 30000) -> bool:  # pylint: disable=no-self-use
349:    def force_flush(self, timeout_millis: int | None = None) -> bool:

opentelemetry/sdk/metrics/_internal/__init__.py
559:    def force_flush(self, timeout_millis: float = 10_000) -> bool:

opentelemetry/sdk/metrics/_internal/export/__init__.py
122:    def force_flush(self, timeout_millis: float = 10_000) -> bool:
177:    def force_flush(self, timeout_millis: float = 10_000) -> bool:
403:    def force_flush(self, timeout_millis: float = 10_000) -> bool:
604:    def force_flush(self, timeout_millis: float = 10_000) -> bool:

@github-project-automation github-project-automation Bot moved this to Reviewed PRs that need fixes in Python PR digest Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress
Status: Reviewed PRs that need fixes

Development

Successfully merging this pull request may close these issues.

3 participants