Skip to content

Commit 8351e23

Browse files
committed
docs(observability-proxy): give the real reason for the prefix check
The prefix is quoted before it reaches the regex, so a metacharacter or an upper case letter cannot widen the scope. Such a prefix matches no namespace at all and silently drops the exporter series, which is what the flag check guards against. Assisted-by: LLM Signed-off-by: Maxim Belyy <[email protected]>
1 parent 0e4711b commit 8351e23

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

‎cmd/observability-proxy/main.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ func parseFlags(args []string) (options, error) {
113113
return o, fmt.Errorf("invalid metrics store name %q", store)
114114
}
115115
}
116-
// Anything but namespace name characters would make the prefix match
117-
// differently from the namespaces it is meant to name.
116+
// The prefix is matched literally, so one no namespace name can start
117+
// with would turn the exporter branch off without a word.
118118
if p := o.metrics.PlatformNamespacePrefix; p != "" && len(validation.IsDNS1123Label(p+"x")) > 0 {
119119
return o, fmt.Errorf("invalid metrics platform namespace prefix %q", p)
120120
}

‎cmd/observability-proxy/main_test.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ func TestParseFlagsInvalid(t *testing.T) {
112112
{"--metrics-max-range=0s"},
113113
{"--metrics-max-points=1"},
114114
{"--metrics-max-timeout=0s"},
115-
// Only namespace name characters: a regex metacharacter or an upper
116-
// case letter would widen or empty the scope.
115+
// No namespace name starts with these, so they would match nothing.
117116
{"--metrics-platform-namespace-prefix=Cozy-"},
118117
{"--metrics-platform-namespace-prefix=cozy.*"},
119118
{"--metrics-platform-namespace-prefix=-"},

0 commit comments

Comments
 (0)