feat(sync-service): populate num_bytes and subset_result span attributes#4143
feat(sync-service): populate num_bytes and subset_result span attributes#4143
Conversation
Expose previously-empty telemetry span attributes so the corresponding
Honeycomb columns can be queried:
- `num_bytes` on the ServeShapePlug root span, mirroring the existing
`bytes` telemetry measurement emitted alongside `http.response_size`.
- `electric.subqueries.subset_result.{bytes,rows,duration_µs}` on the
subset materialisation path in `PartialModes.record_subset_metrics/4`.
`chunk_size` is already emitted as a span attribute on the
`shape_get.plug.stream_chunk` child span; no change required.
`shape_snapshot.query.duration_µs` landed in #4110.
Refs electric-sql/stratovolt#1465
Claude Code ReviewSummaryThis PR adds two previously-missing OpenTelemetry span attributes: What's Working Well
Issues FoundSuggestions (Nice to Have)1. Inaccurate comment in File: The comment says the attributes are added "on the enclosing shape request span", but at the point This is arguably the right place for them (the metrics are about the query execution), but the comment will mislead anyone debugging why the values don't appear on the root span. Suggested fix: # Expose subset materialisation metrics as span attributes on the
# shape_snapshot.query_fn child span so they become queryable
# Honeycomb columns. Mirrors the telemetry event measurements above.2. No automated verification of the new attributes The test plan defers verification to a live Honeycomb deployment. The existing Issue ConformanceThe PR references Review iteration: 1 | 2026-04-21 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4143 +/- ##
=======================================
Coverage 89.20% 89.20%
=======================================
Files 25 25
Lines 2520 2520
Branches 636 639 +3
=======================================
Hits 2248 2248
Misses 270 270
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Clarify that the span attributes added in PartialModes.record_subset_metrics/4 land on the active shape_snapshot.query_fn child span (not the enclosing shape request span), addressing review feedback on PR #4143. - Stop tracking .agent-tasks/ in Git and add it to .gitignore. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
num_bytesspan attribute on theServeShapePlugroot span, mirroring the existingbytestelemetry measurement emitted alongsidehttp.response_size.electric.subqueries.subset_result.{bytes,rows,duration_µs}span attributes at the end ofPartialModes.record_subset_metrics/4so the subset-materialisation metrics become queryable Honeycomb columns.chunk_sizeis already wired on theshape_get.plug.stream_chunkchild span — no change required.shape_snapshot.query.duration_µslanded in chore(sync-service): instrument snapshot query timing #4110 — no change required.Refs electric-sql/stratovolt#1465.
Test plan
mix compile(sync-service)mix test test/electric/plug/serve_shape_plug_test.exs— 38 passingnum_bytesandelectric.subqueries.subset_result.*columns are populated for new spans.Generated with Claude Code.