feat(weave): drop ddtrace dep, inline DogStatsD in datadog.py (PR-7c)#7203
Draft
amwarrier wants to merge 1 commit into
Draft
Conversation
|
Preview this PR with FeatureBee: https://beta.wandb.ai/?betaVersion=0470fcf2da3ddaba2f578cf9a0cacc003ea9e9d3 |
Stacked on PR-7b2. Completes the ddtrace -> OpenTelemetry migration of
weave/trace_server/. After this PR, `pip install . && pip list | grep ddtrace`
returns empty.
Changes:
1. weave/trace_server/datadog.py rewritten to remove all ddtrace imports:
- DogStatsD client is now a ~30-line inline `_StatsDClient` class that
opens a UDP socket to `${DD_DOGSTATSD_URL}` (or `${DD_AGENT_HOST}:8125`
fallback), encodes counters in DogStatsD wire format
`name:value|c|#tags`, and swallows OSError so stats hiccups never
crash the request path. Metric name (`weave_trace_server.db_inserts`)
and tag format preserved, so existing DD dashboards keep resolving.
- `set_root_span_dd_tags` and `set_current_span_dd_tags` now use OTel's
`get_current_span()` rather than `ddtrace.tracer.current_root_span()`.
The "root span" semantics aren't preserved exactly — OTel has no
built-in current-root-span accessor — but per analysis in
services/weave-trace/docs/phase-b-weave-public-plan.md §3.4, none of
the historical call sites actually need root semantics; they just
need "the span currently active when this helper is called", which
`get_current_span()` provides.
- `generator_trace` deleted. It existed to suppress ddtrace's
auto-mark-error-on-GeneratorExit, but OTel's `start_as_current_span`
doesn't have that behavior (BaseException subclasses propagate
through `use_span` without setting status=ERROR). Callers should use
`@traced_generator` from `weave.trace_server.tracing` instead.
2. pyproject.toml: removed `ddtrace>=2.7.0` from the trace_server optional
dep group (line 80) and the trace_server dependency group (line 425).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
6036a72 to
d54aad8
Compare
4b6aa58 to
b9e4c15
Compare
Codecov Report❌ Patch coverage is
📢 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 PR-7b2. Final sub-PR (4 of 4) of the ddtrace → OpenTelemetry migration of
weave/trace_server/.After this PR,
pip install . && pip list | grep ddtracereturns empty.Changes
weave/trace_server/datadog.pyrewrittenThe module historical name (
datadog.py) is preserved for backwards compatibility, but internally ddtrace is gone. Public symbols preserved:DB_INSERT_METRIC,DB_INSERT_PATH_UNKNOWN(constants)db_insert_path(path)(context manager)tag_db_insert_path(path)(decorator)record_db_insert(*, table, count, path=None)(function)set_root_span_dd_tags(tags),set_current_span_dd_tags(tags)(functions)Removed:
generator_trace(span_name)— it existed only to suppress ddtrace's auto-mark-error-on-GeneratorExit. OTel'sstart_as_current_spandoesn't have that behavior (BaseException subclasses propagate throughuse_spanwithout marking the span errored), so this decorator becomes dead code. Callers should use@traced_generatorfromweave.trace_server.tracinginstead. Empirically verified with the OTel SDK before deletion.Inline DogStatsD
The DogStatsD client is now a ~30-line
_StatsDClientclass:${DD_DOGSTATSD_URL}(or${DD_AGENT_HOST}:8125fallback)name:value|c|#tagsOSErrorso stats hiccups never crash the request pathThe metric name (
weave_trace_server.db_inserts) and tag format are preserved, so existing DD dashboards keep resolving.set_root_span_dd_tagssemantics changeThe original used
ddtrace.tracer.current_root_span(). OTel has no built-in current-root-span accessor, so this now usestrace.get_current_span()— the currently-active span. Per analysis inservices/weave-trace/docs/phase-b-weave-public-plan.md§3.4, none of the three historical call sites actually need root semantics; they just need "the span currently active when this helper is called", whichget_current_span()provides. NOT a semantic regression for known callers.pyproject.tomlRemoved
ddtrace>=2.7.0from both occurrences (line 80 intrace_serveroptional deps, line 425 in thetrace_serverdependency group).Test plan
python -m py_compile weave/trace_server/datadog.py✅pip install . && pip list | grep ddtracereturns empty (post-merge validation)tests/trace_server/suite passes (CI)weave_trace_server.db_insertscounter still ingesting in DD🤖 Generated with Claude Code