f/add traced op helper - #19
Conversation
Returns the span-bearing ctx and an error-recording stop closure. When a valid OTEL span is in ctx, forks the suplog/logctx logger so field mutations are scoped to this op, and stamps it with this span's trace_id and span_id. Subsequent log calls via logctx.Info(ctx, ...) within the op are auto-tagged so traces and logs can be correlated.
When tracing is disabled (no valid span), still create a forked logger in ctx so callers can accumulate per-op fields via log.WithField(ctx, ...) without those calls silently no-op'ing.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughUpgrades ChangesMetrics reporting with distributed tracing support
Sequence DiagramsequenceDiagram
participant Caller
participant ReportNamed as ReportNamedFuncCallAndTimingCtxWithErr
participant reportTiming
participant logctx as logctx.Attach
participant Closure
Caller->>ReportNamed: ctx, fn, startTags
ReportNamed->>reportTiming: ctx, fn, startTags
reportTiming->>logctx: attach logger to ctx
reportTiming->>reportTiming: set trace_id, span_id if span valid
reportTiming->>ReportNamed: return enriched ctx, stop
ReportNamed->>Caller: enriched ctx, closure
Caller->>Closure: deferred(errPtr, stopTags)
Closure->>Closure: call stop(stopTags...)
Closure->>Closure: ReportClosureFuncError if errPtr != nil && *errPtr != nil (merged tags)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@metrics.go`:
- Around line 84-86: The returned closure in reportTiming currently computes
finalTags by merging start tags with stopTags and then calls stop(finalTags),
which causes duplicate/contradictory keys; instead, keep computing finalTags
only for use with ReportClosureFuncError but invoke stop with the original
stopTags slice (i.e., call stop(stopTags...)); specifically, inside the closure
produced by reportTiming, leave finalTags = MergeTags(... ) for passing into
ReportClosureFuncError, but replace the stop(finalTags) call with
stop(stopTags...) so stop only receives the stop-time tags and does not re-emit
start tags.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
Summary by CodeRabbit
Chores
New Features