spring-projects / spring-projects/spring-boot

Enable Cassandra Driver Metrics Via Properties

Open
#28,915 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: pending-design-work theme: observability type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

Current behaviour

To enable the cassandra 4.x driver metrics, you need to provide the configuration below, which includes the fully qualified class name of the MetricsFactory implementation within the cassandra driver and lists of the metric names to enable.

    @Configuration
    public static class CassandraMetricConfig {
        @Bean
        public DriverConfigLoaderBuilderCustomizer driverConfigLoaderBuilderCustomizer() {
            return builder -> {
                builder.withString(METRICS_FACTORY_CLASS, "com.datastax.oss.driver.internal.metrics.micrometer.MicrometerMetricsFactory");
                builder.withStringList(METRICS_SESSION_ENABLED, List.of("connected-nodes", "cql-requests"));
                builder.withStringList(METRICS_NODE_ENABLED, List.of("pool.open-connections", "pool.in-flight"));
            };
        }
    }
Proposed Behaviour

Expose a property to enabled the cassandra 4.x metrics, which if enabled will autoconfigure a DriverConfigLoaderBuilderCustomizer which will set the metrics factory class property to micrometer ie.

spring.data.cassandra.metrics.enabled: true

Expose two other properties to allow a user to configure which metrics should be enabled

spring.data.cassandra.metrics:
     session:
         - cql-requests
         - connected-nodes
     node:
         - pool.open-connections
         - pool.in-flight
Justification

To me, this feels like a very common use case and with the current way of enabling will likely result in developers writing their own ConfigurationProperties classes to give them the ability to configure this via properties. Should we provide an out of the box solution to make this easier for developers to use? No code required, just properties.

NOTE
More than happy for the proposed property names to be changed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the Cassandra auto-configuration around DriverConfigLoaderBuilderCustomizer and the proposed spring.data.cassandra.metrics properties. Done means enabling the property selects the Micrometer metrics factory and the session and node lists configure the metrics exposed by the Cassandra 4.x driver.

Written by the indexing model from the issue text.

Assessment

Tech stack
cassandra, java, spring-boot
Domain
backend, databases, observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.