From 828892954b406e19cc34d765a61c23533fc35d2e Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Tue, 24 Jan 2023 07:56:11 -0800 Subject: [PATCH] Update the RegisterCallback of the SDK meter (#3604) --- sdk/metric/meter.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sdk/metric/meter.go b/sdk/metric/meter.go index 7a4d6f9d377..e6732ff5ff3 100644 --- a/sdk/metric/meter.go +++ b/sdk/metric/meter.go @@ -205,8 +205,16 @@ func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float6 return inst, nil } -// RegisterCallback registers the function f to be called when any of the -// insts Collect method is called. +// RegisterCallback registers f to be called each collection cycle so it will +// make observations for insts during those cycles. +// +// The only instruments f can make observations for are insts. All other +// observations will be dropped and an error will be logged. +// +// Only instruments from this meter can be registered with f, an error is +// returned if other instrument are provided. +// +// The returned Registration can be used to unregister f. func (m *meter) RegisterCallback(f metric.Callback, insts ...instrument.Asynchronous) (metric.Registration, error) { if len(insts) == 0 { // Don't allocate a observer if not needed.