langflow icon indicating copy to clipboard operation
langflow copied to clipboard

Langflow traces are not well reflected in Langfuse

Open codenprogressive opened this issue 1 year ago • 8 comments

Bug Description

Not able to see Langflow components inputs and outputs in Langfuse tracing. For instance, for a given component, you will see the component python code instead of the input data. And the Output is completely empty.

See screenshot below.

Reproduction

  1. create a simple flow with chat input, prompt, and a chat output! flow example reproduce _error_langfuse (1).json
  2. connect to Langfuse, and see trace.
  3. notice that components input are tracking the python code of the component and not the data inputted
  4. notice that the component output is empty

see screenshow: image

Expected behavior

I'm expecting to see input data (not the python code) and output data of each components.

Who can help?

@italojohnny

Operating System

Ubuntu

Langflow Version

1.0.19

Python Version

3.10

Screenshot

image

Flow File

reproduce _error_langfuse (1).json

codenprogressive avatar Oct 19 '24 15:10 codenprogressive

Langflow should capture and serialize component inputs and outputs correctly for Langfuse integration. The LangFuseTracer class is responsible for this, using methods like add_trace and end_trace to handle inputs and outputs. These methods should ensure that the actual data, not the code, is included in the trace [1].

If you're seeing code instead of data, it might be due to an issue with how inputs are being captured or serialized. The _convert_to_langwatch_types method is used to convert inputs and outputs to compatible types, which should help ensure that data is correctly represented [2].

To troubleshoot, ensure that the _cleanup_inputs method is correctly sanitizing and storing inputs, and that the LangFuseTracer is properly initialized with the necessary environment variables for Langfuse [3][4]. If the issue persists, reviewing the implementation of these methods might help identify any discrepancies in how data is being processed.

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Oct 19 '24 15:10 dosubot[bot]

In version 1.0.18 traces were working fine. Looks like something was introduced in v19 resulted into breaking things. I see tracing service logic was slightly changed when introducing ruff rules.

codenprogressive avatar Oct 20 '24 18:10 codenprogressive

In version 1.0.18 traces were working fine. Looks like something was introduced in v19 resulted into breaking things. I see tracing service logic was slightly changed when introducing ruff rules.

I spend a long time debugging this. And you are right, it is a bug that was introduced in the latest version :-(.

zcasanova avatar Oct 26 '24 22:10 zcasanova

I found that the _end_and_reset function has an issue: self._reset_io() clears the outputs before the task is executed.

sunny6chen avatar Nov 02 '24 09:11 sunny6chen

Same issue here; is there an ETA on a patch?

colecal avatar Nov 08 '24 19:11 colecal

The reported behavior was introduced specifically in commit 4221fa40e610df564971b328b3b0ee41178077a2 (PR #3694).

However, from my analysis, all trace data is still present. What changed is that the component’s Python code is now included as well, which is quite annoying.

italojohnny avatar Nov 12 '24 18:11 italojohnny

@italojohnny other than the python code is being added into the input. The output is not showing empty. See above screenshot. Were you able to reproduce the empty output?

codenprogressive avatar Nov 13 '24 20:11 codenprogressive

@italojohnny other than the python code is being added into the input. The output is not showing empty. See above screenshot. Were you able to reproduce the empty output?

Thanks for clarifying this. I also saw that output was not being produced, which was how I noticed the bug in the first place. My scoring code that needs to pull the observation results broke.

zcasanova avatar Nov 13 '24 22:11 zcasanova

Hello, @codenprogressive , @sunny6chen, @colecal and @zcasanova I believe PR #4669 has addressed the issues reported here. Could you please check again?

italojohnny avatar Nov 25 '24 14:11 italojohnny

@italojohnny hey, I've tested couple of flows and most of them worked, but when I try to run flow with Wikipedia API tool (by itself or in a flow) there is lots of serialization errors and either flow times out or entire app straight up crashes. When langflow is not connected to langfuse everything works as expected. Maybe there are more components that do this, haven't really tested all of them.

To reproduce just connect to langfuse and run Wikipedia API tool. Tested on version 1.1.1

rors41 avatar Nov 29 '24 09:11 rors41

Thank you for your response, @rors41 . In this case, I believe the issue might be specifically related to this component. Could you open a new issue to report it?

I’ll go ahead and close this issue. If you encounter any other problems, please don’t hesitate to open a new one.

italojohnny avatar Nov 29 '24 16:11 italojohnny