diff --git a/config/custom-environment-variables.json b/config/custom-environment-variables.json index 063d8a5..a79cc89 100644 --- a/config/custom-environment-variables.json +++ b/config/custom-environment-variables.json @@ -17,11 +17,8 @@ "__name": "OPENTELEMETRY_LOGGING_ENABLED", "__format": "boolean" }, - "url": "OPENTELEMETRY_LOGGING_URL", - "resourceAttributes": { - "__name": "OPENTELEMETRY_RESOURCE_ATTRIBUTES", - "__format": "json" - } + "url": "OTLP_LOGGER_ENDPOINT_URL", + "resourceAttributes": "OTEL_RESOURCE_ATTRIBUTES" } }, "shared": {}, diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 5c29d72..586d9c4 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -101,3 +101,37 @@ Returns the cloud provider image pull secret name from global if exists or from {{- .Values.cloudProvider.imagePullSecretName -}} {{- end -}} {{- end -}} + +{{/* +Returns the tracing url from global if set, otherwise from the chart's values +*/}} +{{- define "geoserver-api.tracingUrl" -}} +{{- if .Values.global.telemetry.tracing.url }} + {{- .Values.global.telemetry.tracing.url -}} +{{- else if .Values.telemetry.tracing.url -}} + {{- .Values.telemetry.tracing.url -}} +{{- end -}} +{{- end -}} + +{{/* +Returns the opentelemetry logging url from global if set, otherwise from the chart's values +*/}} +{{- define "geoserver-api.opentelemetryLoggingUrl" -}} +{{- if .Values.global.telemetry.logger.opentelemetryOptions.url }} + {{- .Values.global.telemetry.logger.opentelemetryOptions.url -}} +{{- else if .Values.telemetry.logger.opentelemetryOptions.url -}} + {{- .Values.telemetry.logger.opentelemetryOptions.url -}} +{{- end -}} +{{- end -}} + +{{/* +Renders a map of resource attributes as key=value,key=value for OTEL_RESOURCE_ATTRIBUTES. +Usage: {{ include "geoserver-api.otelResourceAttributes" .resourceAttributes }} +*/}} +{{- define "geoserver-api.otelResourceAttributes" -}} +{{- $attributes := list }} +{{- range $key, $value := . }} +{{- $attributes = append $attributes (printf "%s=%s" $key (toString $value)) }} +{{- end }} +{{- join "," $attributes }} +{{- end -}} diff --git a/helm/templates/_tplValues.tpl b/helm/templates/_tplValues.tpl index 7f1924d..597c568 100644 --- a/helm/templates/_tplValues.tpl +++ b/helm/templates/_tplValues.tpl @@ -54,14 +54,6 @@ Custom definitions {{- include "common.tplvalues.merge" ( dict "values" ( list .Values.db .Values.global.db ) "context" . ) }} {{- end -}} -{{- define "common.tracing.merged" -}} -{{- include "common.tplvalues.merge" ( dict "values" ( list .Values.tracing .Values.global.tracing ) "context" . ) }} -{{- end -}} - -{{- define "common.openTelemetryOptions.merged" -}} -{{- include "common.tplvalues.merge" ( dict "values" ( list .Values.env.openTelemetryOptions .Values.global.openTelemetryOptions ) "context" . ) }} -{{- end -}} - {{- define "common.geoserver.merged" -}} {{- include "common.tplvalues.merge" ( dict "values" ( list .Values.geoserver .Values.global.geoserver ) "context" . ) }} {{- end -}} diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml index e997587..07d0707 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -1,34 +1,42 @@ {{- $chartName := include "geoserver-api.name" . -}} -{{- $tracing := (include "common.tracing.merged" .) | fromYaml }} {{- $configmapName := include "configmap.fullname" . }} +{{- $server := .Values.server -}} +{{- $telemetry := .Values.telemetry -}} +{{- $tracingUrl := include "geoserver-api.tracingUrl" . -}} +{{- $opentelemetryLoggingUrl := include "geoserver-api.opentelemetryLoggingUrl" . -}} {{- $serviceUrls := (include "common.serviceUrls.merged" .) | fromYaml }} {{- $db := (include "common.db.merged" .) | fromYaml }} -{{- $openTelemetryOptions := (include "common.openTelemetryOptions.merged" .) | fromYaml }} {{- if .Values.enabled -}} apiVersion: v1 kind: ConfigMap metadata: name: {{ $configmapName }} data: - REQUEST_PAYLOAD_LIMIT: {{ .Values.env.requestPayloadLimit | quote }} - RESPONSE_COMPRESSION_ENABLED: {{ .Values.env.responseCompressionEnabled | quote }} - LOG_LEVEL: {{ .Values.env.logLevel | quote }} - LOG_PRETTY_PRINT_ENABLED: {{ .Values.env.logPrettyPrintEnabled | quote }} + {{- with $server }} + REQUEST_PAYLOAD_LIMIT: {{ .requestPayloadLimit | quote }} + RESPONSE_COMPRESSION_ENABLED: {{ .responseCompressionEnabled | quote }} + {{- end }} + {{- with $telemetry }} + LOG_LEVEL: {{ .logger.level | quote }} + LOG_PRETTY_PRINT_ENABLED: {{ .logger.prettyPrint | quote }} + {{- with .logger.opentelemetryOptions }} + OPENTELEMETRY_LOGGING_ENABLED: {{ .enabled | quote }} + {{- if .enabled }} + OTLP_LOGGER_ENDPOINT_URL: {{ $opentelemetryLoggingUrl | quote }} + {{- if .resourceAttributes }} + OTEL_RESOURCE_ATTRIBUTES: {{ include "geoserver-api.otelResourceAttributes" .resourceAttributes | quote }} + {{- end }} + {{- end }} + {{- end }} + TELEMETRY_TRACING_ENABLED: {{ .tracing.enabled | quote }} + {{- if .tracing.enabled }} + TELEMETRY_TRACING_URL: {{ $tracingUrl | quote }} + {{- end }} + {{- end }} HTTP_RETRY_ATTEMPTS: {{ .Values.env.httpRetry.attempts | quote }} HTTP_RETRY_DELAY: {{ .Values.env.httpRetry.delay | quote }} HTTP_RETRY_RESET_TIMEOUT: {{ .Values.env.httpRetry.resetTimeout | quote }} DISABLE_HTTP_CLIENT_LOGS: {{ .Values.env.disableHttpClientLogs | quote }} - {{- with $openTelemetryOptions }} - OPENTELEMETRY_LOGGING_ENABLED: {{ .enabled | quote }} - {{ if .enabled }} - OPENTELEMETRY_LOGGING_URL: {{ .url | quote }} - OPENTELEMETRY_RESOURCE_ATTRIBUTES: {{ .resourceAttributes | toJson | quote }} - {{- end }} - {{- end }} - TELEMETRY_TRACING_ENABLED: {{ $tracing.enabled | quote }} - {{ if $tracing.enabled }} - TELEMETRY_TRACING_URL: {{ $tracing.url }} - {{ end }} GEOSERVER_URL: {{ $serviceUrls.geoserverUrl }} DATASTORE_HOST: {{ $db.host }} DATASTORE_PORT: {{ $db.port | quote }} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index 74a2803..1399fe2 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -63,7 +63,7 @@ spec: {{- end }} env: - name: SERVER_PORT - value: {{ .Values.env.targetPort | quote }} + value: {{ .Values.server.targetPort | quote }} - name: K8S_POD_UID valueFrom: fieldRef: @@ -99,13 +99,13 @@ spec: name: {{ $configmapName }} ports: - name: http - containerPort: {{ .Values.env.targetPort }} - protocol: {{ .Values.env.protocol }} + containerPort: {{ .Values.server.targetPort }} + protocol: {{ .Values.server.protocol }} livenessProbe: initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} httpGet: path: {{ .Values.livenessProbe.path }} - port: {{ .Values.env.targetPort }} + port: {{ .Values.server.targetPort }} {{- if .Values.resources.enabled }} resources: {{- toYaml .Values.resources.value | nindent 12 }} diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml index 911ca6a..e47097b 100644 --- a/helm/templates/ingress.yaml +++ b/helm/templates/ingress.yaml @@ -39,6 +39,6 @@ spec: service: name: {{ $serviceName }} port: - number: {{ .Values.env.port }} + number: {{ .Values.server.port }} host: {{ $ingressHost }} {{- end -}} diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml index 912f348..b5af49c 100644 --- a/helm/templates/service.yaml +++ b/helm/templates/service.yaml @@ -18,9 +18,9 @@ spec: type: NodePort {{- end }} ports: - - port: {{ .Values.env.port }} - targetPort: {{ .Values.env.targetPort }} - protocol: {{ .Values.env.protocol }} + - port: {{ .Values.server.port }} + targetPort: {{ .Values.server.targetPort }} + protocol: {{ .Values.server.protocol }} name: http {{- if eq $cloudProviderFlavor "minikube" }} nodePort: {{ .Values.nodePort }} diff --git a/helm/values.yaml b/helm/values.yaml index 45512bf..cad6cd7 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -1,30 +1,20 @@ global: cloudProvider: {} - tracing: {} - metrics: {} - openTelemetryOptions: {} + telemetry: + tracing: {} + logger: + opentelemetryOptions: {} environment: '' - -mclabels: - #environment: development - component: backend - partOf: ingestion - owner: raster - gisDomain: raster - prometheus: - enabled: true - port: 8080 - serviceUrls: geoserverUrl: "" - geoserver: + geoserver: secrets: useExternal: false - externalSecretName: '' - auth: + externalSecretName: '' + auth: username: "" password: "" - db: + db: username: "" password: "" host: "" @@ -37,13 +27,22 @@ mclabels: secrets: useExternal: false externalSecretName: '' - - ca: + ca: secretName: '' path: '/usr/local/share/ca-certificates' - key: 'ca.crt' + key: 'ca.crt' ingress: - domain: 'apps.aroapp.io' + domain: 'apps.aroapp.io' + +mclabels: + #environment: development + component: backend + partOf: ingestion + owner: raster + gisDomain: raster + prometheus: + enabled: true + port: 8080 enabled: true environment: development @@ -52,7 +51,7 @@ revisionHistoryLimit: 5 # Amount of revisions we keep initialDelaySeconds: 60 nodePort: 30030 #for minikube deployment only resetOnConfigChange: true -imagePullPolicy: Always +imagePullPolicy: IfNotPresent nameOverride: "" fullnameOverride: "" @@ -99,17 +98,6 @@ cloudProvider: imagePullSecretName: 'my-registry-secret' flavor: openshift -tracing: - enabled: false - url: '' - -metrics: - enabled: false - url: '' - prometheus: - scrape: true - port: 8080 - geoserver: secrets: useExternal: true @@ -117,9 +105,9 @@ geoserver: db: host: '' port: '' - schema: '' + schema: 'polygon_parts' name: '' - dbType: '' + dbType: 'postgis' sslEnabled: false secrets: useExternal: true @@ -128,33 +116,43 @@ serviceUrls: geoserverUrl: '' configManagement: - offlineMode: false + offlineMode: true name: 'geoserver-api' version: 'latest' serverUrl: 'http://localhost:8080/api' -env: +server: port: 80 targetPort: 8080 protocol: TCP - logLevel: info - logPrettyPrintEnabled: false - openTelemetryOptions: - enabled: false - url: '' - resourceAttributes: {} responseCompressionEnabled: true requestPayloadLimit: 1mb - disableHttpClientLogs: false + +telemetry: + logger: + level: info + prettyPrint: false + opentelemetryOptions: + enabled: true + url: http://localhost:4317 + # Rendered as OTEL_RESOURCE_ATTRIBUTES in "key=value,key=value" format + # resourceAttributes: + # service.namespace: namespace + # deployment.environment: dev + tracing: + enabled: true + url: http://localhost:55681/v1/traces + +env: + disableHttpClientLogs: false httpRetry: attempts: 5 delay: exponential resetTimeout: true - srs: "EPSG:4326" - numOfDecimals: 100 + srs: "EPSG:4326" + numOfDecimals: 100 wfsMaxFeatures: 1000 - resources: enabled: false value: diff --git a/src/containerConfig.ts b/src/containerConfig.ts index f841a1b..ee06fef 100644 --- a/src/containerConfig.ts +++ b/src/containerConfig.ts @@ -20,7 +20,7 @@ interface RegisterOptions { export const registerExternalValues = async (options?: RegisterOptions): Promise => { const configInstance = getConfig(); const loggerConfig = configInstance.get('telemetry.logger'); - const logger = await jsLogger({ ...loggerConfig, prettyPrint: loggerConfig.prettyPrint, mixin: getOtelMixin() }); + const logger = await jsLogger({ ...loggerConfig, mixin: getOtelMixin() }); const tracer = trace.getTracer(SERVICE_NAME); const metricsRegistry = new Registry();