Conversation
create_score passed camelCase kwargs to the v4 ScoreBody, which takes snake_case field names and keeps unknown kwargs as extras. body.trace_id was always None, so add_score_task never sampled a score out.
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?
create_scorepassed camelCase kwargs to the v4 ScoreBody, which takes snake_case field names and keeps unknown kwargs as extras.body.trace_idwas always None, so add_score_task never sampled a score out. This builds the body by field name and serialises it by alias in the consumer, so the wire format is unchanged.Fixes #1890
Type of change
Verification
uv run --frozen ruff check . uv run --frozen mypy langfuse --no-error-summary uv run --frozen pytest tests/unit/test_resource_manager.py tests/unit/test_otel.py::TestAdvancedSpans::test_score_sampling_follows_trace_samplingChecklist
code_review.md..env.templateif needed.The PR appears safe to merge; the corrected model population restores score sampling while preserving the ingestion contract.
Summary
This PR restores trace-consistent sampling for scores by populating the generated score model through its Python field names and applying API aliases when the queued model is serialized.
trace_idto queue-admission sampling.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR A[create_score] --> B[Build ScoreBody with snake_case fields] B --> C{Trace-linked and sampled?} C -->|No| D[Drop score] C -->|Yes or unlinked| E[Score ingestion queue] E --> F[Convert model fields to API aliases] F --> G[camelCase ingestion payload]Reviews (1) · Last reviewed commit: "fix(scores): apply trace sampling to sco..."