feat(weave): emit OTEL metrics for ClickHouse client operations#6692
Draft
gtarpenning wants to merge 3 commits intomasterfrom
Draft
feat(weave): emit OTEL metrics for ClickHouse client operations#6692gtarpenning wants to merge 3 commits intomasterfrom
gtarpenning wants to merge 3 commits intomasterfrom
Conversation
Wraps the hot methods on each thread-local ClickHouse client (`query`, `insert`, `command`, `query_rows_stream`) with OTEL counters and a duration histogram. No-op until the host service (weave-trace) installs a real MeterProvider, so this has no effect on SDK consumers of the `weave` package. Part of the MVP for making weave-trace, workers, and ClickHouse emit OTEL metrics so both Datadog (cloud) and Prometheus/Grafana (on-prem operator v2) can consume them from a single code path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Preview this PR with FeatureBee: https://beta.wandb.ai/?betaVersion=677c0bc4ef75c436eec8e704bbff0c1871cec048 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
CI runs uv sync --frozen against the committed lockfile, so the SDK group was not resolvable at test time. Rewrite the ClickHouse metrics tests to exercise the wrapper against the opentelemetry-api default no-op meter - the wrapping contract is what matters, and that path is what most SDK consumers of weave will actually hit. Removes the spurious trace_server_tests -> opentelemetry-sdk edge. Also picks up the ruff-format pass that CI flagged on the test module. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The explicit 'opentelemetry-api>=1.24.0' in the trace_server extra and dependency group forced uv.lock drift in CI. prek's 'files modified by hook' guard then failed because 'uv run ty check' resynced the lock. opentelemetry-api is already pulled in transitively by ddtrace and opentelemetry-proto, so the import in trace_server.clickhouse.metrics keeps working without the explicit declaration. Lockfile stays untouched. Co-Authored-By: Claude Opus 4.7 (1M context) <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
Wraps the hot methods on each thread-local ClickHouse client (
query,insert,command,query_rows_stream) with OTEL counters and a duration histogram. No-op until the host service (weave-trace) installs a realMeterProvider, so this has zero effect on SDK consumers of theweavepackage.Part of an MVP to stand up a single OTEL metrics path that can fan out to both Datadog (cloud, via the dd-agent OTLP receiver) and Prometheus / Grafana (on-prem, via an otel-collector). Avoids dual-emit from application code.
Weave side: #6692
What this adds
weave/trace_server/clickhouse/metrics.py(~100 lines):install_metrics(client)rebinds the four hot methods on aclickhouse_connectclient to record three OTEL instruments:weave.clickhouse.query.count(counter, labeled byoperation)weave.clickhouse.query.duration(histogram, seconds, labeled byoperation)weave.clickhouse.query.errors(counter, labeled byoperation)clickhouse_trace_server_batched._mint_client: wraps the client before returning it. Single call site, no churn at the 7300+ line downstream query sites.opentelemetry-api>=1.24.0added to thetrace_serveroptional-deps (runtime) andopentelemetry-sdktotrace_server_tests(test-only, forInMemoryMetricReader).Companion PR
Consumed by a weave-trace PR (
gtarpenning/weave-trace-otel-mvp) inwandb/corethat sets up theMeterProviderand OTLP exporter. Intentionally not bumping theweave-publicsubmodule pointer in that PR until this lands.Test plan
uv run --group test --group trace_server --group trace_server_tests python -m pytest tests/trace_server/test_clickhouse_metrics.py -v-> 2 passeduvx ruff checkclean🤖 Generated with Claude Code