Skip to content

fix(tracing): report streaming errors to generation spans - #353

Open
fcy222fcy wants to merge 1 commit into
Ingenimax:mainfrom
fcy222fcy:fix/streaming-error-trace-328
Open

fix(tracing): report streaming errors to generation spans#353
fcy222fcy wants to merge 1 commit into
Ingenimax:mainfrom
fcy222fcy:fix/streaming-error-trace-328

Conversation

@fcy222fcy

Copy link
Copy Markdown

Description

When a streaming LLM request fails, the Langfuse TraceGeneration span was still emitted with the successful-looking streaming_response value and without error metadata. This made failed generations appear successful.

This change captures interfaces.StreamEventError, records the error on the main streaming span, and adds metadata["error"] to the generation span. Failed streams now use explicit <error> or <redacted> response placeholders, while successful streams preserve the existing streaming_response behavior.

Fixes #328

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

The following tests and checks passed locally:

  • go test -count=1 ./pkg/tracing
  • go test -race -count=1 ./pkg/tracing
  • go test -count=1 ./...
  • go test -race -count=1 ./...
  • go vet ./pkg/tracing
  • golangci-lint run ./...
  • gosec ./...
  • gofmt and git diff --check

The regression tests cover both content policies, successful-stream compatibility, error metadata, and exception events on the main streaming span.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

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.

[BUG] Langfuse streaming TraceGeneration silently masks errors

1 participant