apache / accumulo

Apache Accumulo
https://accumulo.apache.org
Apache License 2.0
1.06k stars 445 forks source link

Add ability to filter out metrics #4599

Open dlmarion opened 4 months ago

dlmarion commented 4 months ago

Is your feature request related to a problem? Please describe. It's possible that a user may not need one or more metrics that we publish via Micrometer.

Describe the solution you'd like I think we can add a method on MeterRegistryFactory, maybe even a default method, that accepts a comma separated list of regular expressions via a property value, that returns a MeterFilter via MeterFilter.deny(Predicate). This MeterFilter that is returned will need to be added to the MeterRegistry using MeterRegistry.meterFilter.

keith-turner commented 4 months ago

One way to do this w/ the existing code is by subclassing an existing MeterRegistryFactory

package mypackage;

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.config.MeterFilter;
import org.apache.accumulo.core.spi.metrics.LoggingMeterRegistryFactory;

public class FilteringLoggingMRFactory extends LoggingMeterRegistryFactory {
    @Override
    public MeterRegistry create(final InitParameters params) {
       var meterRegistry = super.create(params);
        MeterFilter myFilter = MeterFilter.denyNameStartsWith("accumulo.gc");
        meterRegistry.config().meterFilter(myFilter);
        return meterRegistry;
    }
}
dlmarion commented 3 months ago

So, that's a fair point. We don't necessarily have to implement something to provide some base functionality. A user can extend one of our existing implementations or create their own to provide this functionality.

keith-turner commented 3 months ago

We don't necessarily have to implement something to provide some base functionality. A user can extend one of our existing implementations or create their own to provide this functionality.

Wondering if it would be useful to provide some kind of help in the SPI for building micrometer filters related to Accumulo metrics. One possible way to do this would be to have constants related to metrics in the SPI. This could enable writing a MeterRegistryFactory that manipulates Accumulo metrics using those constants. Could have something like the following.

package org.apache.accumulo.core.spi.metrics;

class MetricsConstants {

   static class Tags {
           String INSTANCE_TAG = "instance.name";
  }

  static class Meters {
           String COMPACTIONS_QUEUED = "...";
  }
}

With the above then could have a scenario like the following.

Completely unrelated to metrics, but if this approach of putting metrics related constants in the SPI works then it could also potentially work for Accumulo's properties. Could have constants related to those in the SPI maybe.

ArbaazKhan1 commented 3 months ago

I can take a look at this