使用了 DBResolver 读写分离怎么获取对应的数据库连接地址 和 DB.Stats()

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: li-jin-gou

@JellyZero 思路是遍历 GormPlugin, 获取到 DBResolver,这样就可以对应所有的数据库连接,从而获取 DB.Stats()

@zstone12 https://github.com/go-gorm/opentelemetry 看看是否需要适配这个场景

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: JellyZero

@JellyZero 思路是遍历 GormPlugin, 获取到 DBResolver,这样就可以对应所有的数据库连接,从而获取 DB.Stats()

@zstone12 https://github.com/go-gorm/opentelemetry 看看是否需要适配这个场景

获取 链接dns 呢?我尝试过反射获取不到,能贴一下代码吗

Comment From: li-jin-gou

@JellyZero 思路是遍历 GormPlugin, 获取到 DBResolver,这样就可以对应所有的数据库连接,从而获取 DB.Stats() @zstone12 https://github.com/go-gorm/opentelemetry 看看是否需要适配这个场景

获取 链接dns 呢?我尝试过反射获取不到,能贴一下代码吗

gorm 没有提供获取 DSN 的接口并且不会提供,用户如果想要获取的话可以自行获取其他方式获取

Comment From: JellyZero

没有提供获取 DSN 的接口并且不会提供,用户如果想要获取的话可以自行获取

咋获取呢?没有这种需求吗?使用了读写分离插件就不知道是哪个连接在操作啊

Comment From: li-jin-gou

使用反射