1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-27 22:49:15 +02:00

Redesign RegisterCallback API (#3584)

* Update RegisterCallback and Callback declerations

RegisterCallback accepts variadic Asynchronous instruments instead of a
slice.

Callback accepts an observation result recorder to ensure instruments
that are observed by a callback.

* Update global, noop, SDK implementations
* Fix examples
* Add changes to changelog
* Test RegisterCallback for invalid observers
* Test callbacks from foreign sources not collected
* Support registering delegating instruments
This commit is contained in:
Tyler Yahn
2023-01-19 06:18:26 -08:00
committed by GitHub
parent e8c6e45178
commit 69b18e62a7
12 changed files with 630 additions and 114 deletions

View File

@@ -54,7 +54,7 @@ func TestEmptyPipeline(t *testing.T) {
})
require.NotPanics(t, func() {
pipe.addMultiCallback(emptyCallback)
pipe.addMultiCallback(func(context.Context) error { return nil })
})
output, err = pipe.produce(context.Background())
@@ -78,7 +78,7 @@ func TestNewPipeline(t *testing.T) {
})
require.NotPanics(t, func() {
pipe.addMultiCallback(emptyCallback)
pipe.addMultiCallback(func(context.Context) error { return nil })
})
output, err = pipe.produce(context.Background())
@@ -121,7 +121,7 @@ func TestPipelineConcurrency(t *testing.T) {
wg.Add(1)
go func() {
defer wg.Done()
pipe.addMultiCallback(emptyCallback)
pipe.addMultiCallback(func(context.Context) error { return nil })
}()
}
wg.Wait()