morazow commented on code in PR #2711: URL: https://github.com/apache/fluss/pull/2711#discussion_r2940159641
########## helm/templates/_metrics.tpl: ########## @@ -0,0 +1,88 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +{{/* +Returns list of provided reporter names. +*/}} +{{- define "fluss.metrics.reporterNames" -}} +{{- $metrics := .Values.metrics | default dict -}} +{{- $reportersValue := $metrics.reporters | default "" | toString | trim -}} +{{- if eq $reportersValue "" -}} +[] +{{- else -}} +{{- $selected := list -}} +{{- range $raw := regexSplit "\\s*,\\s*" $reportersValue -1 -}} +{{- $name := trim $raw -}} +{{- if ne $name "" -}} +{{- $selected = append $selected $name -}} +{{- end -}} +{{- end -}} +{{- $selected | toYaml -}} +{{- end -}} +{{- end -}} + +{{/* +Checks if prometheus reporter is enabled. +*/}} +{{- define "fluss.metrics.prometheusEnabled" -}} +{{- $reporterNames := include "fluss.metrics.reporterNames" . | fromYamlArray -}} +{{- if has "prometheus" $reporterNames -}} +true +{{- end -}} +{{- end -}} + +{{/* +Renders metrics reporter configuration entries. +Expects the root context as argument. + +From values: + metrics: + reporters: prometheus + prometheus: + port: 9249 + +Renders: + metrics.reporters: prometheus + metrics.reporter.prometheus.port: 9249 + +Only the port is rendered from values. All other reporter options +should be specified via configurationOverrides. +The port must be set via metrics.<name>.port, not via configurationOverrides. +*/}} +{{- define "fluss.metrics.config" -}} Review Comment: Function added to the _helpers.tpl ########## helm/templates/_metrics.tpl: ########## @@ -0,0 +1,88 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + Review Comment: Addressed below ########## helm/templates/configmap.yaml: ########## @@ -26,4 +26,5 @@ data: server.yaml: | {{- range $key, $val := .Values.configurationOverrides }} {{ $key }}: {{ tpl (printf "%v" $val) $ }} - {{- end }} \ No newline at end of file + {{- end }} + {{- include "fluss.metrics.config" . | nindent 4 }} Review Comment: Refactored ✅ For the failure cases, added these validation functions for now: - `fluss.metrics.validateReporterPorts`: fails if a reporter is enabled but its port is missing/empty - `fluss.metrics.validateNoPortOverrides`: fails if a reporter port is set via configurationOverrides -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
