Repository navigation
feat(go): support typed batch observations - #65
Conversation
yordis
commented
Nov 1, 2026
- Related observable metrics need a shared snapshot for consistent collection.
- Batch registration must preserve schema identity and typed attributes while keeping SDK handles private.
- Existing per-instrument callbacks must remain compatible.
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
PR SummaryMedium Risk Overview Generated code now includes
Documentation, Reviewed by Cursor Bugbot for commit c9bba66. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Scoped callback and observation API templates/code/go/scope_meter.go.j2, templates/code/go/meter.go.j2, templates/code/go/tests/*/expected/internal/scope/meter.go, templates/code/go/tests/*/expected/*meter/meter.go |
The scoped meter adds opaque observable handles, callback registration, typed observation helpers, and safe unregistration. Generated meter packages expose the scoped types through aliases. |
Generated batch metric APIs templates/code/go/metrics.go.j2, templates/code/go/tests/*/expected/*metric/metrics.go, templates/code/go/tests/batch_observables/expected/*, templates/code/go/tests/batch_observables/registry/*, templates/code/go/README.md |
Generated metric APIs add batch-observable constructors, handles, Observe, and, where attributes exist, ObserveSet. Examples cover multiple instrument types, attributes, sets, and schema-scoped meter construction. |
Batch API behavior tests templates/code/go/tests/batch_observables/consumer/myappmetric/*_test.go |
Tests cover collection results, registration validation, meter ownership, callback context and errors, unregistration, zero values, and concurrent collections. |
Compile and identifier validation templates/code/go/tests/batch_observables/compile-fail/*, templates/code/go/tests/error_batch_*/*, templates/code/go/weaver.yaml |
Compile-fail cases check invalid batch-observable calls and inaccessible native handles. Collision cases and generator validation include generated batch-observable names. |
Estimated code review effort: 4 (Complex) | ~60 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant Caller
participant ScopeMeter as scope.Meter
participant MetricMeter as metric.Meter
participant BatchMetric as QueueDepthBatchObservable
Caller->>ScopeMeter: RegisterCallback(callback, observable)
ScopeMeter->>MetricMeter: RegisterCallback(native callback, instruments)
MetricMeter->>ScopeMeter: Invoke callback with context and native observer
ScopeMeter->>Caller: Supply scoped Observer to callback
Caller->>BatchMetric: Observe(observer, value, attributes)
BatchMetric->>ScopeMeter: ObserveInt64(observer, handle, value, options)
Possibly related PRs
- TrogonStack/trogonstack-weaver-packages#62: Updates Go observer attribute handling with attribute sets and reusable options, which the batch observation methods also use.
Merge Risk: 
Minimal · up to c9bba
-
The change adds typed batch observable metrics to the Go generator while keeping existing per-instrument callbacks working. No concrete defect was identified in the supplied files. The remaining uncertainty is ordinary: the Go toolchain version for the generated consumer tests was not supplied. The change appears ready to merge after normal CI checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 75.36% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 69 functions across 46 files. (23 skipped: 23 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit records a queue’s bright glow
With one shared call, the values flow
A handle keeps each note in scope
Sets bring attributes, clear and whole
Then off I hop, with metrics in tow!