You need to show more of your code, but it looks like you're not importing 
this library properly.

The code appears in a package called "collectors": 
see https://github.com/prometheus/client_golang/pull/862/files
so unless you import it under a different name, that's what you'll have to 
use.  And you'll need to use the right import path.

https://play.golang.org/p/7Dgu6MJGidJ

On Wednesday, 18 August 2021 at 12:38:52 UTC+1 afridi wrote:

>
> Hey everyone,
>
> Need some help regarding the usage for the  collector for 
> database/sql(DBStats). I am instrumenting my go code and want to get 
> metrics for connection pool.
>
> I was planning to use this awesome nice library 
> <http://github.com/dlmiddlecote/sqlstats>by dlmiddlecote dbstates. I 
> created a demo and it works fine. 
>
>
>
> *//sample code for above librarycollector := 
> sqlstats.NewStatsCollector(conf.DB.Type, db.GetConnection())// Register it 
> with Prometheus // prometheus.MustRegister(collector)*
>
> However, recently I have notice that client_go(already using this) have 
> this new same feature in latest release version 1.11.0 
> <https://github.com/prometheus/client_golang/releases/tag/v1.11.0> and it 
> was merged in this PR 
> <https://github.com/prometheus/client_golang/pull/866>. 
>
>
> *//sample code for client_go*
> *reg := prometheus.NewRegistry()*
> * reg.MustRegister(prometheus.NewDBStatsCollector(db.GetConnection(), 
> "db_A"))*
>
> Now my question, can someone provide me POC for this feature like how to 
> instrument my code. I tried but due lake of experience I am failing, you 
> can see the error in the subject of this post that I am getting. Any help 
> would be appreciated.
>
> Regards,
> Afr
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/bfb00ac2-f78a-4245-a7ff-60a10ce99843n%40googlegroups.com.

Reply via email to