-
Notifications
You must be signed in to change notification settings - Fork 4
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
upgrade to SB 3.4 and polish observability #130
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 |
---|---|---|
@@ -1,19 +1,62 @@ | ||
services: | ||
ollama: | ||
image: langchain4j/ollama-llama3:latest | ||
ports: | ||
- '11434:11434' | ||
redis-stack: | ||
image: redis/redis-stack-server | ||
ports: | ||
- '6379:6379' | ||
lgtm-stack: | ||
image: grafana/otel-lgtm:0.8.0 | ||
extra_hosts: ['host.docker.internal:host-gateway'] | ||
container_name: lgtm-stack | ||
environment: | ||
- OTEL_METRIC_EXPORT_INTERVAL=500 | ||
ports: | ||
- "3000:3000" | ||
- "4317:4317" | ||
- "4318:4318" | ||
|
||
ollama: | ||
container_name: ollama | ||
image: ollama/ollama:latest | ||
ports: | ||
- '11434:11434' | ||
|
||
postgresqldb: | ||
container_name: postgresqldb | ||
image: pgvector/pgvector:pg17 | ||
extra_hosts: [ 'host.docker.internal:host-gateway' ] | ||
restart: always | ||
environment: | ||
- POSTGRES_USER=appuser | ||
- POSTGRES_PASSWORD=secret | ||
- POSTGRES_DB=appdb | ||
- PGPASSWORD=secret | ||
logging: | ||
options: | ||
max-size: 10m | ||
max-file: "3" | ||
ports: | ||
- '5432:5432' | ||
healthcheck: | ||
test: "pg_isready -U appuser -d appdb" | ||
interval: 2s | ||
timeout: 20s | ||
retries: 10 | ||
|
||
pgadmin: | ||
container_name: pgadmin_container | ||
image: dpage/pgadmin4 | ||
extra_hosts: [ 'host.docker.internal:host-gateway' ] | ||
environment: | ||
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:[email protected]} | ||
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin} | ||
PGADMIN_CONFIG_SERVER_MODE: "False" | ||
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: "False" | ||
ports: | ||
- "${PGADMIN_PORT:-5050}:80" | ||
depends_on: | ||
postgresqldb: | ||
condition: service_healthy | ||
volumes: | ||
- ./docker_pgadmin_servers.json:/pgadmin4/servers.json | ||
entrypoint: | ||
- "/bin/sh" | ||
- "-c" | ||
- "/bin/echo 'postgresqldb:5432:*:appuser:secret' > /tmp/pgpassfile && chmod 600 /tmp/pgpassfile && /entrypoint.sh" | ||
|
||
lgtm-stack: | ||
image: grafana/otel-lgtm:0.8.1 | ||
extra_hosts: [ 'host.docker.internal:host-gateway' ] | ||
container_name: lgtm-stack | ||
environment: | ||
- OTEL_METRIC_EXPORT_INTERVAL=500 | ||
ports: | ||
- "3000:3000" | ||
- "4317:4317" | ||
- "4318:4318" | ||
- "9090:9090" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"Servers": { | ||
"1": { | ||
"Name": "Docker Compose DB", | ||
"Group": "Servers", | ||
"Port": 5432, | ||
"Username": "appuser", | ||
"Host": "postgresqldb", | ||
"SSLMode": "prefer", | ||
"MaintenanceDB": "appdb", | ||
"PassFile": "/tmp/pgpassfile" | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,11 @@ | ||||||||||||||||||||||||
## WARNING: Development-only configuration | ||||||||||||||||||||||||
## The following setting will DELETE existing vector store data on startup | ||||||||||||||||||||||||
spring.ai.vectorstore.pgvector.removeExistingVectorStoreTable=true | ||||||||||||||||||||||||
Comment on lines
+1
to
+3
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. 💡 Codebase verification The dangerous vector store table removal setting is not properly isolated. It's currently set in:
Having this setting in the default Recommendations:
🔗 Analysis chainVerify configuration isolation for data deletion setting The vector store table removal setting is dangerous and should be strictly isolated to local development. Let's verify this setting isn't present in other profiles: Let me verify if this setting is properly isolated by checking the context of its usage in the other file. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for vector store removal setting in all property files
fd -e properties -e yml -e yaml | xargs rg "spring.ai.vectorstore.pgvector.removeExistingVectorStoreTable"
Length of output: 392 Script: #!/bin/bash
# Get context for the other occurrence
rg -B2 -A2 "spring.ai.vectorstore.pgvector.removeExistingVectorStoreTable" embeddingstores/pgvector-springai/src/main/resources/application.properties
Length of output: 342 |
||||||||||||||||||||||||
spring.ai.ollama.baseUrl=http://localhost:11434 | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
logging.level.org.springframework.ai.rag=debug | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
spring.datasource.url=jdbc:postgresql://localhost/appdb | ||||||||||||||||||||||||
spring.datasource.username=appuser | ||||||||||||||||||||||||
spring.datasource.password=secret | ||||||||||||||||||||||||
Comment on lines
+9
to
+11
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. Secure database credentials and add connection pool settings Several security and configuration concerns:
Apply these changes: -spring.datasource.url=jdbc:postgresql://localhost/appdb
-spring.datasource.username=appuser
-spring.datasource.password=secret
+spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost/appdb}
+spring.datasource.username=${SPRING_DATASOURCE_USERNAME}
+spring.datasource.password=${SPRING_DATASOURCE_PASSWORD}
+
+# Connection pool settings
+spring.datasource.hikari.maximum-pool-size=10
+spring.datasource.hikari.minimum-idle=5
+spring.datasource.hikari.idle-timeout=300000 Also, consider using Spring Cloud Config Server or HashiCorp Vault for secure credential management in a production environment. 📝 Committable suggestion
Suggested change
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,26 +3,32 @@ spring.application.name=rag-springai-ollama-llm | |||||||||||||||||||||||
spring.threads.virtual.enabled=true | ||||||||||||||||||||||||
spring.mvc.problemdetails.enabled=true | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
spring.ai.ollama.init.pull-model-strategy=WHEN_MISSING | ||||||||||||||||||||||||
spring.ai.ollama.chat.options.model=mistral | ||||||||||||||||||||||||
spring.ai.ollama.chat.options.temperature=0.3 | ||||||||||||||||||||||||
spring.ai.ollama.chat.options.top-k=2 | ||||||||||||||||||||||||
spring.ai.ollama.chat.options.top-p=0.2 | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
spring.ai.ollama.embedding.options.model=nomic-embed-text | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
spring.ai.vectorstore.redis.index=vector_store | ||||||||||||||||||||||||
spring.ai.vectorstore.redis.prefix=ai | ||||||||||||||||||||||||
spring.ai.vectorstore.redis.initialize-schema=true | ||||||||||||||||||||||||
#PgVector | ||||||||||||||||||||||||
spring.ai.vectorstore.observations.include-query-response=true | ||||||||||||||||||||||||
spring.ai.vectorstore.pgvector.initialize-schema=true | ||||||||||||||||||||||||
Comment on lines
+14
to
+16
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. 💡 Codebase verification Missing required PostgreSQL connection properties for PgVector The PgVector configuration is incomplete. Based on the example from
These properties should be added to either Example of required properties: spring.datasource.url=jdbc:postgresql://localhost/appdb
spring.datasource.username=appuser
spring.datasource.password=secret 🔗 Analysis chainVerify PgVector connection properties While schema initialization is configured, the PostgreSQL connection properties appear to be missing. These are typically required for PgVector to function. Let's check if these properties are defined elsewhere: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for PostgreSQL connection properties in all property files
fd -e properties -e yaml | xargs rg -l "spring\.datasource\.(url|username|password)"
Length of output: 403 Script: #!/bin/bash
# Let's check the content of application-local.properties in the same directory
cat rag/rag-springai-ollama-llm/src/main/resources/application-local.properties 2>/dev/null || echo "File not found"
# Also check if there are any other property files in the same directory
ls rag/rag-springai-ollama-llm/src/main/resources/
# Let's also examine one of the found PgVector examples to see the required properties
cat embeddingstores/pgvector-springai/src/main/resources/application-local.properties
Length of output: 428 |
||||||||||||||||||||||||
|
||||||||||||||||||||||||
spring.ai.ollama.baseUrl=http://localhost:11434 | ||||||||||||||||||||||||
spring.http.client.connect-timeout=PT1M | ||||||||||||||||||||||||
spring.http.client.read-timeout=PT5M | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
spring.testcontainers.beans.startup=parallel | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
##Observability | ||||||||||||||||||||||||
spring.ai.chat.observations.include-completion=true | ||||||||||||||||||||||||
spring.ai.chat.observations.include-prompt=true | ||||||||||||||||||||||||
spring.ai.chat.client.observations.include-input=true | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
management.endpoints.web.exposure.include=* | ||||||||||||||||||||||||
management.metrics.tags.service.name=${spring.application.name} | ||||||||||||||||||||||||
management.tracing.sampling.probability=1.0 | ||||||||||||||||||||||||
management.otlp.tracing.endpoint=http://localhost:4318/v1/traces | ||||||||||||||||||||||||
management.otlp.logging.endpoint=http://localhost:4318/v1/logs | ||||||||||||||||||||||||
Comment on lines
28
to
+32
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. Security: Restrict management endpoint exposure Exposing all management endpoints ( Consider:
-management.endpoints.web.exposure.include=*
+management.endpoints.web.exposure.include=health,metrics,prometheus,info
+management.endpoints.web.exposure.exclude=env,beans 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
logging.level.org.springframework.ai.rag=info |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
<include resource="org/springframework/boot/logging/logback/base.xml" /> | ||
|
||
<appender name="OpenTelemetry" | ||
class="io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender"> | ||
<captureExperimentalAttributes>true</captureExperimentalAttributes> | ||
<captureCodeAttributes>true</captureCodeAttributes> | ||
<captureKeyValuePairAttributes>true</captureKeyValuePairAttributes> | ||
</appender> | ||
|
||
<root level="INFO"> | ||
<appender-ref ref="OpenTelemetry"/> | ||
</root> | ||
|
||
</configuration> |
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.
🛠️ Refactor suggestion
Enhance error handling and observability.
The current implementation lacks proper error handling and could benefit from enhanced observability, especially given the PR's objective to "polish observability".
Consider implementing these improvements:
📝 Committable suggestion