Skip to content

BatchLogRecordProcessor objects are not able to be garbage collected #4422

@robahlgren

Description

@robahlgren

Describe your environment

OS: Debian 12 (Bookworm)
Python version: Python 3.11.2
SDK version: 1.30.0
API version: 1.30.0

What happened?

BatchLogRecordProcessor is not garbage collected, causing a memory leak

Steps to Reproduce

import gc
from opentelemetry.exporter.otlp.proto.grpc._log_exporter import OTLPLogExporter
from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
for _ in range(10):
    processor = BatchLogRecordProcessor(OTLPLogExporter("test"))
    processor.shutdown()
    del processor

gc.collect()
for obj in gc.get_objects():
    if isinstance(obj, BatchLogRecordProcessor):
        print(obj)

Expected Result

No BatchLogRecordProcessor objects should remain

Actual Result

One BatchLogRecordProcessor object is found for each instantiation and consumes ~240KiB of heap as measured by memray

Additional context

No response

Would you like to implement a fix?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions