diff --git a/config/custom-environment-variables.json b/config/custom-environment-variables.json index 1d67543..02d9527 100644 --- a/config/custom-environment-variables.json +++ b/config/custom-environment-variables.json @@ -14,11 +14,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" } }, "tracing": { diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 26bcabd..12416f6 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -108,23 +108,35 @@ Returns the cloud provider image pull secret name from global if exists or from {{- end -}} {{/* -Returns the tracing url from global if exists or from the chart's values +Returns the tracing url from global if set, otherwise from the chart's values */}} {{- define "cache-seeder.tracingUrl" -}} -{{- if .Values.global.tracing.url }} - {{- .Values.global.tracing.url -}} -{{- else if .Values.cloudProvider -}} - {{- .Values.env.tracing.url -}} +{{- 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 tracing url from global if exists or from the chart's values +Returns the opentelemetry logging url from global if set, otherwise from the chart's values */}} -{{- define "cache-seeder.metricsUrl" -}} -{{- if .Values.global.metrics.url }} - {{- .Values.global.metrics.url -}} -{{- else -}} - {{- .Values.env.metrics.url -}} +{{- define "cache-seeder.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 "cache-seeder.otelResourceAttributes" .resourceAttributes }} +*/}} +{{- define "cache-seeder.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 69154aa..2b616d7 100644 --- a/helm/templates/_tplValues.tpl +++ b/helm/templates/_tplValues.tpl @@ -61,18 +61,6 @@ Custom definitions {{- include "common.tplvalues.merge" ( dict "values" ( list .Values.redis .Values.global.redis ) "context" . ) }} {{- end -}} -{{- define "common.tracing.merged" -}} -{{- include "common.tplvalues.merge" ( dict "values" ( list .Values.tracing .Values.global.tracing ) "context" . ) }} -{{- end -}} - -{{- define "common.metrics.merged" -}} -{{- include "common.tplvalues.merge" ( dict "values" ( list .Values.metrics .Values.global.metrics ) "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 530660b..50e60e8 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -1,5 +1,7 @@ -{{- $tracing := (include "common.tracing.merged" .) | fromYaml }} -{{- $openTelemetryOptions := (include "common.openTelemetryOptions.merged" .) | fromYaml }} +{{- $server := .Values.server -}} +{{- $telemetry := .Values.telemetry -}} +{{- $tracingUrl := include "cache-seeder.tracingUrl" . -}} +{{- $opentelemetryLoggingUrl := include "cache-seeder.opentelemetryLoggingUrl" . -}} {{- $configmapName := include "configmap.fullname" . }} {{- $redis := (include "common.redis.merged" .) | fromYaml }} {{- $serviceUrls := (include "common.serviceUrls.merged" .) | fromYaml }} @@ -11,22 +13,26 @@ 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 }} - TELEMETRY_TRACING_ENABLED: {{ $tracing.enabled | quote }} - {{ if $tracing.enabled }} - TELEMETRY_TRACING_URL: {{ $tracing.url }} - {{ end }} - {{- 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 }} - {{ if .resourceAttributes }} - OPENTELEMETRY_RESOURCE_ATTRIBUTES: {{ .resourceAttributes | toJson | quote }} - {{ end }} - {{ end }} + {{- if .enabled }} + OTLP_LOGGER_ENDPOINT_URL: {{ $opentelemetryLoggingUrl | quote }} + {{- if .resourceAttributes }} + OTEL_RESOURCE_ATTRIBUTES: {{ include "cache-seeder.otelResourceAttributes" .resourceAttributes | quote }} + {{- end }} + {{- end }} + {{- end }} + TELEMETRY_TRACING_ENABLED: {{ .tracing.enabled | quote }} + {{- if .tracing.enabled }} + TELEMETRY_TRACING_URL: {{ $tracingUrl | quote }} + {{- end }} {{- end }} npm_config_cache: /tmp/ QUEUE_JOB_MANAGER_BASE_URL: {{ $serviceUrls.jobManager | quote}} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index d941a7c..bf4a905 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -82,7 +82,7 @@ spec: fieldRef: fieldPath: metadata.uid - name: SERVER_PORT - value: {{ .Values.env.targetPort | quote }} + value: {{ .Values.server.targetPort | quote }} {{- if .Values.global.ca.caSecretName }} - name: REQUESTS_CA_BUNDLE value: {{ printf "%s/%s" .Values.global.ca.caPath .Values.global.ca.caKey | quote }} @@ -109,8 +109,8 @@ spec: name: {{ $releaseName }}-{{ $chartName }}-configmap ports: - name: http - containerPort: {{ .Values.env.targetPort }} - protocol: {{ .Values.env.protocol }} + containerPort: {{ .Values.server.targetPort }} + protocol: {{ .Values.server.protocol }} {{- if .Values.livenessProbe.enabled }} livenessProbe: initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} @@ -118,7 +118,7 @@ spec: failureThreshold: {{ .Values.livenessProbe.failureThreshold }} httpGet: path: {{ .Values.livenessProbe.path }} - port: {{ .Values.env.targetPort }} + port: {{ .Values.server.targetPort }} {{- end }} {{- if .Values.readinessProbe.enabled }} readinessProbe: @@ -127,7 +127,7 @@ spec: failureThreshold: {{ .Values.readinessProbe.failureThreshold }} httpGet: path: {{ .Values.readinessProbe.path }} - port: {{ .Values.env.targetPort }} + port: {{ .Values.server.targetPort }} {{- end }} {{- if .Values.resources.enabled }} resources: diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml index 398cda1..64f8e9e 100644 --- a/helm/templates/service.yaml +++ b/helm/templates/service.yaml @@ -17,9 +17,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 b71ee0b..18b196a 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -1,8 +1,9 @@ global: cloudProvider: {} - tracing: {} - metrics: {} - openTelemetryOptions: {} + telemetry: + tracing: {} + logger: + opentelemetryOptions: {} environment: '' jobDefinitions: {} storage: @@ -106,14 +107,6 @@ serviceUrls: heartbeatManager: "" jobTracker: "" -tracing: - enabled: false - url: '' - -metrics: - enabled: false - url: '' - configManagement: offlineMode: true name: 'cache-seeder' @@ -123,7 +116,7 @@ configManagement: image: repository: cache-seeder tag: 'latest' - pullPolicy: Always + pullPolicy: IfNotPresent jobDefinitions: jobs: @@ -133,19 +126,29 @@ jobDefinitions: seed: type: '' -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 + # resourceAttributes: + # service.namespace: namespace + # deployment.environment: dev + tracing: + enabled: true + # url can be overridden from global.telemetry.tracing.url + url: http://localhost:55681/v1/traces + +env: httpRetry: attempts: 5 delay: exponential @@ -161,7 +164,7 @@ env: seedYamlDir: /mapproxy/seed.yaml geometryTxtFile: /mapproxy/coverage.json seedAttempts: 5 - seedConcurrency: 5 + seedConcurrency: 25 mapproxyCmdCommand: "mapproxy-seed" refreshBeforeYearsOffset: 1 invalidBboxInitialBufferMeters: 200 diff --git a/src/containerConfig.ts b/src/containerConfig.ts index 8149fbe..7c10b2e 100644 --- a/src/containerConfig.ts +++ b/src/containerConfig.ts @@ -20,7 +20,7 @@ export const registerExternalValues = async (options?: RegisterOptions): Promise const config = configInstance as unknown as IConfig; const loggerConfig = configInstance.get('telemetry.logger'); - const logger = await jsLogger({ ...loggerConfig, prettyPrint: loggerConfig.prettyPrint, mixin: getOtelMixin() }); + const logger = await jsLogger({ ...loggerConfig, mixin: getOtelMixin() }); const queueConfig = config.get('queue'); const tracer = trace.getTracer(SERVICE_NAME);