1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-05-22 09:35:21 +02:00

Support use of synchronous instruments in async callbacks (#725)

* Support use of synchronous instruments in async callbacks

* Add a test
This commit is contained in:
Joshua MacDonald
2020-05-19 21:33:10 -07:00
committed by GitHub
parent c5f2252c48
commit 1fab21ddbf
13 changed files with 78 additions and 47 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ func main() {
commonLabels := []kv.KeyValue{lemonsKey.Int(10), kv.String("A", "1"), kv.String("B", "2"), kv.String("C", "3")}
oneMetricCB := func(result metric.Float64ObserverResult) {
oneMetricCB := func(_ context.Context, result metric.Float64ObserverResult) {
result.Observe(1, commonLabels...)
}
_ = metric.Must(meter).RegisterFloat64ValueObserver("ex.com.one", oneMetricCB,
+1 -1
View File
@@ -52,7 +52,7 @@ func main() {
observerLock := new(sync.RWMutex)
observerValueToReport := new(float64)
observerLabelsToReport := new([]kv.KeyValue)
cb := func(result metric.Float64ObserverResult) {
cb := func(_ context.Context, result metric.Float64ObserverResult) {
(*observerLock).RLock()
value := *observerValueToReport
labels := *observerLabelsToReport