diff --git a/config/custom-environment-variables.json b/config/custom-environment-variables.json index 4a908c8..dea24d8 100644 --- a/config/custom-environment-variables.json +++ b/config/custom-environment-variables.json @@ -22,11 +22,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 9e92ac7..86e8e21 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -106,4 +106,38 @@ Create chart name and version as used by the chart label. */}} {{- define "overseer.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} \ No newline at end of file +{{- end }} + +{{/* +Returns the tracing url from global if set, otherwise from the chart's values +*/}} +{{- define "overseer.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 "overseer.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 "overseer.otelResourceAttributes" .resourceAttributes }} +*/}} +{{- define "overseer.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 3ea9860..c873680 100644 --- a/helm/templates/_tplValues.tpl +++ b/helm/templates/_tplValues.tpl @@ -46,14 +46,6 @@ Custom definitions */}} -{{- 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.serviceUrls.merged" -}} {{- include "common.tplvalues.merge" ( dict "values" ( list .Values.serviceUrls .Values.global.serviceUrls ) "context" . ) }} {{- end -}} diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml index bac2296..d855e43 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -1,6 +1,8 @@ {{- $configmapName := include "configmap.fullname" . }} -{{- $tracing := (include "common.tracing.merged" .) | fromYaml }} -{{- $openTelemetryOptions := (include "common.openTelemetryOptions.merged" .) | fromYaml }} +{{- $server := .Values.server -}} +{{- $telemetry := .Values.telemetry -}} +{{- $tracingUrl := include "overseer.tracingUrl" . -}} +{{- $opentelemetryLoggingUrl := include "overseer.opentelemetryLoggingUrl" . -}} {{- $serviceUrls := (include "common.serviceUrls.merged" .) | fromYaml }} {{- $storage := (include "common.storage.merged" .) | fromYaml }} {{- $jobDefinitions := (include "common.jobDefinitions.merged" .) | fromYaml }} @@ -11,21 +13,27 @@ 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 $openTelemetryOptions }} + {{- 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 }} - OPENTELEMETRY_LOGGING_URL: {{ .url | quote }} - OPENTELEMETRY_RESOURCE_ATTRIBUTES: {{ .resourceAttributes | toJson | quote }} + {{- if .enabled }} + OTLP_LOGGER_ENDPOINT_URL: {{ $opentelemetryLoggingUrl | quote }} + {{- if .resourceAttributes }} + OTEL_RESOURCE_ATTRIBUTES: {{ include "overseer.otelResourceAttributes" .resourceAttributes | quote }} + {{- end }} + {{- end }} + {{- end }} + TELEMETRY_TRACING_ENABLED: {{ .tracing.enabled | quote }} + {{- if .tracing.enabled }} + TELEMETRY_TRACING_URL: {{ $tracingUrl | quote }} {{- end }} {{- end }} - TELEMETRY_TRACING_ENABLED: {{ $tracing.enabled | quote }} - {{ if $tracing.enabled }} - TELEMETRY_TRACING_URL: {{ $tracing.url }} - {{ end }} TELEMETRY_METRICS_BUCKETS: {{ .Values.mclabels.prometheus.buckets | toJson | quote }} {{- if eq (upper $storage.gpkgProvider) "S3" }} {{- $s3HttpProtocol := ternary "https://" "http://" $storage.s3.sslEnabled }} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index c00b400..67fd0bb 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -5,6 +5,7 @@ {{- $cloudProviderImagePullSecretName := include "overseer.cloudProviderImagePullSecretName" . -}} {{- $cloudProviderDockerRegistryUrl := include "overseer.cloudProviderDockerRegistryUrl" . -}} {{- $imageTag := include "overseer.tag" . -}} +{{- $server := .Values.server -}} {{- $storage := (include "common.storage.merged" .) | fromYaml }} {{- /* PVC handling - check if both PVCs point to the same claim */ -}} @@ -89,7 +90,7 @@ spec: fieldRef: fieldPath: metadata.uid - name: SERVER_PORT - value: {{ .Values.env.targetPort | quote }} + value: {{ $server.targetPort | quote }} {{- if .Values.global.ca.secretName }} - name: REQUESTS_CA_BUNDLE value: {{ printf "%s/%s" .Values.global.ca.path .Values.global.ca.key | quote }} @@ -116,8 +117,8 @@ spec: name: {{ $configmapName }} ports: - name: http - containerPort: {{ .Values.env.targetPort }} - protocol: {{ .Values.env.protocol }} + containerPort: {{ $server.targetPort }} + protocol: {{ $server.protocol }} {{- if .Values.livenessProbe.enabled }} livenessProbe: initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} @@ -125,7 +126,7 @@ spec: failureThreshold: {{ .Values.livenessProbe.failureThreshold }} httpGet: path: {{ .Values.livenessProbe.path }} - port: {{ .Values.env.targetPort }} + port: {{ $server.targetPort }} {{- end }} {{- if .Values.readinessProbe.enabled }} readinessProbe: @@ -134,7 +135,7 @@ spec: failureThreshold: {{ .Values.readinessProbe.failureThreshold }} httpGet: path: {{ .Values.readinessProbe.path }} - port: {{ .Values.env.targetPort }} + port: {{ $server.targetPort }} {{- end }} {{- if .Values.resources.enabled }} resources: diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml index 7c61b88..c0afd2b 100644 --- a/helm/templates/service.yaml +++ b/helm/templates/service.yaml @@ -2,6 +2,7 @@ {{- $chartName := include "overseer.name" . -}} {{- $cloudProviderFlavor := include "overseer.cloudProviderFlavor" . -}} {{- $serviceName := include "service.fullname" . -}} +{{- $server := .Values.server -}} {{- if .Values.enabled -}} apiVersion: v1 @@ -19,9 +20,9 @@ spec: type: NodePort {{- end }} ports: - - port: {{ .Values.env.port }} - targetPort: {{ .Values.env.targetPort }} - protocol: {{ .Values.env.protocol }} + - port: {{ $server.port }} + targetPort: {{ $server.targetPort }} + protocol: {{ $server.protocol }} name: http {{- if eq $cloudProviderFlavor "minikube" }} nodePort: {{ .Values.nodePort }} diff --git a/helm/values.yaml b/helm/values.yaml index cf3fb66..d0c2752 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -1,7 +1,9 @@ global: cloudProvider: {} - tracing: {} - openTelemetryOptions: {} + telemetry: + tracing: {} + logger: + opentelemetryOptions: {} environment: '' serviceUrls: {} jobDefinitions: {} @@ -106,7 +108,7 @@ cloudProvider: image: repository: overseer tag: 'latest' - pullPolicy: Always + pullPolicy: IfNotPresent serviceUrls: jobManager: "" @@ -120,12 +122,8 @@ serviceUrls: polygonPartsManager: "" downloadServerPublicDNS: "" -tracing: - enabled: false - url: "" - configManagement: - offlineMode: false + offlineMode: true name: 'overseer' version: 'latest' serverUrl: 'http://localhost:8080/api' @@ -186,19 +184,29 @@ jobDefinitions: intervalMs: 3000 maxTaskAttempts: 3 -env: +server: port: 8080 targetPort: 8080 protocol: TCP - logLevel: info - logPrettyPrintEnabled: false - openTelemetryOptions: - enabled: false - url: '' - resourceAttributes: {} responseCompressionEnabled: true requestPayloadLimit: 1mb +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:4318/v1/traces + +env: httpRetry: attempts: 5 delay: exponential diff --git a/src/containerConfig.ts b/src/containerConfig.ts index 5e18b8e..d62c331 100644 --- a/src/containerConfig.ts +++ b/src/containerConfig.ts @@ -121,7 +121,7 @@ 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 metricsRegistry = new Registry(); configInstance.initializeMetrics(metricsRegistry);