deepset-ai / haystack-core-integrations

Additional packages (components, document stores and the likes) to extend the capabilities of Haystack version 2.0 and onwards
https://haystack.deepset.ai
Apache License 2.0
121 stars 119 forks source link

Langfuse trace failing apps for flushing #1138

Closed touhi99 closed 1 week ago

touhi99 commented 1 month ago

Describe the bug Following the documentation here Langfuse, I am adding trace flush on the fastapi

@asynccontextmanager
async def lifespan(app: FastAPI):
    tracer.actual_tracer.flush()

I am getting the following error:

  File "C:\Users\touhidul.alam\Anaconda3\envs\shs\Lib\site-packages\starlette\routing.py", line 732, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "C:\Users\touhidul.alam\Anaconda3\envs\shs\Lib\contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\touhidul.alam\Desktop\shs\shs-rag-backend\src\rag\api\api.py", line 17, in lifespan
    tracer.actual_tracer.flush()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NullTracer' object has no attribute 'flush'

ERROR:    Application startup failed. Exiting.

Describe your environment (please complete the following information):

it was working with langfuse-haystack==0.2.0 but after upgrading to haystack 0.5.0, it's not working anymore. Any solution idea? Thanks

vblagoje commented 1 week ago

Hey @touhi99 NullTracer is our internal class that is used when tracing in haystack is disabled. Please make sure your env is setup correctly.

Let us know if this issue persists, otherwise we'll close it EOW.

vblagoje commented 1 week ago

Closing - likely caused by incorrect setup. If not, please provide traces @touhi99 so we can figure it out.