Skip to content

[Observability] Langfuse move to context manager approach #1819

Open
@Benvii

Description

@Benvii

See this PR comment : #1793 (comment)

Currently we use the old langchain callback integration attach langfuse client to chain execution. The new way is based on context managers we should refactor our implementation to use this approach that is also more likely to be compatible with the auto-instrumentation approach of other observability framework such as Arize Phoenix.

PR comment :
Those are directly mapped to the langfuse attributes ... I'm thinking that this is ok untill we just have langfuse but what about langsmith or Arize Phoenix so I made some research in case we would someday implement them :

  • Arize Phoenix uses auto-instrumentation (compatible with OpenTelemetry standard and OpenInference), meaning it's not done though an explicit langchain callback
  • Langsmith SDK is now called LangChainTracer, it seems that they aren't using callbacks any more : context managers are use in the document, tags are passed by wrapping the LCEL chain ...

It seems that langfuse also recommends using decorators : https://langfuse.com/docs/sdk/python/decorators#decorator-context

I think that it would be great to investigate a bit more and maybe instead of using a callback, wrap chains calls inside python's context managers ... where the manager is build by a factory.
Also we should test LCEL chain tags with_configs (to pass tags) in a more generic way, maybe we would have to pass them to the observability provider.

Arkea's internal ref : DERCBOT-1331

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions