Skip to content

bug(langfuse): test_create_new_span causes excessive RAM usage and hangs due to unspecced MagicMock #2543

@Hansehart

Description

@Hansehart

Describe the bug
The issue is on line 537 where mock_raw_span = MagicMock() is created without a spec parameter. When this mock is passed through the tracer's handle() method, it triggers unbounded creation of child MagicMock objects because:

  • Every attribute access (span.get_data(), span.raw_span(), etc.) creates new MagicMock instances
  • MagicMock stores all calls and arguments in memory for assertion tracking
  • Without a spec, there are no boundaries preventing infinite mock object creation
  • The handle() method makes numerous such calls (lines 352-421 in tracer.py)

To Reproduce

  cd integrations/langfuse
  hatch run test:unit tests/test_tracer.py::TestLangfuseTracer::test_create_new_span -v

Describe your environment (please complete the following information):

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