From 845c0f748a319563db2d0f6597e212920e126151 Mon Sep 17 00:00:00 2001 From: foukou19 Date: Thu, 1 Oct 2026 15:17:45 +0200 Subject: [PATCH 1/3] feat(config): add OpenTelemetry OTLP config for Datadog Signed-off-by: foukou19 --- Dockerfile | 1 + pom.xml | 30 +++++++++ .../api/controller/OtelDebugController.java | 44 +++++++++++++ src/main/resources/application.yml | 65 +++++++++---------- 4 files changed, 105 insertions(+), 35 deletions(-) create mode 100644 src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/OtelDebugController.java diff --git a/Dockerfile b/Dockerfile index 7dd4bd05..8f0cf15f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM eclipse-temurin:25-jre-alpine ENV PORT=8080 +ENV JAVA_TOOL_OPTIONS="-Dotel.java.global-autoconfigure.enabled=true" RUN apk add --no-cache shadow && \ groupadd -r idp-core-group && \ diff --git a/pom.xml b/pom.xml index 456b4c59..a952b04f 100644 --- a/pom.xml +++ b/pom.xml @@ -85,6 +85,13 @@ pom import + + io.opentelemetry + opentelemetry-bom + 1.54.0 + pom + import + @@ -337,6 +344,28 @@ camel-rest-starter + + io.opentelemetry + opentelemetry-api + + + io.opentelemetry + opentelemetry-sdk + + + io.opentelemetry + opentelemetry-sdk-extension-autoconfigure + + + io.opentelemetry + opentelemetry-exporter-otlp + + + + org.apache.camel.springboot + camel-opentelemetry-starter + + @@ -545,6 +574,7 @@ org.hibernate.orm:hibernate-core:6.6.29.Final ch.qos.logback:logback-classic:1.5.34 ch.qos.logback:logback-core:1.5.34 + org.codehaus.mojo:animal-sniffer-annotations:1.26 diff --git a/src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/OtelDebugController.java b/src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/OtelDebugController.java new file mode 100644 index 00000000..33e0b4b8 --- /dev/null +++ b/src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/OtelDebugController.java @@ -0,0 +1,44 @@ +package com.decathlon.idp_core.infrastructure.adapters.api.controller; + +import java.util.Map; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.api.trace.StatusCode; +import io.opentelemetry.api.trace.Tracer; +import io.opentelemetry.context.Scope; + +/** + * Debug endpoint used to validate that OpenTelemetry spans are created and + * exported. + * + *

+ * This endpoint intentionally creates a custom span with attributes and logs an + * event so that Cloud Run logs can confirm whether the SDK is active and + * whether the exporter is called. + */ +@RestController +@RequestMapping("/debug") +public class OtelDebugController { + + private static final Tracer TRACER = GlobalOpenTelemetry.get().getTracer("idp-core-debug"); + + @GetMapping("/otel-test") + public ResponseEntity> triggerOtelTrace() { + Span span = TRACER.spanBuilder("debug.otel-test").setAttribute("debug.enabled", true) + .setAttribute("debug.route", "/debug/otel-test").startSpan(); + + try (Scope ignored = span.makeCurrent()) { + span.addEvent("debug-otel-triggered"); + span.setStatus(StatusCode.OK); + return ResponseEntity.ok(Map.of("status", "ok", "trace", "debug.otel-test")); + } finally { + span.end(); + } + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index bd217e2e..832b945f 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -170,27 +170,42 @@ idp: logging: level: - # Application log level, defaults to INFO. Override per environment via LOG_LEVEL env var. + io.opentelemetry: DEBUG + org.apache.camel.opentelemetry: DEBUG com.decathlon: ${LOG_LEVEL:INFO} - # Suppresses noisy Spring context startup logs at WARN level. org.springframework.context.support: WARN - # Suppresses a specific repetitive bean registration delegate log line. org.springframework.context.support.PostProcessorRegistrationDelegate: ERROR +otel: + service: + name: ${OTEL_SERVICE_NAME:internal-developer-platform} + traces: + exporter: otlp + metrics: + exporter: otlp + logs: + exporter: none + exporter: + otlp: + endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT} + protocol: ${OTEL_EXPORTER_OTLP_PROTOCOL:http/protobuf} + headers: + Authorization: ${OTEL_EXPORTER_OTLP_AUTHORIZATION:} + resource: + attributes: + deployment.environment: ${OTEL_ENV} + service.namespace: ${OTEL_SERVICE_NAMESPACE} + X-Datadog-Org: ${ORG} + X-Backend: ${BACKEND} + +camel: + opentelemetry: + enabled: true + management: tracing: - # Tracing is disabled by default and only enabled via environment variables (OTEL_TRACING_ENABLED). - enabled: false - sampling: - probability: 1.0 # 100% des traces - - otlp: - tracing: - endpoint: ${OPEN_TELEMETRY_URL:""} - headers: - swagger: - enabled: ${APP_SECURITY_SWAGGER_ENABLED:true} - authorization: ${OPEN_TELEMETRY_TOKEN:""} + # Tracing is disabled by default and only enabled via environment variables. + enabled: ${OTEL_TRACING_ENABLED:false} endpoints: web: @@ -220,23 +235,3 @@ management: # Shows full health details only to authenticated users. # Avoids leaking internal infrastructure info to unauthenticated callers. show-details: when_authorized - -camel: - component: - platform-http: - engine: "servlet" - # Never expose the health "details" map (e.g. database product name/version, - # validation query, disk space paths). Only UP/DOWN status is shown. - show-details: never - # Still surface per-component status (e.g. db: UP/DOWN) so direct - # dependencies can be checked, without leaking their details. - show-components: always - health: - diskspace: - # DiskSpace is not a direct dependency and its free/threshold values - # are not relevant to consumers checking service health. - enabled: false - ssl: - # SSL certificate/chain info is internal infrastructure detail and - # must not be exposed via actuator. - enabled: false From 4dee8055cda60cf5fec04f9b95da27a55bdb1f51 Mon Sep 17 00:00:00 2001 From: foukou19 Date: Mon, 5 Oct 2026 08:46:08 +0200 Subject: [PATCH 2/3] feat(config): update OpenTelemetry OTLP config Signed-off-by: foukou19 --- src/main/resources/application.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 832b945f..43f34ba4 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -187,10 +187,19 @@ otel: exporter: none exporter: otlp: - endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT} protocol: ${OTEL_EXPORTER_OTLP_PROTOCOL:http/protobuf} headers: - Authorization: ${OTEL_EXPORTER_OTLP_AUTHORIZATION:} + Authorization: ${OTEL_EXPORTER_OTLP_AUTHORIZATION} + traces: + endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT} + protocol: ${OTEL_EXPORTER_OTLP_PROTOCOL:http/protobuf} + headers: + Authorization: ${OTEL_EXPORTER_OTLP_AUTHORIZATION} + metrics: + endpoint: ${OTEL_EXPORTER_OTLP_METRIC_ENDPOINT} + protocol: ${OTEL_EXPORTER_OTLP_PROTOCOL:http/protobuf} + headers: + Authorization: ${OTEL_EXPORTER_OTLP_AUTHORIZATION} resource: attributes: deployment.environment: ${OTEL_ENV} From fc2cd8c73a9b9a9f73ae02ba03dfe6df4bbc77bb Mon Sep 17 00:00:00 2001 From: foukou19 Date: Mon, 5 Oct 2026 10:03:33 +0200 Subject: [PATCH 3/3] feat(config): update OpenTelemetry OTLP Signed-off-by: foukou19 --- src/main/resources/application.yml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 43f34ba4..0e0c44cc 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -187,19 +187,8 @@ otel: exporter: none exporter: otlp: + endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT} protocol: ${OTEL_EXPORTER_OTLP_PROTOCOL:http/protobuf} - headers: - Authorization: ${OTEL_EXPORTER_OTLP_AUTHORIZATION} - traces: - endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT} - protocol: ${OTEL_EXPORTER_OTLP_PROTOCOL:http/protobuf} - headers: - Authorization: ${OTEL_EXPORTER_OTLP_AUTHORIZATION} - metrics: - endpoint: ${OTEL_EXPORTER_OTLP_METRIC_ENDPOINT} - protocol: ${OTEL_EXPORTER_OTLP_PROTOCOL:http/protobuf} - headers: - Authorization: ${OTEL_EXPORTER_OTLP_AUTHORIZATION} resource: attributes: deployment.environment: ${OTEL_ENV}