Skip to content

Add LangFuse tracing samples - #331

Open
DABH wants to merge 6 commits into
mainfrom
langfuse-tracing
Open

Add LangFuse tracing samples#331
DABH wants to merge 6 commits into
mainfrom
langfuse-tracing

Conversation

@DABH

@DABH DABH commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Adds samples of using our OTel plugin to send traces to LangFuse from Temporal workflows.

DABH added 3 commits July 23, 2026 15:47
…metry

Demonstrates the recommended way to get Temporal workflow traces into
Langfuse: OpenTelemetryPlugin(add_temporal_spans=True) with a replay-safe
tracer provider, plus a standard OTLP/HTTP exporter pointed at Langfuse's
native OpenTelemetry endpoint. No Langfuse-specific SDK or plugin needed.

- ticket_triage/: LLM triage workflow (two LLM activities, a plain
  activity, and a human-approval update) with --replay-stress and
  worker-restart demos; one correctly nested Langfuse trace per run with
  GENERATION observations carrying model, token usage, and content.
- verify_trace.py: asserts the whole observation tree, types, usage, and
  no-duplicates through the Langfuse public API.
- langfuse/docker-compose.yml: pinned self-hosted Langfuse with headless
  org/project/API-key provisioning.
- naive_guide_style/: deliberately broken anti-pattern (spans created in
  workflow code, sandbox disabled) showing duplicated, fragmented traces
  under replay.
- RECOMMENDATION.md: customer-shareable write-up of the approach.
- tests/langfuse_tracing/: CI-safe tests with mocked LLM activities, an
  in-memory exporter, the workflow cache disabled, and a Replayer pass
  asserting replay emits zero new spans.
Drop the recommendation write-up and the comparison variant, and remove
references to them from the READMEs and verify_trace.py.
- Bound LLM activity retries (RetryPolicy(maximum_attempts=3)) so a
  misconfigured endpoint or API key fails fast instead of retrying
  forever, and note that each retry attempt adds its own RunActivity
  span; verify_trace's duplicate-row message now mentions activity
  retries alongside replay as a possible cause of extra spans.
- Ignore .env files repo-wide so the runbook-created env file holding a
  real API key cannot be committed by accident.
- Make the Langfuse project ID in the starter's printed trace link
  configurable via LANGFUSE_PROJECT_ID (defaults to the project the
  bundled docker-compose provisions).
- Parse worker flags with argparse so typos and --help behave as
  expected instead of silently starting a normal-mode worker.
- Replace bare os.environ lookups for Langfuse credentials with an
  actionable error message in telemetry.py and verify_trace.py.
@DABH
DABH requested review from a team as code owners July 28, 2026 18:37
DABH added 2 commits July 28, 2026 13:39
The AI SDK block below already contains the identical pattern and
owners, and CODEOWNERS resolves by last matching pattern, so the
earlier entry was fully shadowed.
Comment thread .github/CODEOWNERS
@@ -1,5 +1,4 @@
* @temporalio/sdk
/langgraph_plugin/ @temporalio/sdk @temporalio/ai-sdk

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a duplicate of L19 down below, can be safely removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant