feat(weave): migrate clickhouse_trace_server_batched.py to @traced (PR-7b1)#7201
Draft
amwarrier wants to merge 1 commit into
Draft
Conversation
…R-7b1) Replaces all 47 `@ddtrace.tracer.wrap(name=X)` decorators with `@traced(name=X)` from `weave.trace_server.tracing` (added in PR-7a). Two generator functions (`_table_query_stream`, `annotation_queues_query_stream`) use `@traced_generator(name=X)` instead — with `@ddtrace.tracer.wrap` these were silently producing wrong span durations (span closed on first generator-creation, not on exhaustion); the new shape spans the full iteration via `yield from` inside the span body. No behavior change for non-generator functions: span name is preserved 1:1, DD APM auto-derives `resource_name` from it, dashboards keyed on the historical names keep resolving. `import ddtrace` removed from the file (now unused after this change). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
f3bceb9 to
213dfe7
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
amwarrier
added a commit
that referenced
this pull request
Jun 12, 2026
…ated) Integrated commit for testing in wandb/core's weave-trace image on wandbench-small. Represents the combined effect of upstream PRs: - #7196 (PR-7a): @Traced + @traced_generator in weave/trace_server/tracing.py - #7201 (PR-7b1): 47 wraps in clickhouse_trace_server_batched.py - #7202 (PR-7b2): 17 wraps + 2 trace blocks + 3 set_tag + 1 current_root in 10 files - #7203 (PR-7c): inline DogStatsD in datadog.py, drop ddtrace dep from pyproject.toml This branch sits on top of the wandb/core-pinned submodule SHA so the weave-trace image build picks up only PR-7 changes — no unrelated upstream drift. After this commit, `grep -rn "import ddtrace\|from ddtrace"` returns empty across weave/trace_server/. Only docstring/comment references remain. Co-Authored-By: Claude Opus 4.7 <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.
Summary
Stacked on #7196 (PR-7a). This is sub-PR 2 of 4 in the ddtrace → OpenTelemetry migration of
weave/trace_server/.Replaces all 47
@ddtrace.tracer.wrap(name=X)decorators inclickhouse_trace_server_batched.pywith@traced(name=X)fromweave.trace_server.tracing(added in PR-7a).Notable: two generators move to
@traced_generator_table_query_streamandannotation_queues_query_streamare generator functions. With@ddtrace.tracer.wrap, these were silently producing wrong span durations — ddtrace's wrap closes the span when the wrapper returns the generator object, not when the generator is exhausted. The new@traced_generatorusesyield frominside the span body so the span correctly covers the full iteration lifetime.This is a behavior change: span durations on these two methods will be larger (and more accurate) after this PR.
Test plan
python -m py_compile weave/trace_server/clickhouse_trace_server_batched.py✅ (validated locally)@tracedlands on a non-generator, every@traced_generatorlands on a generator ✅ (validated locally)ddtracereferences in the file ✅tests/trace_server/suite passes (CI)🤖 Generated with Claude Code