-
-
Notifications
You must be signed in to change notification settings - Fork 335
chore: add a way for running local observability stack with Tolgee running outside of docker #3448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -298,6 +298,53 @@ bootRun { | |
| } | ||
| } | ||
|
|
||
| // Copy OTEL agent JAR to a predictable location for manual IntelliJ run configuration. | ||
| // Not used by bootRun or bootRunWithObservability (they resolve the agent from Gradle's dependency cache). | ||
| // Usage: ./gradlew server-app:copyOtelAgent → build/otel/opentelemetry-javaagent.jar | ||
| // Then add -javaagent:backend/app/build/otel/opentelemetry-javaagent.jar to your IntelliJ VM options. | ||
| // See: docs/observability/ | ||
| tasks.register('copyOtelAgent', Copy) { | ||
| from configurations.otelAgent | ||
| into "${buildDir}/otel" | ||
| rename { 'opentelemetry-javaagent.jar' } | ||
| } | ||
|
Comment on lines
+301
to
+310
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify Gradle project structure and task path
echo "=== Checking for settings.gradle files ==="
fd -t f 'settings\.gradle' --max-depth 3
echo -e "\n=== Checking settings.gradle content ==="
find . -maxdepth 3 -name 'settings.gradle*' -exec cat {} \;
echo -e "\n=== Checking backend directory structure ==="
ls -la backend/ 2>/dev/null | head -20
echo -e "\n=== Checking if server-app directory exists ==="
find . -maxdepth 3 -type d -name '*server*app*' -o -type d -name 'server-app'
echo -e "\n=== Checking for other Gradle task invocations ==="
rg 'gradlew.*copyOtelAgent|gradlew.*bootRun' --max-count 10Repository: tolgee/tolgee-platform Length of output: 8912 🏁 Script executed: #!/bin/bash
# Verify buildDir usage and deprecation
echo "=== Checking Gradle version and buildDir patterns ==="
grep -r "gradle\|buildDir\|layout.buildDirectory" gradle.properties settings.gradle 2>/dev/null | head -20
echo -e "\n=== Checking buildDir usage in build.gradle files ==="
rg 'buildDir|layout\.buildDirectory' backend/ --type gradle --max-count 15
echo -e "\n=== Checking environment variable naming in bootRun tasks ==="
rg 'environment.*SPRING|spring\.' backend/app/build.gradle -A 2 -B 2Repository: tolgee/tolgee-platform Length of output: 2923 🏁 Script executed: #!/bin/bash
# Verify the correct module naming in Gradle
echo "=== Checking gradle wrapper and build files ==="
find . -maxdepth 2 -name 'gradle.properties' -o -name 'build.gradle' | head -10 | xargs head -5
echo -e "\n=== Checking if 'app' module exists in backend ==="
test -f backend/app/build.gradle && echo "backend/app/build.gradle EXISTS" || echo "NOT FOUND"
echo -e "\n=== Checking gradle tasks available ==="
grep -E "tasks\.(register|create)" backend/app/build.gradle | grep -E 'copyOtel|bootRun' | head -5Repository: tolgee/tolgee-platform Length of output: 561 Minor: Deprecated
Suggested fix tasks.register('copyOtelAgent', Copy) {
from configurations.otelAgent
- into "${buildDir}/otel"
+ into layout.buildDirectory.dir("otel")
rename { 'opentelemetry-javaagent.jar' }
}🤖 Prompt for AI Agents |
||
|
|
||
| // Run with local observability stack (docker-compose.local-observability-stack-dev.yaml) | ||
| // Drop-in replacement for bootRun: supports --args and all other BootRun options. | ||
| // See: docs/observability/ | ||
| tasks.register('bootRunWithObservability', org.springframework.boot.gradle.tasks.run.BootRun) { | ||
| group = 'application' | ||
| description = 'Runs Tolgee with OpenTelemetry tracing, using the local Docker observability stack' | ||
|
|
||
| // Inherit classpath and main class from bootRun (configured by Spring Boot plugin) | ||
| classpath = bootRun.classpath | ||
| mainClass.set(bootRun.mainClass) | ||
|
|
||
| // OTEL configuration | ||
| environment 'OTEL_JAVAAGENT_ENABLED', 'true' | ||
| environment 'OTEL_SERVICE_NAME', 'tolgee-platform' | ||
| environment 'OTEL_EXPORTER_OTLP_ENDPOINT', 'http://localhost:4318' | ||
| environment 'OTEL_RESOURCE_ATTRIBUTES', 'deployment.environment=local-dev' | ||
| environment 'OTEL_LOGS_EXPORTER', 'none' | ||
| environment 'OTEL_METRICS_EXPORTER', 'none' | ||
| environment 'OTEL_INSTRUMENTATION_LOGBACK_MDC_ENABLED', 'true' | ||
| environment 'OTEL_SEMCONV_STABILITY_OPT_IN', 'http' | ||
|
|
||
| // Database configuration (use Docker stack's PostgreSQL/Redis) | ||
| environment 'spring.datasource.url', 'jdbc:postgresql://localhost:5432/tolgee' | ||
| environment 'spring.datasource.username', 'tolgee' | ||
| environment 'spring.datasource.password', 'tolgee' | ||
| environment 'spring.redis.host', 'localhost' | ||
| environment 'spring.redis.port', '6379' | ||
| environment 'spring.redis.password', 'tolgee' | ||
| environment 'tolgee.postgres-autostart.enabled', 'false' | ||
|
|
||
| doFirst { | ||
| // Resolve agent JAR at execution time (not configuration time) | ||
| jvmArgs "-javaagent:${configurations.otelAgent.singleFile.absolutePath}" | ||
| } | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // ===== Apply custom tasks, if exist, from gitignored .local directory ===== | ||
| def customTasksFile = rootProject.file('.local/gradle/backend-app.gradle') | ||
| if (customTasksFile.exists()) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| # Local Observability Stack for IntelliJ development. | ||
| # Run Tolgee in IntelliJ with OTEL tracing while observability services run in Docker. | ||
| # See: docs/observability/ | ||
| name: tolgee-local-observability-stack-dev | ||
|
|
||
| services: | ||
| # Local Observability Stack (for development only) | ||
| tempo: | ||
| image: grafana/tempo:2.6.1 | ||
| command: ["-config.file=/etc/tempo.yaml"] | ||
| volumes: | ||
| - ./local-observability-stack/tempo-config.yaml:/etc/tempo.yaml:ro | ||
| - tempo-data:/var/tempo | ||
| ports: | ||
| - "3200:3200" | ||
| healthcheck: | ||
| test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3200/ready"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
|
|
||
| otel-collector: | ||
| image: otel/opentelemetry-collector-contrib:0.96.0 | ||
| command: ["--config=/etc/otel-collector-config.yaml"] | ||
| volumes: | ||
| - ./local-observability-stack/otel-collector-config.yaml:/etc/otel-collector-config.yaml:ro | ||
| ports: | ||
| - "4317:4317" | ||
| - "4318:4318" | ||
| - "13133:13133" | ||
| depends_on: | ||
| tempo: | ||
| condition: service_healthy | ||
| # Note: otel-collector image is scratch-based without shell utilities. | ||
| # Health check is disabled, but service exposes health_check extension on :13133 | ||
|
|
||
| loki: | ||
| image: grafana/loki:2.9.1 | ||
| command: ["-config.file=/etc/loki/local-config.yaml"] | ||
| volumes: | ||
| - ./local-observability-stack/loki-config.yaml:/etc/loki/local-config.yaml:ro | ||
| - loki-data:/loki | ||
| ports: | ||
| - "3100:3100" | ||
| healthcheck: | ||
| test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3100/ready"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
|
|
||
| promtail: | ||
| image: grafana/promtail:2.9.1 | ||
| command: ["-config.file=/etc/promtail/config.yaml"] | ||
| volumes: | ||
| - ./local-observability-stack/promtail-config.yaml:/etc/promtail/config.yaml:ro | ||
| - /var/lib/docker/containers:/var/lib/docker/containers:ro | ||
| - /var/run/docker.sock:/var/run/docker.sock | ||
| depends_on: | ||
| loki: | ||
| condition: service_healthy | ||
|
|
||
| prometheus: | ||
| image: prom/prometheus:v2.47.0 | ||
| command: | ||
| - '--config.file=/etc/prometheus/prometheus.yml' | ||
| - '--storage.tsdb.path=/prometheus' | ||
| - '--web.enable-remote-write-receiver' | ||
| volumes: | ||
| - ./local-observability-stack/prometheus.yaml:/etc/prometheus/prometheus.yml:ro | ||
| - prometheus-data:/prometheus | ||
| ports: | ||
| - "9090:9090" | ||
| healthcheck: | ||
| test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9090/-/ready"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
|
|
||
| grafana: | ||
| image: grafana/grafana:11.4.0 | ||
| environment: | ||
| - GF_SECURITY_ADMIN_USER=admin | ||
| - GF_SECURITY_ADMIN_PASSWORD=admin | ||
| - GF_AUTH_ANONYMOUS_ENABLED=true | ||
| - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin | ||
| - GF_AUTH_DISABLE_LOGIN_FORM=false | ||
| volumes: | ||
| - ./local-observability-stack/grafana/datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml:ro | ||
| - grafana-data:/var/lib/grafana | ||
| ports: | ||
| - "3000:3000" | ||
| depends_on: | ||
| tempo: | ||
| condition: service_healthy | ||
| loki: | ||
| condition: service_healthy | ||
| prometheus: | ||
| condition: service_healthy | ||
| healthcheck: | ||
| test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
|
|
||
| # Tolgee Dependencies | ||
| postgres: | ||
| image: postgres:15 | ||
| environment: | ||
| POSTGRES_USER: tolgee | ||
| POSTGRES_PASSWORD: tolgee | ||
| POSTGRES_DB: tolgee | ||
| volumes: | ||
| - postgres-data:/var/lib/postgresql/data | ||
| ports: | ||
| - "5432:5432" | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "pg_isready -U tolgee"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
|
|
||
| redis: | ||
| image: redis:7-alpine | ||
| command: ["redis-server", "--requirepass", "tolgee"] | ||
| volumes: | ||
| - redis-data:/data | ||
| ports: | ||
| - "6379:6379" | ||
| healthcheck: | ||
| test: ["CMD", "redis-cli", "-a", "tolgee", "ping"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
|
|
||
| volumes: | ||
| tempo-data: | ||
| loki-data: | ||
| grafana-data: | ||
| prometheus-data: | ||
| postgres-data: | ||
| redis-data: |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,10 +31,10 @@ Three capabilities for debugging and monitoring: | |||||||||||||||||
|
|
||||||||||||||||||
| ### Two Ways to Run with Tracing | ||||||||||||||||||
|
|
||||||||||||||||||
| | Method | Use Case | How | | ||||||||||||||||||
| |--------|----------|-----| | ||||||||||||||||||
| | `./gradlew bootRun` | Local development, quick iteration | `OTEL_JAVAAGENT_ENABLED=true ./gradlew bootRun` | | ||||||||||||||||||
| | Docker | Testing the full stack, CI, production-like | Set `OTEL_JAVAAGENT_ENABLED=true` in docker-compose environment (already done in `docker-compose.local-observability-stack.yaml`) | | ||||||||||||||||||
| | Method | Use Case | How | | ||||||||||||||||||
| |--------------------------------|---------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||||||||||||||||||
| | `./gradlew server-app:bootRun` | Local development, quick iteration | `docker compose -f docker-compose.local-observability-stack-dev.yaml up -d && ./gradlew server-app:bootRunWithObservability --args='--spring.profiles.active=dev'` | | ||||||||||||||||||
| | Docker (full stack) | Testing the full stack, CI, production-like | `docker compose -f docker-compose.local-observability-stack.yaml up -d` | | ||||||||||||||||||
|
Comment on lines
+34
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n docs/observability/README.md | head -50Repository: tolgee/tolgee-platform Length of output: 3363 Align the "Method" label with the command shown. The Method column shows ✏️ Suggested edit-| `./gradlew server-app:bootRun` | Local development, quick iteration | `docker compose -f docker-compose.local-observability-stack-dev.yaml up -d && ./gradlew server-app:bootRunWithObservability --args='--spring.profiles.active=dev'` |
+| `./gradlew server-app:bootRunWithObservability` | Local development, quick iteration | `docker compose -f docker-compose.local-observability-stack-dev.yaml up -d && ./gradlew server-app:bootRunWithObservability --args='--spring.profiles.active=dev'` |📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| Both methods use the same agent version from `gradle.properties`. | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this actually used anywhere - it should imho either be called as part of something, mentioned in the docs, or removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used by the IntelliJ IDEA runner in the other repo, though I'm not sure myself if it's required.