<commit_before>{{- define "joinKey" -}}
{{ range $item, $_ := . -}}{{$item | replace "." "_" -}},{{- end }}
{{- end -}}

{{- define "util.helpers.valuesToIni" -}}
  {{- range $section, $values := . -}}
[{{ $section }}]
    {{- range $key, $value := $values}}
{{ $key }} = {{ $value }}
    {{- end }}

{{ end }}
{{- end }}

{{- define "loggerIni" -}}
{{ range $top_level_key, $value := . }}
[{{ $top_level_key }}]
keys={{ include "joinKey" $value | trimAll "," }}
{{range $item, $values := $value}}

[{{ $top_level_key | trimSuffix "s" }}_{{ $item | replace "." "_" }}]
{{- if and (eq $top_level_key "loggers") (ne $item "root")}}
qualname={{ $item }}
propagate=0
{{- end}}
{{- range $key, $value := $values }}
{{ $key }}={{ $value }}
{{- end }}
{{- end }}
{{ end }}
{{- end }}

{{- define "osprofiler_url" }}
    {{- $options := merge .Values.osprofiler .Values.global.osprofiler -}}
    {{- if $options.jaeger.enabled -}}
jaeger://localhost:6831
    {{- else if $options.redis -}}
redis://:{{ $options.redis.redisPassword }}@flamegraph-redis.monsoon3.svc.kubernetes.{{ .Values.global.region }}.{{ .Values.global.tld }}:6379/0
    {{- end -}}
{{- end }}

{{- define "osprofiler" }}
    {{- $options := merge .Values.osprofiler .Values.global.osprofiler }}
    {{- if $options.enabled }}<commit_msg>[jaeger] Fix osprofiler helper function<commit_after>{{- define "joinKey" -}}
{{ range $item, $_ := . -}}{{$item | replace "." "_" -}},{{- end }}
{{- end -}}

{{- define "util.helpers.valuesToIni" -}}
  {{- range $section, $values := . -}}
[{{ $section }}]
    {{- range $key, $value := $values}}
{{ $key }} = {{ $value }}
    {{- end }}

{{ end }}
{{- end }}

{{- define "loggerIni" -}}
{{ range $top_level_key, $value := . }}
[{{ $top_level_key }}]
keys={{ include "joinKey" $value | trimAll "," }}
{{range $item, $values := $value}}

[{{ $top_level_key | trimSuffix "s" }}_{{ $item | replace "." "_" }}]
{{- if and (eq $top_level_key "loggers") (ne $item "root")}}
qualname={{ $item }}
propagate=0
{{- end}}
{{- range $key, $value := $values }}
{{ $key }}={{ $value }}
{{- end }}
{{- end }}
{{ end }}
{{- end }}

{{- define "osprofiler_url" }}
    {{- $options := merge .Values.osprofiler .Values.global.osprofiler -}}
    {{- if and (hasKey $options "jaeger") ($options.jaeger.enabled) -}}
jaeger://localhost:6831
    {{- else if $options.redis -}}
redis://:{{ $options.redis.redisPassword }}@flamegraph-redis.monsoon3.svc.kubernetes.{{ .Values.global.region }}.{{ .Values.global.tld }}:6379/0
    {{- end -}}
{{- end }}

{{- define "osprofiler" }}
    {{- $options := merge .Values.osprofiler .Values.global.osprofiler }}
    {{- if $options.enabled }}
{'fraction_non_alphanumeric': 0.2753295668549906, 'fraction_numerical': 0.008286252354048965, 'mean_word_length': 3.3900826446280994, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1352452', 'n_tokens_mistral': 1019, 'n_tokens_neox': 1010, 'n_words': 196}