formachines / errata

Errata / PyPI / opentelemetry-sdk

opentelemetry.sdk._events removed in opentelemetry-sdk 1.45.1

In our sandbox runs up to 2026-10-27, claude-sonnet-5-5, gemini-3.8-flash and gpt-6.1-sol wrote from opentelemetry._events import Event for opentelemetry-sdk. It fails on 1.45.1 with ModuleNotFoundError (changed between 1.40.0 and 1.45.1). There is no direct replacement in the new version.

What to do
no direct replacement
Output
no replacement — not comparable
Patch
nothing to apply word for word
Auto-apply
not allowed
Seen in
3 models
Worked / failed
6 / 0
Last verified
2026-10-27

What to do

Not for automatic application — format removed: there is no replacement to apply. Show this correction to the user as a lead. opentelemetry.sdk._events is not available in opentelemetry-sdk 1.45.1; remove or replace this use. The same code works on opentelemetry-sdk 1.40.0: pin a version before 1.45.1 if you cannot change the code. Release notes: logger.emit(LogRecord(event_name="my.event", body=...))

Automatic application: not allowed — the fix's output was not compared; the patch gives not_applicable when applied word for word. Automatic application is allowed only when proof.equivalent is true and proof.applicability.status is applies; otherwise show the correction to the user as a lead and do not apply it on your own. The change itself is described by kind (removed); the checks are in proof; neither follows from the other.

How to tell this applies to your code

Old code

from opentelemetry._events import Event

No direct replacement: the verified example below shows code that works without it.

Error on 1.45.1:

ModuleNotFoundError: No module named 'opentelemetry._events'

Other verified fixes

The fix above passed 4 times. These also passed in the sandbox for the same error; pick the one that matches what your code needs.

Replace the line · passed 2 times · claude-sonnet-5-5, gemini-3.8-flash · patch: incomplete: old names remain

from opentelemetry._events import Event
from opentelemetry._logs import LogRecord

Not for automatic application — after the patch the example still uses Event, _events, which the verified example does not: the patch covers part of the change. Show this correction to the user as a lead. Review before applying: this fix runs on opentelemetry-sdk 1.45.1, but its printed output differs from what the original printed on 1.40.0 (observed stdout of one example) — it may do different work. Replace the old line with the new one; the rest of the code can stay.

Alternatives are leads for the user, not for automatic application: Automatic application is allowed only when proof.equivalent is true and proof.applicability.status is applies; otherwise show the correction to the user as a lead and do not apply it on your own.

Sandbox proof
Scriptopentelemetry-sdk versionResult
Code the models wrote1.40.0works
Code the models wrote1.45.1fails: ModuleNotFoundError
Verified example below1.45.1works
Output of the verified example1.45.1not compared: the API was removed without a replacement, the fix drops that work
Patch applied word for word to the example1.45.1no literal patch to apply (removed or added code, or the old line is not found once) — format removed: there is no replacement to apply

Verified example for opentelemetry-sdk 1.45.1

from opentelemetry.sdk._logs import LoggerProvider
from opentelemetry.sdk._logs.export import (
    ConsoleLogExporter,
    SimpleLogRecordProcessor,
)


def main() -> None:
    # Logger provider that exports log records to the console (stdout)
    logger_provider = LoggerProvider()
    logger_provider.add_log_record_processor(
        SimpleLogRecordProcessor(ConsoleLogExporter())
    )

    # Get a logger for the "auth-service"
    logger = logger_provider.get_logger("auth-service")

    # Emit the "user.login" event as a log record with event_name set
    logger.emit(
        event_name="user.login",
        body={"username": "alice"},
        attributes={"login.method": "password"},
    )

    # Ensure everything is flushed and cleaned up
    logger_provider.force_flush()
    logger_provider.shutdown()


if __name__ == "__main__":
    main()

Source

`opentelemetry-api`, `opentelemetry-sdk`: Removed deprecated Events API/SDK. Use `LogRecord` with the `event_name` field set instead. ([#5293](https://github.com/open-telemetry/opentelemetry-python/pull/5293))

Release notes · Seen in: claude-sonnet-5-5, gemini-3.8-flash, gpt-6.1-sol · First seen 2026-10-20 · Last verified 2026-10-27 · All corrections for opentelemetry-sdk

For agents