You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/08/19 09:26:16 UTC

[GitHub] [pulsar-client-go] ernado opened a new issue #352: Use dependency injection for metrics

ernado opened a new issue #352:
URL: https://github.com/apache/pulsar-client-go/issues/352


   **Is your feature request related to a problem? Please describe.**
   Currently `promauto.NewCounter`, `promauto.NewGauge`, etc are used in such way:
   ```go
   var (
   	consumersOpened = promauto.NewCounter(prometheus.CounterOpts{
   		Name: "pulsar_client_consumers_opened",
   		Help: "Counter of consumers created by the client",
   	})
   
   	consumersClosed = promauto.NewCounter(prometheus.CounterOpts{
   		Name: "pulsar_client_consumers_closed",
   		Help: "Counter of consumers closed by the client",
   	})
   
   	consumersPartitions = promauto.NewGauge(prometheus.GaugeOpts{
   		Name: "pulsar_client_consumers_partitions_active",
   		Help: "Counter of individual partitions the consumers are currently active",
   	})
   )
   ```
   There are several problems with such approach:
   1. Using `prometheus.DefaultRegisterer`
   2. Using global variables
   
   **Describe the solution you'd like**
   1. Add an ability to provide custom prometheus registry instance
   2. Remove global variable usage in favor of dependency injection (e.g. via struct fields like logger)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] faceair commented on issue #352: Use dependency injection for metrics

Posted by GitBox <gi...@apache.org>.
faceair commented on issue #352:
URL: https://github.com/apache/pulsar-client-go/issues/352#issuecomment-697331210


   I'd prefer to add a method that returns only internal statistics, and not bind to prometheus. More generic SDKs are used in this way, e.g. https://golang.org/pkg/database/sql/#DB.Stats, https://github.com/go-redis/redis/blob/v8.2.0/redis.go#L618
   
   We're still using graphite, and maybe someone else is using some other metrics system.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org