Errata / PyPI / opentelemetry-api
opentelemetry._events behaviour changed in opentelemetry-api 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 ( for opentelemetry-api. It fails on 1.45.1 with ModuleNotFoundError (changed between 1.40.0 and 1.45.1). Use from opentelemetry._logs import ( instead.
- What to do
- replace the line
- Output
- differs on one example — review first
- Patch
- fails when applied word for word
- Auto-apply
- not allowed
- Seen in
- 3 models
- Worked / failed
- 7 / 0
- Last verified
- 2026-10-27
What to do
Not for automatic application — the patched example does not run on 1.45.1: exit code 1, ImportError: cannot import name 'Event' from 'opentelemetry._logs' (/usr/local/lib/python3.11/site-packages/opentelemetry/_logs/__init__.py). Show this correction to the user as a lead. Review before applying: this fix runs on opentelemetry-api 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.
Automatic application: not allowed — the fix's output differs from the original's; the patch gives fails 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 (behaviour changed); the checks are in proof; neither follows from the other.
How to tell this applies to your code
- opentelemetry-api version 1.45.1 or newer is installed (checked on 1.45.1; changed between 1.40.0 and 1.45.1).
- Your code uses:
opentelemetry._events - Or it already failed with:
ModuleNotFoundError: No module named 'opentelemetry._events'(every correction for this error)
Old and new code
from opentelemetry._events import (from opentelemetry._logs import (
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 3 times · claude-sonnet-5-5, gemini-3.8-flash · patch: incomplete: old names remain
from opentelemetry._events import Event, get_event_loggerfrom opentelemetry._logs import LogRecord, get_loggerNot for automatic application — after the patch the example still uses get_event_logger, 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-api 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.
| Script | opentelemetry-api version | Result |
|---|---|---|
| Code the models wrote | 1.40.0 | works |
| Code the models wrote | 1.45.1 | fails: ModuleNotFoundError |
| Verified example below | 1.45.1 | works |
| Output of the verified example | 1.45.1 | DIFFERS from the original's on 1.40.0 (observed stdout of one example): review before applying |
| Patch applied word for word to the example | 1.45.1 | applied word for word, the patch does not give the verified example's result — the patched example does not run on 1.45.1: exit code 1, ImportError: cannot import name 'Event' from 'opentelemetry._logs' (/usr/local/lib/python3.11/site-packages/opentelemetry/_logs/__init__.py) |
Verified example for opentelemetry-api 1.45.1
import json
from opentelemetry._logs import (
LogRecord,
Logger,
LoggerProvider,
get_logger,
set_logger_provider,
)
class PrintingEventLogger(Logger):
"""Minimal API-only EventLogger that records emitted events and prints them."""
def __init__(self, name, version=None, schema_url=None, attributes=None):
super().__init__(name, version, schema_url, attributes)
self.emitted = []
def enabled(self, *args, **kwargs) -> bool:
return True
def emit(self, event: LogRecord) -> None:
self.emitted.append(event)
event_name = getattr(event, "name", None) or getattr(event, "event_name", None)
event_attrs = dict(event.attributes or {})
print(f"event name: {event_name}")
print(f"event attributes: {json.dumps(event_attrs, sort_keys=True)}")
class PrintingEventLoggerProvider(LoggerProvider):
def __init__(self):
self.loggers = {}
def get_logger(self, name, version=None, schema_url=None, attributes=None):
if name not in self.loggers:
self.loggers[name] = PrintingEventLogger(name, version, schema_url, attributes)
return self.loggers[name]
def main() -> None:
# The API alone only provides no-op implementations, so register a simple
# provider that prints events, allowing verification of what was emitted.
set_logger_provider(PrintingEventLoggerProvider())
event_logger = get_logger("checkout-service")
event = LogRecord(
event_name="order.placed",
attributes={"order_id": "A123", "total": 42.5},
)
event_logger.emit(event)
if __name__ == "__main__":
main()Source
`opentelemetry-api`, `opentelemetry-sdk`: Removed deprecated Events API/SDK. Use `LogRecord` with the `event_name` field set instead.
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-api
For agents
- This page as JSON:
https://formachines.ai/errata/pypi/opentelemetry-api/0002-opentelemetry-events/index.json - Whole database in plain text:
/errata/llms-full.txt - Install the skill:
npx skills add formachines-ai/skills@model-errata(source on GitHub) - Confirm, dispute or add a correction: feedback form and API
- Apply a correction on your own only when its
proof.auto_applyis true (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.)