Skip to content

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

Merged
lzchen merged 12 commits into
open-telemetry:mainfrom
herin049:feat/logging-force-flush
Jul 13, 2026
Merged

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

Conversation

@herin049

@herin049 herin049 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #5359

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 ✌️ .

Comment thread opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/__init__.py Outdated
@github-project-automation github-project-automation Bot moved this to Reviewed PRs that need fixes in Python PR digest Jun 24, 2026
@github-project-automation github-project-automation Bot moved this from Reviewed PRs that need fixes to Approved PRs in Python PR digest Jul 10, 2026
@xrmx
xrmx requested a review from DylanRussell July 10, 2026 15:12
@carlosalberto

Copy link
Copy Markdown
Contributor

#5403 created as a follow up, so this PR doesn't get stuck.

@lzchen lzchen 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.

This will cause previous child implementations to require the new method but I think this is fine to enforce.

@lzchen
lzchen added this pull request to the merge queue Jul 13, 2026
Merged via the queue into open-telemetry:main with commit 23dc0b2 Jul 13, 2026
560 checks passed
@github-project-automation github-project-automation Bot moved this from Approved PRs to Done in Python PR digest Jul 13, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Python Logging API/SDK RC Jul 13, 2026
Eason09053360 added a commit to Eason09053360/opentelemetry-python that referenced this pull request Jul 14, 2026
…pen-telemetry#5294)

* opentelemetry-sdk: add 'force_flush' method to LogRecordExporter ABC

* update unit tests

* update 'force_flush' doc-string

* add changelog fragment

* switch timeout millis from float to int

* update remaining type hints
liustve added a commit to aws-observability/aws-otel-python-instrumentation that referenced this pull request Jul 22, 2026
Automated update of OpenTelemetry dependencies.

**Build Status:** ❌
[failure](https://github.com/aws-observability/aws-otel-python-instrumentation/actions/runs/29554721211)

**Updated versions:**
- [OpenTelemetry
Python](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.44.0):
1.44.0
- [OpenTelemetry
Contrib](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.65b0):
0.65b0
-
[opentelemetry-sdk-extension-aws](https://pypi.org/project/opentelemetry-sdk-extension-aws/2.1.0/):
2.1.0
-
[opentelemetry-propagator-aws-xray](https://pypi.org/project/opentelemetry-propagator-aws-xray/1.0.2/):
1.0.2
-
[opentelemetry-instrumentation-openai-agents-v2](https://pypi.org/project/opentelemetry-instrumentation-openai-agents-v2/0.1.0/):
0.1.0

**Upstream releases with breaking changes:**
Note: the mechanism to detect upstream breaking changes is not perfect.
Be sure to check all new releases and understand if any additional
changes need to be addressed.

**opentelemetry-python:**
- [Version
1.44.0/0.65b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.44.0)

**opentelemetry-python-contrib:**
- [Version
1.44.0/0.65b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.65b0)

*Description of changes:*

- Drops the `opentelemetry-instrumentation-elasticsearch` runtime
dependency (from `pyproject.toml`, the lite-mode instrumentor map, and
the nightly bot's `CONTRIB_DEPS` allowlist), removed entirely upstream
now that all supported `elasticsearch` versions ship native OTel
instrumentation:

open-telemetry/opentelemetry-python-contrib#4759

- Migrates the three Events API call sites (`llo_handler.py`,
`debugger/_snapshot_otlp_emitter.py`,
`aws_opentelemetry_configurator._init_logging`) to emit `LogRecord` with
the `event_name` field via the Logs API, after upstream removed the
deprecated Events API/SDK (`opentelemetry._events` /
`opentelemetry.sdk._events`):
  open-telemetry/opentelemetry-python#5293
To keep the OTLP wire shape byte-identical to v0.18.0 for downstream
consumers, the migration explicitly preserves the two things the old
`Event` class auto-injected: the `event.name` attribute (which the GenAI
E2E `CWLogValidator` asserts on) and `severity_number=INFO`. Verified by
encoding both versions' output through the OTLP proto encoder and
diffing — the only deltas are the additive top-level `eventName` field
and SDK-generated resource metadata (`telemetry.sdk.version`,
`service.instance.id`).

- Implements `force_flush` on `CompactConsoleLogRecordExporter`,
required after upstream added it as an abstract method on the
`LogRecordExporter` ABC (instantiation otherwise fails with
`TypeError`):
  open-telemetry/opentelemetry-python#5294

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Eric Zhang <eric.zhang6811@gmail.com>
Co-authored-by: Steve Liu <liustve@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Logging stability review: [minor] No force_flush on LogRecordExporter

7 participants