in pkg/rules/nacos/dom/nacos_go_client_dom_setup.go [46:85]
func afterNewBeatReactor(call api.CallContext, b naming_http.BeatReactor) {
if !experimental.NacosEnabler.Enable() {
return
}
t := reflect.ValueOf(&b).Elem()
beatMapField := t.FieldByName("beatMap")
if beatMapField.IsValid() {
bf := reflect.NewAt(beatMapField.Type(), unsafe.Pointer(beatMapField.UnsafeAddr())).Elem()
beatMap, ok := bf.Interface().(cache.ConcurrentMap)
if !ok {
return
}
attrSet := attribute.NewSet(attribute.KeyValue{
Key: "namespace",
Value: attribute.StringValue(call.GetKeyData("namespace").(string)),
}, attribute.KeyValue{
Key: "region",
Value: attribute.StringValue(call.GetKeyData("region").(string)),
}, attribute.KeyValue{
Key: "appName",
Value: attribute.StringValue(call.GetKeyData("appName").(string)),
}, attribute.KeyValue{
Key: "appKey",
Value: attribute.StringValue(call.GetKeyData("appKey").(string)),
}, attribute.KeyValue{
Key: "userName",
Value: attribute.StringValue(call.GetKeyData("userName").(string)),
})
reg, err := experimental.GlobalMeter.RegisterCallback(func(ctx context.Context, observer metric.Observer) error {
observer.ObserveInt64(experimental.ClientDomBeatMapSize, int64(beatMap.Count()), metric.WithAttributeSet(attrSet))
return nil
}, experimental.ClientDomBeatMapSize)
if err != nil {
log.Printf("[otel nacos] failed to register metrics for beat map, %v\n", err)
} else {
b.OtelReg = reg
call.SetReturnVal(0, b)
}
}
}