Skip to content

feat(weave): migrate clickhouse_trace_server_batched.py to @traced (PR-7b1)#7201

Draft
amwarrier wants to merge 1 commit into
aravind/weave-trace/otel-migration-pr-7afrom
aravind/weave-trace/otel-migration-pr-7b1
Draft

feat(weave): migrate clickhouse_trace_server_batched.py to @traced (PR-7b1)#7201
amwarrier wants to merge 1 commit into
aravind/weave-trace/otel-migration-pr-7afrom
aravind/weave-trace/otel-migration-pr-7b1

Conversation

@amwarrier

Copy link
Copy Markdown
Contributor

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 in clickhouse_trace_server_batched.py with @traced(name=X) from weave.trace_server.tracing (added in PR-7a).

Notable: two generators move to @traced_generator

_table_query_stream and annotation_queues_query_stream are 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_generator uses yield from inside 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)
  • AST audit: every @traced lands on a non-generator, every @traced_generator lands on a generator ✅ (validated locally)
  • No remaining ddtrace references in the file ✅
  • Existing tests/trace_server/ suite passes (CI)
  • Tested end-to-end in wandb/core image on wandbench-small (post-merge of full stack)

🤖 Generated with Claude Code

…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>
@amwarrier amwarrier force-pushed the aravind/weave-trace/otel-migration-pr-7b1 branch from f3bceb9 to 213dfe7 Compare June 12, 2026 16:06
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

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>
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