in pkg/rules/nacos2_1_0/service_holder/nacos_go_client_service_holder_setup_210.go [42:73]
func afterNewServiceInfoHolder210(call api.CallContext, holder *naming_cache.ServiceInfoHolder) {
if !experimental.NacosEnabler.Enable() {
return
}
reg, err := experimental.GlobalMeter.RegisterCallback(func(ctx context.Context, observer metric.Observer) error {
attrSet := attribute.NewSet(attribute.KeyValue{
Key: "namespace",
Value: attribute.StringValue(call.GetKeyData("namespace").(string)),
}, attribute.KeyValue{
Key: "cache.dir",
Value: attribute.StringValue(call.GetKeyData("cacheDir").(string)),
}, attribute.KeyValue{
Key: "update.cache.when.empty",
Value: attribute.StringValue(call.GetKeyData("updateCacheWhenEmpty").(string)),
}, attribute.KeyValue{
Key: "not.load.cache.at.start",
Value: attribute.StringValue(call.GetKeyData("notLoadCacheAtStart").(string)),
})
var count int
holder.ServiceInfoMap.Range(func(key, value interface{}) bool {
count++
return true
})
observer.ObserveInt64(experimental.ClientServiceInfoMapSize, int64(count), metric.WithAttributeSet(attrSet))
return nil
}, experimental.ClientServiceInfoMapSize)
if err != nil {
log.Printf("[otel nacos] failed to register metrics for service info holder")
} else {
holder.OtelReg = reg
}
}