← Back to Pull requests

feat(sync): stamp connector identity on sync/dotc1z spans + c1z size metric #910

Closed
unknown closed this pull request without merging on Jun 05, 2026 17:11 UTC
View on GitHub
unknown unknown commented on Jun 02, 2026 22:39 UTC
Author

Why

Sync and dotc1z spans already exist (syncer.Sync, syncer.SyncResources/Grants/Entitlements, C1File.Vacuum/Cleanup/finalize, …) but carry no connector identity, so a single connector's sync/c1z work can't be filtered per-connector in APM. In a recent incident a connector's sync silently looped + VACUUMed for days and was only findable via CPU profile labels — the spans were useless for it. This closes that gap and adds the c1z-size signal that loop would have surfaced immediately.

What

  • uotel.SyncIdentity — context-propagated {tenant_id, connector_id, catalog_id, catalog_name}. Attribute keys match the platform's pprof.Do labels, so spans and CPU profiles line up on the same dimensions.

  • sync.WithSyncIdentity(...) option — Sync() injects identity into the run context, so every descendant span (sync and dotc1z, via the threaded ctx) gets stamped. Explicit option wins; otherwise inherits whatever the caller already set on ctx.

  • Identity stamped on every linked-root sync operation span + C1File.Vacuum/Cleanup/finalize/saveC1z.

  • Bounded summary span on the parallel fan-out (syncParallel): one span per batch with sync.op / sync.action_count / sync.worker_count. The per-action work already starts its own StartWithLink root, so this stays a handful of spans per sync — traces do not grow with resource/grant count.

  • C1File.Vacuum records c1z.vacuum.{size_before,size_after,reclaimed}_bytes.

  • c1z_size_bytes gauge (phase=vacuum|finalize), tagged catalog_name only — connector_id is too high-cardinality for a metric and is already on the spans for per-connector drill-down.
  • Trace-length safety

    No new per-item spans. Identity stamping is attributes on existing spans; the only new span is one bounded summary per fan-out batch. The existing StartWithLink (new-root-linked-to-parent) pattern is preserved throughout.

    Wiring

    Identity flows by context value, so this lights up once the platform caller sets it (the ductone/c1 sync activity already computes tenant_id/connector_id/catalog_id/catalog_name for its pprof.Do labels — a follow-up passes the same values via WithSyncIdentity after this SDK release). Until then the changes are inert no-ops.

    Test

  • New pkg/uotel/identity_test.go (Attrs/IsZero/context round-trip).

  • go build + go vet clean (incl. -tags=baton_lambda_support); pkg/uotel, pkg/dotc1z, pkg/sync tests pass.
  • 🤖 Generated with Claude Code

    Diff: 318 lines (+238 / -80) across 3 files Reviewer: arreyder Review duration: 3992m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 318 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.345
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #910"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.4% (MEDIUM) · Higher = larger blast radius
    40.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.0% · Safe to merge
    16.0%