1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-29 23:07:45 +02:00

Restructure RegisterCallback method (#3587)

* Restructure RegisterCallback method

Instead of accepting instruments to register the callback with as a
slice, accept them as variadic arguments.

* Add changes to changelog

* Add PR number to changes
This commit is contained in:
Tyler Yahn
2023-01-13 08:31:14 -08:00
committed by GitHub
parent 42863522e5
commit f941b3a8df
10 changed files with 67 additions and 66 deletions

View File

@@ -200,7 +200,7 @@ func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float6
// RegisterCallback registers the function f to be called when any of the
// insts Collect method is called.
func (m *meter) RegisterCallback(insts []instrument.Asynchronous, f metric.Callback) (metric.Registration, error) {
func (m *meter) RegisterCallback(f metric.Callback, insts ...instrument.Asynchronous) (metric.Registration, error) {
for _, inst := range insts {
// Only register if at least one instrument has a non-drop aggregation.
// Otherwise, calling f during collection will be wasted computation.