Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration of Langfuse has bugs #8548

Open
5 tasks done
LiHongYan666 opened this issue Sep 19, 2024 · 1 comment
Open
5 tasks done

Integration of Langfuse has bugs #8548

LiHongYan666 opened this issue Sep 19, 2024 · 1 comment
Labels
🐞 bug Something isn't working

Comments

@LiHongYan666
Copy link

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.12

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

Monitoring the integration of external Ops tools, there are bugs in the integration of Langfuse, see details:langfuse/langfuse#2700

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

@dosubot dosubot bot added the 🐞 bug Something isn't working label Sep 19, 2024
Copy link

dosubot bot commented Sep 19, 2024

I found a similar unsolved discussion that might be relevant to your issue: Started with Local Source Code, made sure langSmith is connected properly, but log traces not printing upon adding to langsmith_trace.py, which was last updated on 2024-08-21 [1].

Additionally, here are some key points and steps to ensure the integration of Langfuse with Dify is correctly configured:

  1. Creating a Project in Langfuse:

    • Register and log in to Langfuse at Langfuse website.
    • Create a new project in Langfuse by clicking New on the homepage. This project will be used for data monitoring in Dify.
    • Edit a name for the project.
  2. Generating API Keys in Langfuse:

    • In the Langfuse project, navigate to Settings in the left sidebar.
    • Click Create API Keys to generate the project API credentials.
    • Copy and save the Secret Key, Public Key, and Host.
  3. Configuring Langfuse in Dify:

    • Open the Dify app and navigate to the monitoring settings of the application you want to monitor.
    • Open Monitoring in the side menu and select Tracing app performance on the page.
    • Click Configure and enter the Secret Key, Public Key, and Host obtained from Langfuse.
    • Save the configuration.
    • Once successfully saved, you can view the status on the current page. If it shows as started, it is being monitored.
  4. Viewing Monitoring Data in Langfuse:

    • After configuration, you can view the monitoring data from Dify in Langfuse. This includes debugging and production data [2][3][4].

For logging and debugging, ensure that the logger is used to log debug messages at various points in the code, such as when traces, spans, and generations are created successfully or when exceptions occur. Here are some examples from the code:

def add_trace(self, langfuse_trace_data: Optional[LangfuseTrace] = None):
    format_trace_data = filter_none_values(langfuse_trace_data.model_dump()) if langfuse_trace_data else {}
    try:
        self.langfuse_client.trace(**format_trace_data)
        logger.debug("LangFuse Trace created successfully")
    except Exception as e:
        raise ValueError(f"LangFuse Failed to create trace: {str(e)}")

def add_span(self, langfuse_span_data: Optional[LangfuseSpan] = None):
    format_span_data = filter_none_values(langfuse_span_data.model_dump()) if langfuse_span_data else {}
    try:
        self.langfuse_client.span(**format_span_data)
        logger.debug("LangFuse Span created successfully")
    except Exception as e:
        raise ValueError(f"LangFuse Failed to create span: {str(e)}")

def add_generation(self, langfuse_generation_data: Optional[LangfuseGeneration] = None):
    format_generation_data = (
        filter_none_values(langfuse_generation_data.model_dump()) if langfuse_generation_data else {}
    )
    try:
        self.langfuse_client.generation(**format_generation_data)
        logger.debug("LangFuse Generation created successfully")
    except Exception as e:
        raise ValueError(f"LangFuse Failed to create generation: {str(e)}")

These log messages and the detailed monitoring data can help in identifying and diagnosing issues with the Langfuse integration [5][3][4].

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant