feat: replace Langfuse with local-first tracing system#183
Merged
anandgupta42 merged 4 commits intomainfrom Mar 16, 2026
Merged
feat: replace Langfuse with local-first tracing system#183anandgupta42 merged 4 commits intomainfrom
anandgupta42 merged 4 commits intomainfrom
Conversation
Instrument `altimate run` with Langfuse observability (activated via LANGFUSE_* env vars) so benchmark runs capture tool calls, tokens, cost, and timing as traces. After evaluation, traces are updated with benchmark_pass scores for end-to-end visibility in the Langfuse dashboard. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Generations previously had empty input (no context) and empty output when the model only produced tool calls. Now: - Input shows tool results from the preceding step - Output falls back to "[tool calls: read, write, ...]" when no text Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the Langfuse SDK integration with a vendor-neutral, exporter-based tracing system that captures full session traces locally by default. Core changes: - New `Tracer` class with `FileExporter` (local JSON) and `HttpExporter` (remote) - 4-mode HTML trace viewer (Waterfall, Tree, Chat, Log) served via `Bun.serve` - `altimate-code trace list` and `altimate-code trace view` CLI commands - Data engineering semantic attributes (`de-attributes.ts`) for warehouse/SQL/dbt - Tracing config schema: `tracing.enabled`, `tracing.dir`, `tracing.maxFiles`, `tracing.exporters` - Integrated into both `run` command and TUI worker with per-session tracers Key design decisions: - Crash-safe: `writeFileSync` in signal handlers, atomic tmp+rename snapshots - Config-aware: TUI and CLI both honor `tracing.*` config settings - Fail-safe: all tracing methods wrapped in try-catch, never crashes the app - Localhost-only: trace viewer server binds to `127.0.0.1` - Session finalization: TUI traces properly end on `session.status=idle` Tests: 380 tests across 13 files (unit, integration, adversarial, e2e) Docs: `docs/docs/configure/tracing.md` + CLI docs updated Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
`padEnd(10)` was called on strings containing ANSI color codes, causing the invisible escape characters to be counted toward the padding length. This broke column alignment for non-"ok" statuses. Fix: pad the visible text first, then wrap with color codes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment on lines
+69
to
+79
| if (tc?.exporters) { | ||
| for (const exp of tc.exporters) { | ||
| exporters.push(new HttpExporter(exp.name, exp.endpoint, exp.headers)) | ||
| } | ||
| } | ||
| tracingExporters = exporters | ||
| tracingMaxFiles = tc?.maxFiles | ||
| } catch { | ||
| // Config failure should not prevent TUI from working | ||
| } | ||
| } |
There was a problem hiding this comment.
Bug: A race condition in loadTracingConfig sets tracingConfigLoaded to true before async operations complete, causing subsequent calls to use uninitialized tracing exporters.
Severity: MEDIUM
Suggested Fix
Move the tracingConfigLoaded = true assignment to after the await Config.get() call has successfully completed. Alternatively, use a Promise-based loading mechanism instead of a simple boolean flag to ensure subsequent callers wait for the configuration to be fully loaded before proceeding.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: packages/opencode/src/cli/cmd/tui/worker.ts#L61-L79
Potential issue: The `loadTracingConfig` function sets the `tracingConfigLoaded` flag to
`true` immediately upon entry, before an asynchronous `Config.get()` operation
completes. If a second call to `loadTracingConfig` occurs during this async window
(e.g., from a rapid `setWorkspace` call), it will see the flag as true and return
prematurely. This causes the second call's context to proceed with an `undefined`
`tracingExporters` variable, leading to the use of default tracer settings instead of
the user's configured exporters. Traces may be written to the wrong directory or sent to
incorrect endpoints.
anandgupta42
added a commit
that referenced
this pull request
Mar 17, 2026
* feat: add Langfuse tracing for CLI and Spider2-DBT benchmark Instrument `altimate run` with Langfuse observability (activated via LANGFUSE_* env vars) so benchmark runs capture tool calls, tokens, cost, and timing as traces. After evaluation, traces are updated with benchmark_pass scores for end-to-end visibility in the Langfuse dashboard. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: populate generation input/output in Langfuse traces Generations previously had empty input (no context) and empty output when the model only produced tool calls. Now: - Input shows tool results from the preceding step - Output falls back to "[tool calls: read, write, ...]" when no text Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: replace Langfuse with local-first tracing system Replace the Langfuse SDK integration with a vendor-neutral, exporter-based tracing system that captures full session traces locally by default. Core changes: - New `Tracer` class with `FileExporter` (local JSON) and `HttpExporter` (remote) - 4-mode HTML trace viewer (Waterfall, Tree, Chat, Log) served via `Bun.serve` - `altimate-code trace list` and `altimate-code trace view` CLI commands - Data engineering semantic attributes (`de-attributes.ts`) for warehouse/SQL/dbt - Tracing config schema: `tracing.enabled`, `tracing.dir`, `tracing.maxFiles`, `tracing.exporters` - Integrated into both `run` command and TUI worker with per-session tracers Key design decisions: - Crash-safe: `writeFileSync` in signal handlers, atomic tmp+rename snapshots - Config-aware: TUI and CLI both honor `tracing.*` config settings - Fail-safe: all tracing methods wrapped in try-catch, never crashes the app - Localhost-only: trace viewer server binds to `127.0.0.1` - Session finalization: TUI traces properly end on `session.status=idle` Tests: 380 tests across 13 files (unit, integration, adversarial, e2e) Docs: `docs/docs/configure/tracing.md` + CLI docs updated Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: pad status text before wrapping with ANSI codes in `trace list` `padEnd(10)` was called on strings containing ANSI color codes, causing the invisible escape characters to be counted toward the padding length. This broke column alignment for non-"ok" statuses. Fix: pad the visible text first, then wrap with color codes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: kulvirgit <kulvirgithub@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
What does this PR do?
Replaces the Langfuse SDK integration with a vendor-neutral, exporter-based tracing system. Every CLI and TUI session now captures full traces (generations, tool calls, tokens, cost, timing) as local JSON files with an interactive HTML viewer.
Core additions:
Tracerclass withFileExporter(local JSON) andHttpExporter(remote endpoints)Bun.servealtimate-code trace listandaltimate-code trace viewCLI commandstracing.enabled,tracing.dir,tracing.maxFiles,tracing.exportersKey design decisions:
writeFileSyncin signal handlers, atomic tmp+rename snapshotstracing.*config settings127.0.0.1session.status=idleType of change
Issue for this PR
Closes #182
How did you verify your code works?
trace list,trace view, and TUI/tracecommandChecklist