1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-07-17 01:12: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

@ -68,11 +68,11 @@ func main() {
if err != nil {
log.Fatal(err)
}
_, err = meter.RegisterCallback([]instrument.Asynchronous{gauge}, func(ctx context.Context) error {
_, err = meter.RegisterCallback(func(ctx context.Context) error {
n := -10. + rand.Float64()*(90.) // [-10, 100)
gauge.Observe(ctx, n, attrs...)
return nil
})
}, gauge)
if err != nil {
log.Fatal(err)
}