instaclustr / cassandra-exporter

Java agent for exporting Cassandra metrics to Prometheus
Apache License 2.0
73 stars 46 forks source link

Feature: support for plugglabe metrics suppliers #96

Open chicobento opened 3 years ago

chicobento commented 3 years ago

We have a set of cassandra plugins developed within the company. The plugins are exposing their own set of metrics via JMX. We would like to expose those metrics to prometheus via cassandra-exporter along the standard set of supported metrics. Please, provide a way of plugging in new metrics.

By looking at the code, I found that it could be potentially achieved by dynamically loading FactoriesSupplier classes. Simple solution is to load multiple FactoriesSuppliers via java.util.ServiceLoader facility.

Please let me know your thoughts and I may contribute with a PR if such feature is acceptable.

chicobento commented 3 years ago

I created an initial PR. Some other refactoring may be done such as providing the existing metrics in FactoriesSupplier via the FactoryProvider interface.

With this feature, the #74 issue is still more relevant, so that cassandra-exporter plugins can get the common.jar dependency for compilation via maven or gradle.

zegelin commented 3 years ago

Thanks for the PR @chicobento. I really like the idea of having dynamic providers. In fact, this could even be a good path forward to enabling compatibility with C* 4.0 (since it'll need a different set of collectors).

chicobento commented 3 years ago

Hi @zegelin , yes, I was thinking on splitting the core module from the 'default' collector provider lets say, but that would make the deployment a bit more tricky for now - however this could be something to consider with the C* 4.0 in the landscape.

Just so you know, I did some integration tests internally and it is working fine: my cassandra plugin metrics can be seen on the scrap interface. Pls let me know your feedback on the PR and the minimal changes to get it merged - I might have some time to work on adjustments over the next days if needed.

ps: the company has intention on opening the code for the plugin, so both its core code and the cassandra-exporter integration should be available in github in near future