From 4762f690954203fa521acb72fbc9776fc3e0345b Mon Sep 17 00:00:00 2001 From: Christophe Vila Date: Fri, 29 May 2026 16:17:38 +0200 Subject: [PATCH] Initial release --- .gitignore | 2 + .idea/.gitignore | 10 + .idea/compiler.xml | 13 + .idea/encodings.xml | 7 + .idea/jarRepositories.xml | 20 ++ .idea/misc.xml | 12 + .idea/vcs.xml | 6 + .mvn/wrapper/maven-wrapper.properties | 2 + CLAUDE.md | 39 +++ Dockerfile | 21 ++ k3s/deployment.yaml | 16 + k3s/service.yaml | 6 + mvnw | 332 +++++++++++++++++++ mvnw.cmd | 206 ++++++++++++ pom.xml | 146 ++++++++ src/main/java/com/demo/InventoryService.java | 82 +++++ src/main/java/com/demo/Order.java | 31 ++ src/main/java/com/demo/OrderResource.java | 295 ++++++++++++++++ src/main/resources/application.properties | 44 +++ 19 files changed, 1290 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/vcs.xml create mode 100644 .mvn/wrapper/maven-wrapper.properties create mode 100644 CLAUDE.md create mode 100644 Dockerfile create mode 100644 k3s/deployment.yaml create mode 100644 k3s/service.yaml create mode 100755 mvnw create mode 100644 mvnw.cmd create mode 100644 pom.xml create mode 100644 src/main/java/com/demo/InventoryService.java create mode 100644 src/main/java/com/demo/Order.java create mode 100644 src/main/java/com/demo/OrderResource.java create mode 100644 src/main/resources/application.properties diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b54619a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target/ +/.mvn/wrapper/maven-wrapper.jar diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..30cf57e --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..c1d76d0 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f88c0a7 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..308007b --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..229dc91 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,39 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project + +Quarkus 3.35 / Java 21 demo app (`otel-quarkus-demo`) that exercises a full observability stack: OpenTelemetry traces/metrics/logs via OTLP, Micrometer with both a Prometheus scrape endpoint and an OTLP push exporter, structured JSON logging, and SmallRye health checks. The OTLP endpoints in `application.properties` point at an in-cluster collector (`otel-collector-opentelemetry-collector.observability.svc.cluster.local`) — running locally without that collector means OTLP exporters will fail, but the app still serves requests and exposes `/q/metrics`. + +## Commands + +Use the Maven wrapper (`./mvnw`) — there is no `mvn` requirement. + +- Dev mode (hot reload, dev UI at `/q/dev`): `./mvnw quarkus:dev` +- Build runnable app (fast-jar layout in `target/quarkus-app/`): `./mvnw package` +- Build container image (jib): `./mvnw package -Dquarkus.container-image.build=true` +- Run packaged app: `java -jar target/quarkus-app/quarkus-run.jar` +- Tests: `./mvnw test` (no tests exist yet; surefire/failsafe are configured via the Quarkus BOM) +- Single test once added: `./mvnw test -Dtest=ClassName#methodName` + +The app listens on `:8080`. Key endpoints: `POST /api/orders`, `GET /api/orders`, `GET /api/orders/{id}`, `GET /api/inventory`, `GET /q/health`, `GET /q/metrics`. + +## Architecture + +Three classes under `src/main/java/com/demo/`, all part of a single REST surface: + +- `OrderResource` — JAX-RS resource at `/api`. Every request path manually builds a parent span (`processOrder`) and child spans (`validateOrder`, `checkInventory`, `processPayment`) using the injected OTel `Tracer`, sets span attributes, and records status/exceptions explicitly. It also lazily registers Micrometer meters (`orders` counter tagged by status, `orders_amount` counter, `order_processing_duration` timer with percentiles, `order_item_count` summary) on each call — the registry deduplicates, but be aware that meter definitions live alongside the request handler rather than in a separate config class. Two behaviors are intentional for demo signal: `Thread.sleep` calls simulate latency, and ~10% of orders throw a synthetic `RuntimeException` to generate error traces. +- `InventoryService` — `@ApplicationScoped` CDI bean. Seeds six products on `@PostConstruct` and registers one `inventory_level` Micrometer gauge per product (tagged `product=...`) bound to an `AtomicInteger`. Decrementing below 10 auto-restocks by 100 — keep this in mind when interpreting metric dips. +- `Order` — DTO with auto-generated id and computed `totalPrice`. The in-memory order store lives on `OrderResource` as a `CopyOnWriteArrayList` (non-persistent; cleared on restart). + +Observability wiring is entirely in `application.properties`: +- OTLP traces/metrics/logs are exported to the collector via gRPC on `:4317`, plus a parallel HTTP push of Micrometer metrics to `:4318/v1/metrics`. Both are configured — changing one without the other leaves a divergent metrics pipeline. +- The trace sampler is `always_on` (demo only — switch to ratio-based in any real deployment). +- Console log format embeds `traceId`/`spanId` from MDC; `quarkus.log.console.json.enabled=false` despite the `quarkus-logging-json` dependency being present (toggle it on for Loki-friendly output). + +## Conventions worth knowing + +- Span lifecycle in `OrderResource` is manual (`spanBuilder().startSpan()` + `try/finally span.end()`). When adding new endpoints, follow the same pattern rather than relying on `@WithSpan` so attributes/status handling stays consistent. +- Meter names use snake_case (`orders_amount`, `order_processing_duration`, `inventory_level`); tags use snake_case too (`order.product`, `inventory.in_stock`). Match this when adding metrics so dashboards/PromQL stay uniform. +- The Dockerfile is a two-stage Maven → JRE-alpine build that copies the `target/quarkus-app/` fast-jar layout — `./mvnw package` must succeed before `docker build` will work. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ed1ac09 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# ── Stage 1: Build ─────────────────────────────────────────── +FROM maven:3.9-eclipse-temurin-21-alpine AS build +WORKDIR /app +COPY pom.xml . +RUN mvn dependency:go-offline -B +COPY src ./src +RUN mvn package -DskipTests -B + +# ── Stage 2: Runtime ───────────────────────────────────────── +FROM eclipse-temurin:21-jre-alpine +WORKDIR /app + +RUN addgroup -S quarkus && adduser -S quarkus -G quarkus +COPY --from=build /app/target/quarkus-app/ ./ + +USER quarkus +EXPOSE 8080 + +ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0" + +ENTRYPOINT ["java", "-jar", "quarkus-run.jar"] diff --git a/k3s/deployment.yaml b/k3s/deployment.yaml new file mode 100644 index 0000000..9a99234 --- /dev/null +++ b/k3s/deployment.yaml @@ -0,0 +1,16 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: { name: otel-quarkus-demo } +spec: + replicas: 1 + selector: { matchLabels: { app: otel-quarkus-demo } } + template: + metadata: { labels: { app: otel-quarkus-demo } } + spec: + containers: + - name: app + image: rm.vdi-linux-cvl.local/global/quarkus-app:latest + imagePullPolicy: IfNotPresent + ports: [{ containerPort: 8080 }] + readinessProbe: { httpGet: { path: /q/health/ready, port: 8080 } } + livenessProbe: { httpGet: { path: /q/health/live, port: 8080 } } diff --git a/k3s/service.yaml b/k3s/service.yaml new file mode 100644 index 0000000..461f9a8 --- /dev/null +++ b/k3s/service.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Service +metadata: { name: otel-quarkus-demo } +spec: + selector: { app: otel-quarkus-demo } + ports: [{ port: 8080, targetPort: 8080 }] diff --git a/mvnw b/mvnw new file mode 100755 index 0000000..5272759 --- /dev/null +++ b/mvnw @@ -0,0 +1,332 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version @@project.version@@ +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ]; then + + if [ -f /usr/local/etc/mavenrc ]; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ]; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ]; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false +darwin=false +mingw=false +case "$(uname)" in +CYGWIN*) cygwin=true ;; +MINGW*) mingw=true ;; +Darwin*) + darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + JAVA_HOME="$(/usr/libexec/java_home)" + export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home" + export JAVA_HOME + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ]; then + if [ -r /etc/gentoo-release ]; then + JAVA_HOME=$(java-config --jre-home) + fi +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin; then + [ -n "$JAVA_HOME" ] \ + && JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + [ -n "$CLASSPATH" ] \ + && CLASSPATH=$(cygpath --path --unix "$CLASSPATH") +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw; then + [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] \ + && JAVA_HOME="$( + cd "$JAVA_HOME" || ( + echo "cannot cd into $JAVA_HOME." >&2 + exit 1 + ) + pwd + )" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr "$javaExecutable" : '\([^ ]*\)')" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=$(which readlink) + if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then + if $darwin; then + javaHome="$(dirname "$javaExecutable")" + javaExecutable="$(cd "$javaHome" && pwd -P)/javac" + else + javaExecutable="$(readlink -f "$javaExecutable")" + fi + javaHome="$(dirname "$javaExecutable")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ]; then + if [ -n "$JAVA_HOME" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="$( + \unset -f command 2>/dev/null + \command -v java + )" + fi +fi + +if [ ! -x "$JAVACMD" ]; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ]; then + echo "Warning: JAVA_HOME environment variable is not set." >&2 +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + if [ -z "$1" ]; then + echo "Path not specified to find_maven_basedir" >&2 + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ]; do + if [ -d "$wdir"/.mvn ]; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=$( + cd "$wdir/.." || exit 1 + pwd + ) + fi + # end of workaround + done + printf '%s' "$( + cd "$basedir" || exit 1 + pwd + )" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + # Remove \r in case we run on Windows within Git Bash + # and check out the repository with auto CRLF management + # enabled. Otherwise, we may read lines that are delimited with + # \r\n and produce $'-Xarg\r' rather than -Xarg due to word + # splitting rules. + tr -s '\r\n' ' ' <"$1" + fi +} + +log() { + if [ "$MVNW_VERBOSE" = true ]; then + printf '%s\n' "$1" + fi +} + +BASE_DIR=$(find_maven_basedir "$(dirname "$0")") +if [ -z "$BASE_DIR" ]; then + exit 1 +fi + +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +export MAVEN_PROJECTBASEDIR +log "$MAVEN_PROJECTBASEDIR" + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" +if [ -r "$wrapperJarPath" ]; then + log "Found $wrapperJarPath" +else + log "Couldn't find $wrapperJarPath, downloading it ..." + + if [ -n "$MVNW_REPOURL" ]; then + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/@@project.version@@/maven-wrapper-@@project.version@@.jar" + else + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/@@project.version@@/maven-wrapper-@@project.version@@.jar" + fi + while IFS="=" read -r key value; do + # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) + safeValue=$(echo "$value" | tr -d '\r') + case "$key" in wrapperUrl) + wrapperUrl="$safeValue" + break + ;; + esac + done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" + log "Downloading from: $wrapperUrl" + + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget >/dev/null; then + log "Found wget ... using wget" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl >/dev/null; then + log "Found curl ... using curl" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + else + curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + fi + else + log "Falling back to using Java to download" + javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaSource=$(cygpath --path --windows "$javaSource") + javaClass=$(cygpath --path --windows "$javaClass") + fi + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then + log " - Compiling MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/javac" "$javaSource") + fi + if [ -e "$javaClass" ]; then + log " - Running MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +# If specified, validate the SHA-256 sum of the Maven wrapper jar file +wrapperSha256Sum="" +while IFS="=" read -r key value; do + case "$key" in wrapperSha256Sum) + wrapperSha256Sum=$value + break + ;; + esac +done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" +if [ -n "$wrapperSha256Sum" ]; then + wrapperSha256Result=false + if command -v sha256sum >/dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c >/dev/null 2>&1; then + wrapperSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c >/dev/null 2>&1; then + wrapperSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $wrapperSha256Result = false ]; then + echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 + echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 + echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 + exit 1 + fi +fi + +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$JAVA_HOME" ] \ + && JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] \ + && CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] \ + && MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +# shellcheck disable=SC2086 # safe args +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..708460f --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,206 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version @@project.version@@ +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. >&2 +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. >&2 +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. >&2 +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. >&2 +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/@@project.version@@/maven-wrapper-@@project.version@@.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/@@project.version@@/maven-wrapper-@@project.version@@.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %WRAPPER_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file +SET WRAPPER_SHA_256_SUM="" +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B +) +IF NOT %WRAPPER_SHA_256_SUM%=="" ( + powershell -Command "&{"^ + "Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash;"^ + "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ + "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ + " Write-Error 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ + " Write-Error 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ + " Write-Error 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ + " exit 1;"^ + "}"^ + "}" + if ERRORLEVEL 1 goto error +) + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..1ec6b03 --- /dev/null +++ b/pom.xml @@ -0,0 +1,146 @@ + + + 4.0.0 + + com.demo + otel-quarkus-demo + 1.0.0 + + + 3.13.0 + 21 + UTF-8 + 3.35.1 + 3.5.0 + 3.4.0 + 3.3.1 + 3.4.2 + 3.1.3 + 3.1.3 + 3.5.1 + 3.5.1 + 3.21.0 + + + + + + io.quarkus.platform + quarkus-bom + ${quarkus.platform.version} + pom + import + + + + + + + + io.quarkus + quarkus-rest + + + io.quarkus + quarkus-rest-jackson + + + + + io.quarkus + quarkus-opentelemetry + + + + + io.quarkus + quarkus-micrometer-registry-prometheus + + + + + io.quarkiverse.micrometer.registry + quarkus-micrometer-registry-otlp + ${quarkiverse-micrometer-registry.version} + + + + + io.quarkus + quarkus-logging-json + + + + + io.quarkus + quarkus-smallrye-health + + + + + io.quarkus + quarkus-container-image-jib + + + + + + + + maven-clean-plugin + ${clean-plugin.version} + + + maven-resources-plugin + ${resources-plugin.version} + + + maven-compiler-plugin + ${compiler-plugin.version} + + + maven-surefire-plugin + ${surefire-plugin.version} + + + maven-failsafe-plugin + ${failsafe-plugin.version} + + + maven-jar-plugin + ${jar-plugin.version} + + + maven-install-plugin + ${install-plugin.version} + + + maven-deploy-plugin + ${deploy-plugin.version} + + + maven-site-plugin + ${site-plugin.version} + + + + + + io.quarkus.platform + quarkus-maven-plugin + ${quarkus.platform.version} + true + + + + build + generate-code + + + + + + + diff --git a/src/main/java/com/demo/InventoryService.java b/src/main/java/com/demo/InventoryService.java new file mode 100644 index 0000000..9b904b7 --- /dev/null +++ b/src/main/java/com/demo/InventoryService.java @@ -0,0 +1,82 @@ +package com.demo; + +import io.micrometer.core.instrument.Gauge; +import io.micrometer.core.instrument.MeterRegistry; +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import org.jboss.logging.Logger; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Simulated inventory service that exposes stock levels as Micrometer gauge metrics. + * Each product has a gauge "inventory_level" with a tag "product". + */ +@ApplicationScoped +public class InventoryService { + + private static final Logger LOG = Logger.getLogger(InventoryService.class); + + @Inject + MeterRegistry registry; + + private final ConcurrentHashMap stock = new ConcurrentHashMap<>(); + + @PostConstruct + void init() { + // Seed initial inventory + initProduct("laptop", 50); + initProduct("keyboard", 200); + initProduct("mouse", 300); + initProduct("monitor", 75); + initProduct("headset", 120); + initProduct("webcam", 90); + + LOG.info("Inventory service initialized with 6 products"); + } + + private void initProduct(String product, int initialStock) { + AtomicInteger level = new AtomicInteger(initialStock); + stock.put(product, level); + + // Register a gauge that tracks the live value of the AtomicInteger + Gauge.builder("inventory_level", level, AtomicInteger::get) + .description("Current inventory level") + .tag("product", product) + .register(registry); + } + + public int getStock(String product) { + AtomicInteger level = stock.get(product); + if (level == null) { + // Unknown product — treat as out of stock + return 0; + } + return level.get(); + } + + public void decrementStock(String product, int quantity) { + AtomicInteger level = stock.get(product); + if (level != null) { + int newLevel = level.addAndGet(-quantity); + LOG.debugf("Inventory updated: product=%s, decremented=%d, new_level=%d", + product, quantity, newLevel); + + // Restock if level drops below 10 (simulates auto-replenishment) + if (newLevel < 10) { + int restock = 100; + level.addAndGet(restock); + LOG.infof("Auto-restocked product=%s by %d units (was at %d)", product, restock, newLevel); + } + } + } + + public Map getInventoryLevels() { + Map levels = new ConcurrentHashMap<>(); + stock.forEach((product, level) -> levels.put(product, level.get())); + return levels; + } +} diff --git a/src/main/java/com/demo/Order.java b/src/main/java/com/demo/Order.java new file mode 100644 index 0000000..6a18567 --- /dev/null +++ b/src/main/java/com/demo/Order.java @@ -0,0 +1,31 @@ +package com.demo; + +import java.time.Instant; +import java.util.UUID; + +public class Order { + + public String id; + public String customerId; + public String product; + public int quantity; + public double unitPrice; + public double totalPrice; + public String status; + public Instant createdAt; + + public Order() { + this.id = UUID.randomUUID().toString().substring(0, 8); + this.createdAt = Instant.now(); + this.status = "CREATED"; + } + + public Order(String customerId, String product, int quantity, double unitPrice) { + this(); + this.customerId = customerId; + this.product = product; + this.quantity = quantity; + this.unitPrice = unitPrice; + this.totalPrice = quantity * unitPrice; + } +} diff --git a/src/main/java/com/demo/OrderResource.java b/src/main/java/com/demo/OrderResource.java new file mode 100644 index 0000000..72c2646 --- /dev/null +++ b/src/main/java/com/demo/OrderResource.java @@ -0,0 +1,295 @@ +package com.demo; + +import io.micrometer.core.instrument.Counter; +import io.micrometer.core.instrument.DistributionSummary; +import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.Timer; +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.api.trace.StatusCode; +import io.opentelemetry.api.trace.Tracer; +import io.opentelemetry.context.Scope; +import jakarta.inject.Inject; +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import org.jboss.logging.Logger; + +import java.time.Duration; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ThreadLocalRandom; + +@Path("/api") +@Produces(MediaType.APPLICATION_JSON) +public class OrderResource { + + private static final Logger LOG = Logger.getLogger(OrderResource.class); + + @Inject + Tracer tracer; + + @Inject + MeterRegistry registry; + + @Inject + InventoryService inventoryService; + + // In-memory store for demo purposes + private final List orders = new CopyOnWriteArrayList<>(); + + // ────── Custom Metrics (registered lazily) ────── + + private Counter ordersCounter(String status) { + return Counter.builder("orders") + .description("Total number of orders processed") + .tag("status", status) + .register(registry); + } + + private Counter revenueCounter() { + return Counter.builder("orders_amount") + .description("Total order revenue") + .baseUnit("dollars") + .register(registry); + } + + private Timer orderProcessingTimer() { + return Timer.builder("order_processing_duration") + .description("Time spent processing an order") + .publishPercentiles(0.5, 0.9, 0.95, 0.99) + .register(registry); + } + + private DistributionSummary orderSizeSummary() { + return DistributionSummary.builder("order_item_count") + .description("Number of items per order") + .publishPercentiles(0.5, 0.9) + .register(registry); + } + + // ────── Endpoints ────── + + @GET + @Path("/health") + public Response health() { + return Response.ok(Map.of("status", "UP", "service", "otel-quarkus-demo")).build(); + } + + /** + * POST /api/orders — Create and process an order. + * Demonstrates: custom spans, span attributes, custom metrics, error injection, latency simulation. + */ + @POST + @Path("/orders") + @Consumes(MediaType.APPLICATION_JSON) + public Response createOrder(OrderRequest request) { + LOG.infof("Received order request: product=%s, quantity=%d, customerId=%s", + request.product, request.quantity, request.customerId); + + // Start a custom parent span for the full order processing + Span orderSpan = tracer.spanBuilder("processOrder") + .setSpanKind(SpanKind.INTERNAL) + .setAttribute("order.product", request.product) + .setAttribute("order.quantity", (long) request.quantity) + .setAttribute("order.customer_id", request.customerId) + .startSpan(); + + try (Scope scope = orderSpan.makeCurrent()) { + return orderProcessingTimer().record(() -> { + try { + // Step 1: Validate the order + validateOrder(request); + + // Step 2: Check inventory + boolean inStock = checkInventory(request.product, request.quantity); + if (!inStock) { + orderSpan.setStatus(StatusCode.ERROR, "Insufficient inventory"); + ordersCounter("rejected_no_stock").increment(); + LOG.warnf("Order rejected — insufficient inventory for product=%s, requested=%d", + request.product, request.quantity); + return Response.status(Response.Status.CONFLICT) + .entity(Map.of("error", "Insufficient inventory", "product", request.product)) + .build(); + } + + // Step 3: Process payment (simulated) + processPayment(request); + + // Step 4: Create the order + Order order = new Order(request.customerId, request.product, + request.quantity, request.unitPrice); + + // Simulate processing time based on complexity + String processingType = request.quantity > 5 ? "complex" : "simple"; + orderSpan.setAttribute("order.processing_type", processingType); + orderSpan.setAttribute("order.total_price", order.totalPrice); + + simulateProcessingDelay(processingType); + + // Randomly inject errors (~10% of the time) for troubleshooting demo + if (ThreadLocalRandom.current().nextDouble() < 0.10) { + throw new RuntimeException("Downstream fulfillment service timeout"); + } + + order.status = "COMPLETED"; + orders.add(order); + + // Record metrics + ordersCounter("completed").increment(); + revenueCounter().increment(order.totalPrice); + orderSizeSummary().record(request.quantity); + + // Update inventory + inventoryService.decrementStock(request.product, request.quantity); + + LOG.infof("Order %s completed: product=%s, quantity=%d, total=%.2f, type=%s", + order.id, order.product, order.quantity, order.totalPrice, processingType); + + orderSpan.setAttribute("order.id", order.id); + orderSpan.setStatus(StatusCode.OK); + + return Response.status(Response.Status.CREATED).entity(order).build(); + + } catch (IllegalArgumentException e) { + orderSpan.setStatus(StatusCode.ERROR, e.getMessage()); + orderSpan.recordException(e); + ordersCounter("rejected_validation").increment(); + LOG.errorf("Order validation failed: %s", e.getMessage()); + return Response.status(Response.Status.BAD_REQUEST) + .entity(Map.of("error", e.getMessage())).build(); + + } catch (RuntimeException e) { + orderSpan.setStatus(StatusCode.ERROR, e.getMessage()); + orderSpan.recordException(e); + ordersCounter("failed").increment(); + LOG.errorf(e, "Order processing failed: %s", e.getMessage()); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .entity(Map.of("error", "Order processing failed", "detail", e.getMessage())).build(); + } + }); + } finally { + orderSpan.end(); + } + } + + /** + * GET /api/orders — List all orders. + */ + @GET + @Path("/orders") + public Response listOrders() { + LOG.debugf("Listing %d orders", orders.size()); + return Response.ok(orders).build(); + } + + /** + * GET /api/orders/{id} — Get a single order by ID. + */ + @GET + @Path("/orders/{id}") + public Response getOrder(@PathParam("id") String id) { + return orders.stream() + .filter(o -> o.id.equals(id)) + .findFirst() + .map(o -> Response.ok(o).build()) + .orElseGet(() -> { + LOG.warnf("Order not found: %s", id); + return Response.status(Response.Status.NOT_FOUND) + .entity(Map.of("error", "Order not found")).build(); + }); + } + + /** + * GET /api/inventory — Current inventory levels (gauge metrics). + */ + @GET + @Path("/inventory") + public Response getInventory() { + return Response.ok(inventoryService.getInventoryLevels()).build(); + } + + // ────── Internal Processing Steps (each with its own span) ────── + + private void validateOrder(OrderRequest request) { + Span span = tracer.spanBuilder("validateOrder").startSpan(); + try (Scope s = span.makeCurrent()) { + if (request.product == null || request.product.isBlank()) { + throw new IllegalArgumentException("Product name is required"); + } + if (request.quantity <= 0) { + throw new IllegalArgumentException("Quantity must be positive"); + } + if (request.unitPrice <= 0) { + throw new IllegalArgumentException("Unit price must be positive"); + } + span.setAttribute("validation.passed", true); + LOG.debugf("Order validation passed for product=%s", request.product); + } finally { + span.end(); + } + } + + private boolean checkInventory(String product, int quantity) { + Span span = tracer.spanBuilder("checkInventory") + .setAttribute("inventory.product", product) + .setAttribute("inventory.requested_quantity", (long) quantity) + .startSpan(); + try (Scope s = span.makeCurrent()) { + // Simulate a small network call delay + Thread.sleep(ThreadLocalRandom.current().nextInt(10, 50)); + int available = inventoryService.getStock(product); + span.setAttribute("inventory.available", (long) available); + boolean inStock = available >= quantity; + span.setAttribute("inventory.in_stock", inStock); + LOG.debugf("Inventory check: product=%s, available=%d, requested=%d, inStock=%s", + product, available, quantity, inStock); + return inStock; + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + return false; + } finally { + span.end(); + } + } + + private void processPayment(OrderRequest request) { + Span span = tracer.spanBuilder("processPayment") + .setSpanKind(SpanKind.CLIENT) + .setAttribute("payment.amount", request.quantity * request.unitPrice) + .setAttribute("payment.currency", "USD") + .startSpan(); + try (Scope s = span.makeCurrent()) { + // Simulate payment gateway latency + Thread.sleep(ThreadLocalRandom.current().nextInt(20, 150)); + span.setAttribute("payment.status", "approved"); + LOG.infof("Payment processed: amount=%.2f", request.quantity * request.unitPrice); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } finally { + span.end(); + } + } + + private void simulateProcessingDelay(String type) { + try { + if ("complex".equals(type)) { + Thread.sleep(ThreadLocalRandom.current().nextInt(200, 800)); + } else { + Thread.sleep(ThreadLocalRandom.current().nextInt(10, 100)); + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } + + // ────── Request DTO ────── + + public static class OrderRequest { + public String customerId; + public String product; + public int quantity; + public double unitPrice; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..724fe0c --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,44 @@ +# ── Application ────────────────────────────────────────────── +quarkus.application.name=otel-quarkus-demo +quarkus.application.version=1.0.0 +quarkus.http.port=8080 + +# ── OpenTelemetry ──────────────────────────────────────────── +# OTLP endpoint — points to the OTel Collector service in-cluster +quarkus.otel.exporter.otlp.endpoint=http://otel-collector-opentelemetry-collector.argos:4317 + +# Resource attributes +quarkus.otel.resource.attributes=service.name=otel-quarkus-demo,service.namespace=argos,deployment.environment=dev + +# Enable all signals +quarkus.otel.traces.enabled=true +quarkus.otel.metrics.enabled=true +quarkus.otel.logs.enabled=true + +# Sampler — collect everything for the demo (use ratio in prod) +quarkus.otel.traces.sampler=always_on + +# ── Micrometer ─────────────────────────────────────────────── +# Prometheus scrape endpoint at /q/metrics (belt-and-suspenders with OTLP push) +quarkus.micrometer.export.prometheus.enabled=true +quarkus.micrometer.export.prometheus.path=/q/metrics + +# OTLP push for micrometer metrics (goes to OTel Collector) +quarkus.micrometer.export.otlp.url=http://otel-collector-opentelemetry-collector.argos:4318/v1/metrics + +# ── Logging ────────────────────────────────────────────────── +# JSON structured logging — makes logs parseable in Loki +quarkus.log.console.format=%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p traceId=%X{traceId} spanId=%X{spanId} [%c{2.}] (%t) %s%e%n +quarkus.log.console.json.enabled=false + +# Log level +quarkus.log.level=INFO +quarkus.log.category."com.demo".level=DEBUG + +# ── Health ─────────────────────────────────────────────────── +quarkus.smallrye-health.root-path=/q/health + +# ── Container Image ───────────────────────────────────────── +quarkus.container-image.group=global +quarkus.container-image.name=quarkus-app +quarkus.container-image.tag=latest