Open
Conversation
Collaborator
|
work out how to remove API keys from what we send to langfuse. Any other sensitive stuff? |
Collaborator
|
next steps here:
|
This was referenced Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Short Description
Adds Langfuse observability to all three chat services (global_chat, job_chat, workflow_chat) with per-user opt-in control.
Fixes #410
Requested Lightning changes: OpenFn/lightning#4595
We need to figure out self-hosting: #439
Implementation Details
Tracing
Every chat request now produces a structured trace in Langfuse — the full call tree from the top-level
main()through routing, planning, subagent calls, RAG retrieval, and Anthropic API calls. Multi-turn conversations are grouped into Langfuse sessions viasession_id. Anthropic SDK calls are auto-instrumented via OpenTelemetry.Tracking controls
metrics_opt_inboolean in the payload. When absent or false, ashould_export_spanfilter drops all spans before they leave the process — zero data sent to Langfuse.metrics_opt_in(one-line removal when we're ready to rely on the flag).metrics_opt_inthrough subagent payloads.User identity
A new
userobject in the payload carriesid(mapped to Langfuseuser_id) andemployee(added as a Langfuse tag). This lets us filter traces by user and segment employee vs external usage.API key safety
The
@observedecorator onmain()was capturing the entire input dict — includingapi_key— as the trace input. Fixed by addingcapture_input=Falseand explicitly setting only the user's message as the span input.Payload changes (frontend action needed)
Three new optional fields on all services:
{ "user": { "id": "user-abc", "employee": true }, "metrics_opt_in": true, "meta": { "session_id": "..." } }meta.session_idis new and consistent across all three services (global_chat previously usedmetadata— renamed tometafor consistency).AI Usage
Please disclose how you've used AI in this work (it's cool, we just want to know!):
You can read more details in our Responsible AI Policy