Package codes.grow.packages.loki
Class CardinalityGuard
java.lang.Object
codes.grow.packages.loki.CardinalityGuard
Keeps Loki's index small: only allowlisted names become index labels, everything else is sent as
structured metadata (per entry, not indexed).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallowed()Returns the allowlist, sorted.apply(LokiStream stream) Returns a copy of the stream whose labels outside the allowlist are moved to the structured metadata of every entry (an entry's own metadata wins).static CardinalityGuarddefaults()Returns a guard withLabels.DEFAULT_ALLOWED_LABELS.booleanReturns whether a name may be an index label.voidSplits attributes into index labels (allowlisted, non-empty scalar text) and structured metadata.toString()
-
Constructor Details
-
CardinalityGuard
Creates a guard.- Parameters:
allowed- label names that may become index labels
-
-
Method Details
-
defaults
Returns a guard withLabels.DEFAULT_ALLOWED_LABELS.- Returns:
- the default guard
-
allowed
Returns the allowlist, sorted.- Returns:
- immutable list
-
isAllowed
Returns whether a name may be an index label.- Parameters:
name- label name- Returns:
- true when allowlisted
-
apply
Returns a copy of the stream whose labels outside the allowlist are moved to the structured metadata of every entry (an entry's own metadata wins).- Parameters:
stream- stream- Returns:
- the guarded stream
-
split
Splits attributes into index labels (allowlisted, non-empty scalar text) and structured metadata. Keys are normalized withLabels.normalizeLabelName(java.lang.String); values are rendered withLabels.attrToString(java.lang.Object). Keys are processed in sorted order, so the result is deterministic when two keys normalize to the same name.- Parameters:
attributes- attributeslabels- receives index labelsmetadata- receives structured metadata
-
toString
-