How to handle array variable in registercallback function #4159
Replies: 1 comment
-
This looks like a duplicate of #4157 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am using opentelemetry to export some customize data to otelcollector. Here my question is any possibility to pass the array arguments into RegisterCallback()
In the below code, instead of passing name1[0], name1[1], name1[2]... any possibility of send name1. Also, is there any api/method to resolve the type converstion. Since name1 data type is metric.Int64ObservableCounter but register to call back argument is metric.Observable.
var name1 []metric.Int64ObservableCounter
......
_, err = meter.RegisterCallback(
func(ctx context.Context, o metric.Observer) error {
o.ObserveInt64(name1[0], int64(getMetricValue(fullName1)))
o.ObserveInt64(name1[1], int64(getMetricValue(fullName2)))
o.ObserveInt64(name1[2], int64(getMetricValue(fullName3)))
o.ObserveInt64(name1[3], int64(getMetricValue(fullName4)))
return nil
},
name1[0],
name1[1],
name1[2],
name1[3],
)
kindly guide me.
Beta Was this translation helpful? Give feedback.
All reactions