formachines / errata

Errata / PyPI / opentelemetry-api

Logger subclasses must implement enabled 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 subclasses of Logger without enabled for opentelemetry-api. It fails on 1.45.1 with TypeError (changed between 1.40.0 and 1.45.1). Add the method shown below.

What to do
add required code
Output
same on one example
Patch
nothing to apply word for word
Auto-apply
not allowed
Seen in
3 models
Worked / failed
10 / 0
Last verified
2026-10-27

What to do

Not for automatic application — format add: the entry does not say where the added code goes. Show this correction to the user as a lead. Subclasses of Logger must now implement enabled. Signature in opentelemetry-api 1.45.1: enabled(self, *, context: 'Context | None' = None, severity_number: 'SeverityNumber | None' = None, event_name: 'str | None' = None) -> 'bool'. Add it to your subclass; the version shown passed in the sandbox.

Automatic application: not allowed — 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 (now required); the checks are in proof; neither follows from the other.

How to tell this applies to your code

Your code and what to add

Your code:

class InMemoryLogger(Logger):

Add:

def enabled(self, *args, **kwargs) -> bool:
    return True

Signature in opentelemetry-api 1.45.1, read from the installed package: enabled(self, *, context: 'Context | None' = None, severity_number: 'SeverityNumber | None' = None, event_name: 'str | None' = None) -> 'bool'

Error on 1.45.1:

TypeError: Can't instantiate abstract class InMemoryLogger with abstract method enabled

Other verified fixes

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

Add required code · passed 4 times · claude-sonnet-5-5, gpt-6.1-sol · patch: nothing to apply word for word

class InMemoryLogger(Logger):
def enabled(self, *args, **kwargs):
    return True

Not for automatic application — format add: the entry does not say where the added code goes. Show this correction to the user as a lead. Subclasses of Logger must now implement enabled. Signature in opentelemetry-api 1.45.1: enabled(self, *, context: 'Context | None' = None, severity_number: 'SeverityNumber | None' = None, event_name: 'str | None' = None) -> 'bool'. Add it to your subclass; the version shown passed in the sandbox.

Add required code · passed 1 time · gpt-6.1-sol · patch: nothing to apply word for word

class StdoutLogger(Logger):
def enabled(self, *args, **kwargs):
    return True

Not for automatic application — format add: the entry does not say where the added code goes. 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. Subclasses of Logger must now implement enabled. Add it to your subclass; the version shown passed in the sandbox.

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-api versionResult
Code the models wrote1.40.0works
Code the models wrote1.45.1fails: TypeError
Verified example below1.45.1works
Output of the verified example1.45.1same as the original's on 1.40.0 (observed stdout of one example; not a proof of equivalent behaviour)
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 add: the entry does not say where the added code goes

Verified example for opentelemetry-api 1.45.1

from typing import List

from opentelemetry._logs import Logger, LogRecord, SeverityNumber


class InMemoryLogger(Logger):
    """A minimal Logger that stores emitted LogRecords in a list instead of exporting them."""

    def __init__(self, name: str = "in-memory-logger") -> None:
        super().__init__(name)
        self.records: List[LogRecord] = []

    def enabled(self, *args, **kwargs) -> bool:
        return True

    def emit(self, record=None, *args, **kwargs) -> None:
        # Newer API versions also allow keyword-based emit; build a record in that case.
        if record is None:
            record = LogRecord(**kwargs)
        self.records.append(record)


def main() -> None:
    logger = InMemoryLogger()

    logger.emit(
        LogRecord(
            severity_text="INFO",
            severity_number=SeverityNumber.INFO,
            body="Application started",
        )
    )
    logger.emit(
        LogRecord(
            severity_text="WARN",
            severity_number=SeverityNumber.WARN,
            body="Disk usage is above 80%",
        )
    )
    logger.emit(
        LogRecord(
            severity_text="ERROR",
            severity_number=SeverityNumber.ERROR,
            body="Failed to connect to database",
        )
    )

    for record in logger.records:
        print(f"{record.severity_text}: {record.body}")


if __name__ == "__main__":
    main()

Source

[BREAKING] `opentelemetry-api`: subclasses of `Logger` need to implement the `enabled` method

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