class Builder {

        private boolean enabled = DEFAULT_ENABLED;

        private boolean histogram = DEFAULT_HISTOGRAM;

        private boolean localDistinction = DEFAULT_LOCAL_DISTINCTION;

        private Predicate<RedisCommand<?, ?, ?>> metricsFilter = command -> true;

        private Duration maxLatency = DEFAULT_MAX_LATENCY;

        private Duration minLatency = DEFAULT_MIN_LATENCY;

        private Tags tags = Tags.empty();

        private double[] targetPercentiles = DEFAULT_TARGET_PERCENTILES;

        private Builder() {
        }

        /**
         * Disable the latency collector.
         *
         * @return this {@link Builder}.
         */
        public Builder disable() {
            this.enabled = false;
            return this;
        }

        /**
         * Enable the latency collector.
         *
         * @return this {@link Builder}.
         */
        public Builder enable() {
            this.enabled = true;
            return this;
        }

        /**
         * Enable histogram buckets used to generate aggregable percentile approximations in monitoring systems that have query
         * facilities to do so.
         *
         * @param histogram {@code true} if histogram buckets are recorded
         * @return this {@link Builder}.
         */
        public Builder histogram(boolean histogram) {
            this.histogram = histogram;
            return this;
        }

        /**
         * Enables per connection metrics tracking insead of per host/port. If {@code true}, multiple connections to the same
         * host/connection point will be recorded separately which allows to inspect every connection individually. If
         * {@code false}, multiple connections to the same host/connection point will be recorded together. This allows a
         * consolidated view on one particular service. Defaults to {@code false}. See
         * {@link MicrometerOptions#DEFAULT_LOCAL_DISTINCTION}.
         *
         * Warning: Enabling this could potentially cause a label cardinality explosion in the remote metric system and should
         * be used with caution.
         *
         * @param localDistinction {@code true} if latencies are recorded distinct on local level (per connection)
         * @return this {@link Builder}.
         */
        public Builder localDistinction(boolean localDistinction) {
            this.localDistinction = localDistinction;
            return this;
        }

        /**
         * Sets which commands are enabled for latency recording. Defaults to an empty list, which means all commands will be
         * recorded. Configuring enabled commands overwrites {@link #metricsFilter(Predicate)}.
         *
         * @param commands list of Redis commands that are enabled for latency recording, must not be {@code null}
         * @return this {@link Builder}.
         * @since 6.3
         */
        public Builder enabledCommands(CommandType... commands) {

            LettuceAssert.notNull(commands, "Commands must not be null");

            if (commands.length == 0) {
                return metricsFilter(command -> true);
            }

            Set<String> enabledCommands = new HashSet<>(commands.length);
            for (CommandType enabledCommand : commands) {
                enabledCommands.add(enabledCommand.name());
            }

            return metricsFilter(command -> enabledCommands.contains(command.getType().name()));
        }

        /**
         * Configures a filter {@link Predicate} to filter which commands should be reported to Micrometer.
         *
         * @param filter the filter predicate to test commands.
         * @return this {@link Builder}.
         * @since 6.3
         */
        public Builder metricsFilter(Predicate<RedisCommand<?, ?, ?>> filter) {<FILL_FUNCTION_BODY>}

        /**
         * Sets the maximum value that this timer is expected to observe. Sets an upper bound on histogram buckets that are
         * shipped to monitoring systems that support aggregable percentile approximations. Only applicable when histogram is
         * enabled. Defaults to {@code 5m}. See {@link MicrometerOptions#DEFAULT_MAX_LATENCY}.
         *
         * @param maxLatency the maximum value that this timer is expected to observe, must not be {@code null}
         * @return this {@link Builder}.
         */
        public Builder maxLatency(Duration maxLatency) {
            LettuceAssert.notNull(maxLatency, "Max Latency must not be null");
            this.maxLatency = maxLatency;
            return this;
        }

        /**
         * Sets the minimum value that this timer is expected to observe. Sets a lower bound on histogram buckets that are
         * shipped to monitoring systems that support aggregable percentile approximations. Only applicable when histogram is
         * enabled. Defaults to {@code 1ms}. See {@link MicrometerOptions#DEFAULT_MIN_LATENCY}.
         *
         * @param minLatency the minimum value that this timer is expected to observe
         * @return this {@link Builder}.
         */
        public Builder minLatency(Duration minLatency) {
            LettuceAssert.notNull(minLatency, "Min Latency must not be null");
            this.minLatency = minLatency;
            return this;
        }

        /**
         * Extra tags to add to the generated metrics. Defaults to {@code Tags.empty()}.
         *
         * @param tags tags to add to the metrics
         * @return this {@link Builder}.
         */
        public Builder tags(Tags tags) {
            LettuceAssert.notNull(tags, "Tags must not be null");
            this.tags = tags;
            return this;
        }

        /**
         * Sets the emitted percentiles. Defaults to {@code 0.50, 0.90, 0.95, 0.99, 0.999} for the 50th, 90th, 95th, 99th, and
         * 99th percentiles. Only applicable when histogram is enabled. See
         * {@link MicrometerOptions#DEFAULT_TARGET_PERCENTILES}.
         *
         * @param targetPercentiles the percentiles which should be emitted, must not be {@code null}
         * @return this {@link Builder}.
         */
        public Builder targetPercentiles(double[] targetPercentiles) {
            LettuceAssert.notNull(targetPercentiles, "TargetPercentiles must not be null");
            this.targetPercentiles = targetPercentiles;
            return this;
        }

        /**
         * @return a new instance of {@link MicrometerOptions}.
         */
        public MicrometerOptions build() {
            return new MicrometerOptions(this);
        }

    }

            LettuceAssert.notNull(filter, "Metrics filter predicate must not be null");
            this.metricsFilter = filter;
            return this;
        
<no_super_class>