Skip to content

how to customize trace id when using callback handler in langchain integration #2658

Answered by shawnzhu
shawnzhu asked this question in Support
Discussion options

You must be logged in to vote

I figured it out by customizing run_id of a Langchain runnable, which is later used as trace id.

from langfuse.callback import CallbackHandler

run_id = uuid4()
langfuse_handler = CallbackHandler();
agent.invoke({"input": input}, config={"callbacks":[langfuse_handler], "run_id": run_id})

Notice that it will also changed the run_id of this langchain runnable as well.

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@shawnzhu
Comment options

Comment options

You must be logged in to vote
1 reply
@marcklingen
Comment options

Answer selected by shawnzhu
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants