Package io.prometheus.client
Class SampleNameFilter
java.lang.Object
io.prometheus.client.SampleNameFilter
Filter samples (i.e. time series) by name.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionFor convenience, a filter that allows all names.private final Collection
<String> private final Collection
<String> private final Collection
<String> private final Collection
<String> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
SampleNameFilter
(Collection<String> nameIsEqualTo, Collection<String> nameIsNotEqualTo, Collection<String> nameStartsWith, Collection<String> nameDoesNotStartWith) -
Method Summary
Modifier and TypeMethodDescriptionReplacement for Java 8'sPredicate.and()
for compatibility with Java versions < 8.private boolean
matchesNameDoesNotStartWith
(String metricName) private boolean
matchesNameEqualTo
(String metricName) private boolean
matchesNameNotEqualTo
(String metricName) private boolean
matchesNameStartsWith
(String metricName) 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 thenames[]
query parameter in HTTP exporters.Helper method to deserialize adelimiter
-separated list of Strings into aList<String>
.boolean
-
Field Details
-
ALLOW_ALL
For convenience, a filter that allows all names. -
nameIsEqualTo
-
nameIsNotEqualTo
-
nameStartsWith
-
nameDoesNotStartWith
-
-
Constructor Details
-
SampleNameFilter
private SampleNameFilter(Collection<String> nameIsEqualTo, Collection<String> nameIsNotEqualTo, Collection<String> nameStartsWith, Collection<String> nameDoesNotStartWith)
-
-
Method Details
-
test
-
and
Replacement for Java 8'sPredicate.and()
for compatibility with Java versions < 8. -
matchesNameEqualTo
-
matchesNameNotEqualTo
-
matchesNameStartsWith
-
matchesNameDoesNotStartWith
-
stringToList
Helper method to deserialize adelimiter
-separated list of Strings into aList<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
names[]
query parameter in HTTP exporters.- Parameters:
filter
- may be null, indicating that the resulting filter should just filter byallowedNames
.allowedNames
- may be null or empty, indicating thatfilter
is returned unmodified.- Returns:
- a filter combining the exising
filter
and theallowedNames
, ornull
if both parameters werenull
.
-