Skip to content

Correct usage of langfuse with Spring AI #8

@davidbellem

Description

@davidbellem

Dear langfuse team,

I have been trying to figure out the best way to setup langfuse with Spring AI for some time now and wanted to share where I am at.

For this, I have created a fork of the current sample application here.

Would you mind taking a look to see if:

  • This is the correct way to add the session and user id?
  • This is the correct way to set the input and output to show up in the UI on the root level?

To me, it looks like, the spans are not correctly nested:
Image

This is also the case if I don't filter out any spans that are not AI related:
Image

However, if I add tool calls, this seems to nest the spans correctly again, but won't show the parameters of the tool calls.
Image

Some other notes

  • Maybe the files in the config folder help others to see how to reduce the noise coming from opentelemetry spring boot starter. If you don't filter out the spans, you also get all other traces into langfuse, e.g.
Image

I am happy to make this example a bit nicer and more elaborate (with a tool call etc)and submit a pull request to improve the documentation a bit.

Thanks for your help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions