Class SampleNameFilter

java.lang.Object
io.prometheus.client.SampleNameFilter
All Implemented Interfaces:
Predicate<String>

public class SampleNameFilter extends Object implements Predicate<String>
Filter samples (i.e. time series) by name.
  • Field Details

  • Constructor Details

  • Method Details

    • test

      public boolean test(String sampleName)
      Specified by:
      test in interface Predicate<String>
    • and

      public Predicate<String> and(Predicate<? super String> other)
      Replacement for Java 8's Predicate.and() for compatibility with Java versions < 8.
    • matchesNameEqualTo

      private boolean matchesNameEqualTo(String metricName)
    • matchesNameNotEqualTo

      private boolean matchesNameNotEqualTo(String metricName)
    • matchesNameStartsWith

      private boolean matchesNameStartsWith(String metricName)
    • matchesNameDoesNotStartWith

      private boolean matchesNameDoesNotStartWith(String metricName)
    • stringToList

      public static List<String> stringToList(String s)
      Helper method to deserialize a delimiter-separated list of Strings into a List<String>.

      delimiter is one of , ; \t \n.

      This is implemented here so that exporters can provide a consistent configuration format for lists of allowed names.

    • restrictToNamesEqualTo

      public static Predicate<String> restrictToNamesEqualTo(Predicate<String> filter, Collection<String> allowedNames)
      Helper method to compose a filter such that Sample names must
      • match the existing filter
      • and be in the list of allowedNames
      This should be used to implement the names[] query parameter in HTTP exporters.
      Parameters:
      filter - may be null, indicating that the resulting filter should just filter by allowedNames.
      allowedNames - may be null or empty, indicating that filter is returned unmodified.
      Returns:
      a filter combining the exising filter and the allowedNames, or null if both parameters were null.